diff --git a/ground/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/src/plugins/scope/scopegadgetoptionspage.cpp index 1d43fa288..8bf3d6802 100644 --- a/ground/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/src/plugins/scope/scopegadgetoptionspage.cpp @@ -70,11 +70,6 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) if(options_page->cmbUAVObjects->currentIndex() >= 0) on_cmbUAVObjects_currentIndexChanged(options_page->cmbUAVObjects->currentText()); - options_page->cmbColor->addItem("Black", QVariant(qRgb(0,0,0))); - options_page->cmbColor->addItem("Red", QVariant(qRgb(255,0,0))); - options_page->cmbColor->addItem("Green", QVariant(qRgb(0,255,0))); - options_page->cmbColor->addItem("Blue", QVariant(qRgb(0,0,255))); - options_page->cmbScale->addItem("E-9", -9); options_page->cmbScale->addItem("E-6", -6); options_page->cmbScale->addItem("E-5",-5); @@ -109,22 +104,34 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) addPlotCurveConfig(uavObject,uavField,scale,varColor); } + if(m_config->plotCurveConfigs().count() > 0) + options_page->lstCurves->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); connect(options_page->btnAddCurve, SIGNAL(clicked()), this, SLOT(on_btnAddCurve_clicked())); connect(options_page->btnRemoveCurve, SIGNAL(clicked()), this, SLOT(on_btnRemoveCurve_clicked())); connect(options_page->lstCurves, SIGNAL(currentRowChanged(int)), this, SLOT(on_lstCurves_currentRowChanged(int))); + connect(options_page->btnColor, SIGNAL(clicked()), this, SLOT(on_btnColor_clicked())); setYAxisWidgetFromPlotCurve(); return optionsPageWidget; } +void ScopeGadgetOptionsPage::on_btnColor_clicked() + { + QColor color = QColorDialog::getColor( QColor(options_page->btnColor->text()), options_page->widget); + if (color.isValid()) { + setButtonColor(color); + } + } + /*! \brief Populate the widgets that containts the configs for the Y-Axis from the selected plot curve */ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve() { + bool parseOK = false; QListWidgetItem* listItem = options_page->lstCurves->currentItem(); if(listItem == 0) @@ -139,8 +146,17 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve() currentIndex = options_page->cmbScale->findData( listItem->data(Qt::UserRole + 2), Qt::UserRole, Qt::MatchExactly); options_page->cmbScale->setCurrentIndex(currentIndex); - currentIndex = options_page->cmbColor->findData( listItem->data(Qt::UserRole + 3), Qt::UserRole, Qt::MatchExactly); - options_page->cmbColor->setCurrentIndex(currentIndex); + QVariant varColor = listItem->data(Qt::UserRole + 3); + int rgb = varColor.toInt(&parseOK); + + setButtonColor(QColor((QRgb)rgb)); +} + +void ScopeGadgetOptionsPage::setButtonColor(const QColor &color) +{ + options_page->btnColor->setText(color.name()); + options_page->btnColor->setPalette(QPalette(color)); + options_page->btnColor->setAutoFillBackground(true); } /*! @@ -168,7 +184,6 @@ void ScopeGadgetOptionsPage::on_cmbUAVObjects_currentIndexChanged(QString val) */ void ScopeGadgetOptionsPage::apply() { - bool parseOK = false; //Apply configuration changes @@ -216,7 +231,7 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked() //TODO: Find an existing plot curve config based on the uavobject and uav field. If it //exists, update it, else add a new one. - QVariant varColor = options_page->cmbColor->itemData(options_page->cmbColor->currentIndex()); + QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb(); addPlotCurveConfig(uavObject,uavField,scale,varColor); @@ -233,7 +248,8 @@ void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavFi QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1); //Set the properties of the newly added list item - QColor color = QColor( (QRgb)varColor.toInt(&parseOK) ); + QRgb rgbColor = (QRgb)varColor.toInt(&parseOK); + QColor color = QColor( rgbColor ); listWidgetItem->setText(listItemDisplayText); listWidgetItem->setTextColor( color ); diff --git a/ground/src/plugins/scope/scopegadgetoptionspage.h b/ground/src/plugins/scope/scopegadgetoptionspage.h index e4b735abc..b72b3659c 100644 --- a/ground/src/plugins/scope/scopegadgetoptionspage.h +++ b/ground/src/plugins/scope/scopegadgetoptionspage.h @@ -29,9 +29,11 @@ #define SCOPEGADGETOPTIONSPAGE_H #include "coreplugin/dialogs/ioptionspage.h" + #include #include #include +#include namespace Core { @@ -63,14 +65,15 @@ private: void addPlotCurveConfig(QString uavObject, QString uavField, int scale, QVariant varColor); void setYAxisWidgetFromPlotCurve(); - + void setButtonColor(const QColor &color); private slots: void on_lstCurves_currentRowChanged(int currentRow); void on_btnRemoveCurve_clicked(); void on_btnAddCurve_clicked(); - void on_cmbUAVObjects_currentIndexChanged(QString val); + void on_cmbUAVObjects_currentIndexChanged(QString val); + void on_btnColor_clicked(); }; -#endif // SCOPEGADGETOPTIONSPAGE_H \ No newline at end of file +#endif // SCOPEGADGETOPTIONSPAGE_H diff --git a/ground/src/plugins/scope/scopegadgetoptionspage.ui b/ground/src/plugins/scope/scopegadgetoptionspage.ui index 9e92957ca..bafee2de9 100644 --- a/ground/src/plugins/scope/scopegadgetoptionspage.ui +++ b/ground/src/plugins/scope/scopegadgetoptionspage.ui @@ -18,88 +18,17 @@ 0 0 - 531 - 361 + 591 + 261 - - - - 0 - 20 - 251 - 111 - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - - - - Plot Type: - - - - - - - seconds - - - 5000 - - - 30 - - - 300 - - - - - - - Data Size: - - - - - - - seconds - - - 1 - - - 30 - - - 5 - - - - - - - Data Timeout: - - - - - 0 - 160 - 481 - 102 + 0 + 551 + 231 @@ -108,44 +37,135 @@ + + QFormLayout::AllNonFixedFieldsGrow + + + + + Bitstream Charter + 75 + true + + + + X-Axis + + + + + + + Plot Type: + + + + + + + + + + Data Size: + + + + + + + seconds + + + 5000 + + + 30 + + + 300 + + + + + + + Data Timeout: + + + + + + + seconds + + + 1 + + + 30 + + + 5 + + + + + + + + Bitstream Charter + 75 + true + + + + Plot curves + + + + UAVObject: - + - - - - Color: - - - - - - - + UAVField: - + - + + + + Color: + + + + + + + Choose + + + + Scale: - + false @@ -159,6 +179,19 @@ QLayout::SetFixedSize + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -173,10 +206,39 @@ + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 50 + + + + + + + + Qt::Vertical + + + + 0 + 200 + + + + @@ -191,46 +253,6 @@ - - - - 0 - 140 - 81 - 17 - - - - - Bitstream Charter - 75 - true - - - - Plot curves - - - - - - 0 - 0 - 62 - 17 - - - - - Bitstream Charter - 75 - true - - - - X-Axis - - diff --git a/ground/src/plugins/scope/scopegadgetwidget.cpp b/ground/src/plugins/scope/scopegadgetwidget.cpp index c649b69a0..5f60aabf5 100644 --- a/ground/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/src/plugins/scope/scopegadgetwidget.cpp @@ -297,4 +297,4 @@ TestDataGen::~TestDataGen() timer->stop(); delete timer; -} \ No newline at end of file +}