From a16f9bdf6ec10dd2e72ab4bbc8c879019c8c8949 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Sat, 12 Oct 2013 23:30:09 +0100 Subject: [PATCH] Improve the UI for editing a text label --- src/ui/designer/QGCTextLabel.cc | 35 ++----- src/ui/designer/QGCTextLabel.h | 1 + src/ui/designer/QGCTextLabel.ui | 160 +++++++++++++++----------------- 3 files changed, 82 insertions(+), 114 deletions(-) diff --git a/src/ui/designer/QGCTextLabel.cc b/src/ui/designer/QGCTextLabel.cc index dd2bbf940c..b1b1731c7b 100644 --- a/src/ui/designer/QGCTextLabel.cc +++ b/src/ui/designer/QGCTextLabel.cc @@ -19,13 +19,7 @@ QGCTextLabel::QGCTextLabel(QWidget *parent) : // Hide all edit items ui->editFinishButton->hide(); ui->editNameLabel->hide(); - ui->editTextParam->hide(); - ui->editComponentSpinBox->hide(); ui->editLine1->hide(); - ui->editLine2->hide(); - - // Add commands to combo box - } QGCTextLabel::~QGCTextLabel() @@ -37,13 +31,9 @@ void QGCTextLabel::startEditMode() { // Hide elements ui->nameLabel->hide(); - - ui->editTextParam->show(); ui->editFinishButton->show(); ui->editNameLabel->show(); - ui->editComponentSpinBox->show(); ui->editLine1->show(); - ui->editLine2->show(); // Attempt to undock the dock widget QWidget* p = this; @@ -66,12 +56,8 @@ void QGCTextLabel::startEditMode() void QGCTextLabel::endEditMode() { ui->editFinishButton->hide(); - ui->editTextParam->hide(); ui->editNameLabel->hide(); - ui->editComponentSpinBox->hide(); ui->editLine1->hide(); - ui->editLine2->hide(); - ui->nameLabel->show(); // Write to settings @@ -105,23 +91,17 @@ void QGCTextLabel::writeSettings(QSettings& settings) } void QGCTextLabel::readSettings(const QString& pre,const QVariantMap& settings) { - ui->editTextParam->setText(settings.value(pre + "QGC_TEXT_SOURCE", "UNKNOWN").toString()); - //ui->editCommandComboBox->setCurrentIndex(settings.value(pre + "QGC_COMMAND_BUTTON_COMMANDID", 0).toInt()); - if (ui->editTextParam->text() == "NONE") + 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 if (ui->editTextParam->text() == "MAV") + else { //MAV command text connect(uas,SIGNAL(textMessageReceived(int,int,int,QString)),this,SLOT(textMessageReceived(int,int,int,QString))); } - - //int commandId = settings.value(pre + "QGC_COMMAND_BUTTON_COMMANDID", 0).toInt(); - - //ui->editNameLabel->setText(settings.value(pre + "QGC_COMMAND_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString()); - //ui->nameLabel->setText(settings.value(pre + "QGC_COMMAND_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString()); } void QGCTextLabel::textMessageReceived(int uasid, int component, int severity, QString message) { @@ -148,17 +128,14 @@ void QGCTextLabel::textMessageReceived(int uasid, int component, int severity, Q void QGCTextLabel::readSettings(const QSettings& settings) { - //ui->editNameLabel->setText(settings.value("QGC_COMMAND_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString()); - //ui->nameLabel->setText(settings.value("QGC_COMMAND_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString()); - ui->editTextParam->setText(settings.value("QGC_TEXT_SOURCE", "UNKNOWN").toString()); + ui->isMavCommand->setChecked(settings.value("QGC_TEXT_SOURCE", "NONE").toString() == "MAV"); ui->editNameLabel->setText(settings.value("QGC_TEXT_TEXT","").toString()); - //ui->editCommandComboBox->setCurrentIndex(settings.value(pre + "QGC_COMMAND_BUTTON_COMMANDID", 0).toInt()); - if (ui->editTextParam->text() == "NONE") + if (!ui->isMavCommand->isChecked()) { ui->textLabel->setText(ui->editNameLabel->text()); ui->nameLabel->setText(""); } - else if (ui->editTextParam->text() == "MAV") + else { //MAV command text ui->nameLabel->setText(ui->editNameLabel->text()); diff --git a/src/ui/designer/QGCTextLabel.h b/src/ui/designer/QGCTextLabel.h index 3828d734fc..f4c23d2c78 100644 --- a/src/ui/designer/QGCTextLabel.h +++ b/src/ui/designer/QGCTextLabel.h @@ -26,6 +26,7 @@ public slots: void readSettings(const QSettings& settings); void readSettings(const QString& pre,const QVariantMap& settings); void textMessageReceived(int uasid, int componentId, int severity, QString message); + private: int enabledNum; Ui::QGCTextLabel *ui; diff --git a/src/ui/designer/QGCTextLabel.ui b/src/ui/designer/QGCTextLabel.ui index 78ba1dda55..24d446ed46 100644 --- a/src/ui/designer/QGCTextLabel.ui +++ b/src/ui/designer/QGCTextLabel.ui @@ -6,34 +6,36 @@ 0 0 - 1183 - 166 + 554 + 107 Form - - - 6 - - - 3 - - - 6 - - - 3 - - - - - <Label Description Label (in front of text)> - - + + + + + + + + + + Label Description + + + + + + + Mav Command + + + + - + @@ -46,68 +48,56 @@ - - - - - 50 - 0 - - - - Description - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - <Text Param> - - + + + + + + + 50 + 0 + + + + Description + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + TextLabel + + + + - - - - Done - - - - - - - Component ID: - - - 0 - - - 255 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - - - - - TextLabel - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Done + + + + @@ -120,8 +110,8 @@ setText(QString) - 114 - 22 + 280 + 32 114 -- GitLab