Commit 94fcdaa3 authored by Lorenz Meier's avatar Lorenz Meier

Instatiation / state fixes

parent 107d7167
...@@ -22,6 +22,7 @@ QGCConfigView::QGCConfigView(QWidget *parent) : ...@@ -22,6 +22,7 @@ QGCConfigView::QGCConfigView(QWidget *parent) :
ui->gridLayout->removeWidget(ui->waitingLabel); ui->gridLayout->removeWidget(ui->waitingLabel);
ui->waitingLabel->setVisible(false); ui->waitingLabel->setVisible(false);
delete ui->waitingLabel; delete ui->waitingLabel;
ui->waitingLabel = NULL;
config = new QGCPX4VehicleConfig(); config = new QGCPX4VehicleConfig();
ui->gridLayout->addWidget(config); ui->gridLayout->addWidget(config);
...@@ -48,10 +49,12 @@ void QGCConfigView::activeUASChanged(UASInterface* uas) ...@@ -48,10 +49,12 @@ void QGCConfigView::activeUASChanged(UASInterface* uas)
type = mav->getAutopilotType(); type = mav->getAutopilotType();
mav = uas; mav = uas;
if (NULL != uas && type != uas->getAutopilotType()) { if (uas && type != uas->getAutopilotType()) {
ui->gridLayout->removeWidget(ui->waitingLabel); if (ui->waitingLabel) {
ui->waitingLabel->setVisible(false); ui->gridLayout->removeWidget(ui->waitingLabel);
ui->waitingLabel->setVisible(false);
}
//remove all child widgets since they could contain stale data //remove all child widgets since they could contain stale data
//for example, when we switch from one PX4 UAS to another UAS //for example, when we switch from one PX4 UAS to another UAS
......
...@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project
QGCToolBar::QGCToolBar(QWidget *parent) : QGCToolBar::QGCToolBar(QWidget *parent) :
QToolBar(parent), QToolBar(parent),
mav(NULL), mav(NULL),
userBaudChoice(false),
changed(true), changed(true),
batteryPercent(0), batteryPercent(0),
batteryVoltage(0), batteryVoltage(0),
...@@ -180,7 +181,7 @@ void QGCToolBar::createUI() ...@@ -180,7 +181,7 @@ void QGCToolBar::createUI()
baudcomboBox->addItem("921600", 921600); baudcomboBox->addItem("921600", 921600);
baudcomboBox->setCurrentIndex(baudcomboBox->findData(57600)); baudcomboBox->setCurrentIndex(baudcomboBox->findData(57600));
addWidget(baudcomboBox); addWidget(baudcomboBox);
connect(baudcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(baudSelected(int)));
connectButton = new QPushButton(tr("Connect"), this); connectButton = new QPushButton(tr("Connect"), this);
...@@ -251,6 +252,11 @@ void QGCToolBar::resetToolbarUI() ...@@ -251,6 +252,11 @@ void QGCToolBar::resetToolbarUI()
symbolLabel->clear(); symbolLabel->clear();
} }
void QGCToolBar::baudSelected(int index)
{
userBaudChoice = true;
}
void QGCToolBar::setPerspectiveChangeActions(const QList<QAction*> &actions) void QGCToolBar::setPerspectiveChangeActions(const QList<QAction*> &actions)
{ {
if (actions.count() > 1) if (actions.count() > 1)
...@@ -679,7 +685,12 @@ void QGCToolBar::updateComboBox() ...@@ -679,7 +685,12 @@ void QGCToolBar::updateComboBox()
portComboBox->setEditText(tr("No serial port found")); portComboBox->setEditText(tr("No serial port found"));
} }
} }
baudcomboBox->setCurrentIndex(baudcomboBox->findData(slink->getBaudRate()));
if (!userBaudChoice) {
int index = baudcomboBox->findData(slink->getBaudRate());
if (index > 0)
baudcomboBox->setCurrentIndex(index);
}
} }
} }
......
...@@ -87,6 +87,12 @@ public slots: ...@@ -87,6 +87,12 @@ public slots:
void advancedActivityTriggered(QAction* action); void advancedActivityTriggered(QAction* action);
void updateComboBox(); void updateComboBox();
/**
* @brief User selected baud rate
* @param index The current index of the combo box
*/
void baudSelected(int index);
protected: protected:
void storeSettings(); void storeSettings();
void loadSettings(); void loadSettings();
...@@ -110,6 +116,7 @@ protected: ...@@ -110,6 +116,7 @@ protected:
QComboBox *portComboBox; QComboBox *portComboBox;
QComboBox *baudcomboBox; QComboBox *baudcomboBox;
QTimer portBoxTimer; QTimer portBoxTimer;
bool userBaudChoice;
bool changed; bool changed;
float batteryPercent; float batteryPercent;
float batteryVoltage; 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