Commit a16f9bdf authored by John Tapsell's avatar John Tapsell

Improve the UI for editing a text label

parent d046a5f2
......@@ -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());
......
......@@ -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;
......
......@@ -6,34 +6,36 @@
<rect>
<x>0</x>
<y>0</y>
<width>1183</width>
<height>166</height>
<width>554</width>
<height>107</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="100,0,0">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="2" column="0" colspan="2">
<widget class="QLineEdit" name="editNameLabel">
<property name="text">
<string>&lt;Label Description Label (in front of text)&gt;</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="editNameLabel">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Label Description</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="isMavCommand">
<property name="text">
<string>Mav Command</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="3">
<item>
<widget class="Line" name="editLine1">
<property name="minimumSize">
<size>
......@@ -46,68 +48,56 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Description</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="editTextParam">
<property name="text">
<string>&lt;Text Param&gt;</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Description</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="textLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="editFinishButton">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QSpinBox" name="editComponentSpinBox">
<property name="prefix">
<string>Component ID: </string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="Line" name="editLine2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="textLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="editFinishButton">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......@@ -120,8 +110,8 @@
<slot>setText(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>114</x>
<y>22</y>
<x>280</x>
<y>32</y>
</hint>
<hint type="destinationlabel">
<x>114</x>
......
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