Commit d4e5dabf authored by Lorenz Meier's avatar Lorenz Meier

Designer widgets: Ensure correct initialization sequence, make sure signals are only connected once

parent bc23c2db
......@@ -23,7 +23,6 @@ QGCComboBox::QGCComboBox(QWidget *parent) :
ui->setupUi(this);
uas = NULL;
ui->editInfoCheckBox->hide();
ui->editDoneButton->hide();
ui->editNameLabel->hide();
......@@ -60,10 +59,8 @@ QGCComboBox::QGCComboBox(QWidget *parent) :
connect(ui->editInfoCheckBox, SIGNAL(clicked(bool)), this, SLOT(showInfo(bool)));
// connect to self
connect(ui->infoLabel, SIGNAL(released()), this, SLOT(showTooltip()));
// Set the current UAS if present
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
init();
}
QGCComboBox::~QGCComboBox()
......
......@@ -84,6 +84,8 @@ QGCCommandButton::QGCCommandButton(QWidget *parent) :
ui->editCommandComboBox->addItem("MAV_CMD_MISSION_START", MAV_CMD_MISSION_START);
ui->editCommandComboBox->addItem("MAV_CMD_COMPONENT_ARM_DISARM", MAV_CMD_COMPONENT_ARM_DISARM);
ui->editCommandComboBox->setEditable(true);
init();
}
QGCCommandButton::~QGCCommandButton()
......
......@@ -69,9 +69,9 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
// connect to self
connect(ui->infoLabel, SIGNAL(released()),
this, SLOT(showTooltip()));
// Set the current UAS if present
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*)));
init();
requestParameter();
}
QGCParamSlider::~QGCParamSlider()
......@@ -220,6 +220,8 @@ void QGCParamSlider::setEditMode(bool editMode)
parameterMin = ui->editMinSpinBox->value();
parameterMax = ui->editMaxSpinBox->value();
requestParameter();
switch ((int)parameterValue.type())
{
case QVariant::Char:
......@@ -264,6 +266,7 @@ void QGCParamSlider::setParamPending()
{
if (uas) {
uas->getParamManager()->setPendingParam(componentId, parameterName, parameterValue);
uas->getParamManager()->sendPendingParameters(true, true);
}
else {
qWarning() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
......
......@@ -143,19 +143,6 @@
</property>
</widget>
</item>
<item row="5" column="2" colspan="9">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="10">
<widget class="QPushButton" name="readButton">
<property name="minimumSize">
......@@ -286,6 +273,19 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="11">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
......
......@@ -24,6 +24,8 @@ QGCTextLabel::QGCTextLabel(QWidget *parent) :
ui->editLine2->hide();
ui->isMavCommand->hide();
ui->textLabel->setText(QString());
init();
}
QGCTextLabel::~QGCTextLabel()
......
......@@ -15,14 +15,19 @@ QGCToolWidgetItem::QGCToolWidgetItem(const QString& name, QWidget *parent) :
_component(-1)
{
startEditAction = new QAction(tr("Edit %1").arg(qgcToolWidgetItemName), this);
connect(startEditAction, SIGNAL(triggered()), this, SLOT(startEditMode()));
stopEditAction = new QAction(tr("Finish Editing %1").arg(qgcToolWidgetItemName), this);
connect(stopEditAction, SIGNAL(triggered()), this, SLOT(endEditMode()));
deleteAction = new QAction(tr("Delete %1").arg(qgcToolWidgetItemName), this);
}
void QGCToolWidgetItem::init()
{
connect(startEditAction, SIGNAL(triggered()), this, SLOT(startEditMode()));
connect(stopEditAction, SIGNAL(triggered()), this, SLOT(endEditMode()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteLater()));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*)));
// Set first UAS if it exists
setActiveUAS(UASManager::instance()->getActiveUAS());
}
......
......@@ -37,6 +37,7 @@ signals:
protected:
void contextMenuEvent (QContextMenuEvent* event);
void init();
UASInterface* uas;
private:
......
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