diff --git a/src/ui/designer/QGCTextLabel.cc b/src/ui/designer/QGCTextLabel.cc
index b1b1731..ceb645f 100644
--- a/src/ui/designer/QGCTextLabel.cc
+++ b/src/ui/designer/QGCTextLabel.cc
@@ -7,7 +7,7 @@
#include "UASManager.h"
QGCTextLabel::QGCTextLabel(QWidget *parent) :
- QGCToolWidgetItem("Command Button", parent),
+ QGCToolWidgetItem("Text Label", parent),
ui(new Ui::QGCTextLabel)
{
uas = 0;
@@ -15,11 +15,15 @@ QGCTextLabel::QGCTextLabel(QWidget *parent) :
ui->setupUi(this);
connect(ui->editFinishButton, SIGNAL(clicked()), this, SLOT(endEditMode()));
+ connect(ui->isMavCommand, SIGNAL(toggled(bool)), this, SLOT(update_isMavCommand()));
// Hide all edit items
ui->editFinishButton->hide();
ui->editNameLabel->hide();
ui->editLine1->hide();
+ ui->editLine2->hide();
+ ui->isMavCommand->hide();
+ ui->textLabel->setText(QString());
}
QGCTextLabel::~QGCTextLabel()
@@ -30,10 +34,11 @@ QGCTextLabel::~QGCTextLabel()
void QGCTextLabel::startEditMode()
{
// Hide elements
- ui->nameLabel->hide();
ui->editFinishButton->show();
ui->editNameLabel->show();
ui->editLine1->show();
+ ui->editLine2->show();
+ ui->isMavCommand->show();
// Attempt to undock the dock widget
QWidget* p = this;
@@ -55,10 +60,12 @@ void QGCTextLabel::startEditMode()
void QGCTextLabel::endEditMode()
{
+ update_isMavCommand();
ui->editFinishButton->hide();
ui->editNameLabel->hide();
ui->editLine1->hide();
- ui->nameLabel->show();
+ ui->editLine2->hide();
+ ui->isMavCommand->hide();
// Write to settings
emit editingFinished();
@@ -83,25 +90,17 @@ void QGCTextLabel::endEditMode()
void QGCTextLabel::writeSettings(QSettings& settings)
{
- qDebug() << "COMMAND BUTTON WRITING SETTINGS";
- settings.setValue("TYPE", "COMMANDBUTTON");
- settings.setValue("QGC_COMMAND_BUTTON_DESCRIPTION", ui->nameLabel->text());
+ settings.setValue("TYPE", "TEXT");
+ settings.setValue("QGC_TEXT_TEXT", ui->editNameLabel->text());
+ settings.setValue("QGC_TEXT_SOURCE", ui->isMavCommand->isChecked()?"MAV":"NONE");
settings.sync();
}
void QGCTextLabel::readSettings(const QString& pre,const QVariantMap& settings)
{
+ ui->editNameLabel->setText(settings.value(pre + "QGC_TEXT_TEXT","").toString());
ui->isMavCommand->setChecked(settings.value(pre + "QGC_TEXT_SOURCE", "NONE").toString() == "MAV");
- if (!ui->isMavCommand->isChecked())
- {
- ui->editNameLabel->setText(settings.value(pre + "QGC_TEXT_TEXT","").toString());
- ui->nameLabel->setText(ui->editNameLabel->text());
- }
- else
- {
- //MAV command text
- connect(uas,SIGNAL(textMessageReceived(int,int,int,QString)),this,SLOT(textMessageReceived(int,int,int,QString)));
- }
+ update_isMavCommand();
}
void QGCTextLabel::textMessageReceived(int uasid, int component, int severity, QString message)
{
@@ -128,28 +127,40 @@ void QGCTextLabel::textMessageReceived(int uasid, int component, int severity, Q
void QGCTextLabel::readSettings(const QSettings& settings)
{
+ ui->editNameLabel->setText(settings.value("QGC_TEXT_TEXT","").toString()); //Place this before setting isMavCommand
ui->isMavCommand->setChecked(settings.value("QGC_TEXT_SOURCE", "NONE").toString() == "MAV");
- ui->editNameLabel->setText(settings.value("QGC_TEXT_TEXT","").toString());
- if (!ui->isMavCommand->isChecked())
- {
- ui->textLabel->setText(ui->editNameLabel->text());
- ui->nameLabel->setText("");
- }
- else
- {
- //MAV command text
- ui->nameLabel->setText(ui->editNameLabel->text());
- ui->textLabel->setText("");
- connect(uas,SIGNAL(textMessageReceived(int,int,int,QString)),this,SLOT(textMessageReceived(int,int,int,QString)));
- }
+ update_isMavCommand();
}
+
void QGCTextLabel::enableText(int num)
{
enabledNum = num;
-
}
void QGCTextLabel::setActiveUAS(UASInterface *uas)
{
+ if(this->uas)
+ this->uas->disconnect(this);
this->uas = uas;
+ update_isMavCommand(); //Might need to update the signal connections
+}
+
+void QGCTextLabel::update_isMavCommand()
+{
+ ui->textLabel->setText("");
+ if (!ui->isMavCommand->isChecked())
+ {
+ ui->nameLabel->setText(ui->editNameLabel->text());
+ if(this->uas)
+ disconnect(uas,SIGNAL(textMessageReceived(int,int,int,QString)),this,SLOT(textMessageReceived(int,int,int,QString)));
+ if(ui->nameLabel->text().isEmpty())
+ ui->nameLabel->setText(tr("Text Label")); //Show something, so that we don't end up with just an empty label
+ }
+ else
+ {
+ //MAV command text
+ ui->nameLabel->setText(ui->editNameLabel->text());
+ if(this->uas)
+ connect(uas,SIGNAL(textMessageReceived(int,int,int,QString)),this,SLOT(textMessageReceived(int,int,int,QString)));
+ }
}
diff --git a/src/ui/designer/QGCTextLabel.h b/src/ui/designer/QGCTextLabel.h
index f4c23d2..a1c1d1d 100644
--- a/src/ui/designer/QGCTextLabel.h
+++ b/src/ui/designer/QGCTextLabel.h
@@ -27,6 +27,9 @@ public slots:
void readSettings(const QString& pre,const QVariantMap& settings);
void textMessageReceived(int uasid, int componentId, int severity, QString message);
+private slots:
+ void update_isMavCommand();
+
private:
int enabledNum;
Ui::QGCTextLabel *ui;
diff --git a/src/ui/designer/QGCTextLabel.ui b/src/ui/designer/QGCTextLabel.ui
index 24d446e..f5f909d 100644
--- a/src/ui/designer/QGCTextLabel.ui
+++ b/src/ui/designer/QGCTextLabel.ui
@@ -15,6 +15,19 @@
-
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+
+ -
-
@@ -28,6 +41,9 @@
-
+
+ This is only for advanced use, and allows a label to display the results of a Command Button.
+
Mav Command
@@ -36,19 +52,6 @@
-
-
-
-
- 0
- 0
-
-
-
- Qt::Horizontal
-
-
-
- -
-
@@ -59,7 +62,7 @@
- Description
+ Text Label
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
@@ -69,7 +72,7 @@
-
- TextLabel
+ mav result
@@ -99,6 +102,19 @@
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+
@@ -119,5 +135,21 @@
+
+ editNameLabel
+ returnPressed()
+ editFinishButton
+ animateClick()
+
+
+ 136
+ 20
+
+
+ 498
+ 86
+
+
+
diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc
index 7f976f6..f5302d7 100644
--- a/src/ui/designer/QGCToolWidget.cc
+++ b/src/ui/designer/QGCToolWidget.cc
@@ -296,7 +296,7 @@ void QGCToolWidget::loadSettings(QVariantMap& settings)
else if (type == "COMBO")
{
item = new QGCComboBox(this);
- //qDebug() << "CREATED PARAM COMBOBOX";
+ //qDebug() << "CREATED COMBOBOX";
}
if (item)
{
@@ -482,6 +482,7 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
QMenu menu(this);
menu.addAction(addParamAction);
menu.addAction(addCommandAction);
+ menu.addAction(addLabelAction);
menu.addSeparator();
menu.addAction(setTitleAction);
menu.addAction(exportAction);