Commit 40202972 authored by Lorenz Meier's avatar Lorenz Meier

Added periodic check for ports to QGC toolbar to not depend on port state on power up

parent baafca2e
......@@ -221,6 +221,9 @@ void QGCToolBar::createUI()
loadSettings();
connect(&portBoxTimer, SIGNAL(timeout()), this, SLOT(updateComboBox()));
portBoxTimer.start(500);
changed = false;
}
......@@ -647,25 +650,29 @@ void QGCToolBar::removeLink(LinkInterface* link)
}
void QGCToolBar::updateComboBox()
{
portComboBox->clear();
// portComboBox->clear();
if (currentLink)
{
SerialLink *slink = qobject_cast<SerialLink*>(currentLink);
QList<QString> portlist = slink->getCurrentPorts();
foreach(QString port, portlist) {
portComboBox->addItem(port, port);
foreach (QString port, portlist)
{
if (portComboBox->findText(port) == -1)
{
portComboBox->addItem(port, port);
}
}
portComboBox->setCurrentIndex(portComboBox->findData(slink->getPortName()));
if (slink->getPortName().trimmed().length() > 0)
{
portComboBox->setCurrentIndex(portComboBox->findData(slink->getPortName()));
portComboBox->setEditText(slink->getPortName());
}
else
{
if (portlist.length() > 0)
{
portComboBox->setEditText(portlist.first());
portComboBox->setEditText(portlist.last());
}
else
{
......
......@@ -31,6 +31,7 @@ This file is part of the QGROUNDCONTROL project
#include <QLabel>
#include <QProgressBar>
#include <QComboBox>
#include <QTimer>
#include "UASInterface.h"
#include "QGCMAVLinkLogPlayer.h"
#include "SerialLink.h"
......@@ -84,13 +85,13 @@ public slots:
void clearStatusString();
/** @brief Set an activity action as checked in menu */
void advancedActivityTriggered(QAction* action);
void updateComboBox();
protected:
void storeSettings();
void loadSettings();
void createUI();
void resetToolbarUI();
void updateComboBox();
UASInterface* mav;
QLabel* symbolLabel;
QLabel* toolBarNameLabel;
......@@ -108,6 +109,7 @@ protected:
QGCMAVLinkLogPlayer* player;
QComboBox *portComboBox;
QComboBox *baudcomboBox;
QTimer portBoxTimer;
bool changed;
float batteryPercent;
float batteryVoltage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment