From 23d29e1f3311351c659949f75ea90311f4221ffc Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 14 Aug 2019 23:59:42 +0200 Subject: [PATCH] Ref T709, UI for settings "lights" and "message box margins" --- .../simulatorxplaneconfigwindow.cpp | 33 +++ .../simulatorxplaneconfigwindow.h | 9 +- .../simulatorxplaneconfigwindow.ui | 232 +++++++++++++++--- 3 files changed, 240 insertions(+), 34 deletions(-) diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp index cac8a9a8b..4c5db0f43 100644 --- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp +++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp @@ -13,6 +13,7 @@ #include #include +#include using namespace BlackGui; using namespace BlackMisc; @@ -68,6 +69,17 @@ namespace BlackSimPlugin s.setFollowAircraftDistanceM(ui->sb_FollowAircraftDistanceM->value()); s.setDrawingLabels(ui->cb_DrawLabels->isChecked()); s.setNightTextureModeQt(ui->cb_NightTextureMode->currentText()); + s.setBundlingTaxiAndLandingLights(ui->cb_BundleTaxiLandingLights->isChecked()); + + // left, top, right, bottom, height + s.setMessageBoxValues( + marginToInt(ui->le_MsgBoxMarginsLeft->text(), 20), + marginToInt(ui->le_MsgBoxMarginsTop->text(), 20), + marginToInt(ui->le_MsgBoxMarginsRight->text(), 20), + marginToInt(ui->le_MsgBoxMarginsBottom->text(), 20), + ui->sb_MessageBoxLines->value(), + ui->sb_MessageBoxDuration->value() + ); return s; } @@ -78,6 +90,7 @@ namespace BlackSimPlugin ui->sb_FollowAircraftDistanceM->setValue(settings.getFollowAircraftDistanceM()); ui->cb_DrawLabels->setChecked(settings.isDrawingLabels()); ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM()); + ui->cb_BundleTaxiLandingLights->setChecked(settings.isBundlingTaxiAndLandingLights()); const QString s = settings.getNightTextureModeQt().left(1); if (!s.isEmpty()) @@ -91,11 +104,31 @@ namespace BlackSimPlugin } } } + + const std::vector values = settings.getMessageBoxValuesVector(); + if (values.size() >= 6) + { + // left, top, right, bottom, height + ui->le_MsgBoxMarginsLeft->setText(QString::number(values[0])); + ui->le_MsgBoxMarginsTop->setText(QString::number(values[1])); + ui->le_MsgBoxMarginsRight->setText(QString::number(values[2])); + ui->le_MsgBoxMarginsBottom->setText(QString::number(values[3])); + ui->sb_MessageBoxLines->setValue(values[4]); + ui->sb_MessageBoxDuration->setValue(values[5]); + } } void CSimulatorXPlaneConfigWindow::onSettingsChanged() { this->setUiValues(m_xSwiftBusServerSettings.get()); } + + int CSimulatorXPlaneConfigWindow::marginToInt(const QString &text, int defaultValue) + { + if (text.isEmpty()) { return defaultValue; } + bool ok; + const int v = text.toInt(&ok); + return ok ? v : defaultValue; + } } // ns } // ns diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h index 755703352..afcf6daca 100644 --- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h +++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h @@ -37,18 +37,21 @@ namespace BlackSimPlugin virtual ~CSimulatorXPlaneConfigWindow() override; private: - //! Settings have been accepted - void onSettingsAccepted(); - //! Settings from UI BlackMisc::Simulation::Settings::CXSwiftBusSettings getSettingsFromUI() const; //! Set settings void setUiValues(const BlackMisc::Simulation::Settings::CXSwiftBusSettings &settings); + //! Settings have been accepted + void onSettingsAccepted(); + //! Settings changed void onSettingsChanged(); + //! Margin value to int + static int marginToInt(const QString &text, int defaultValue); + QScopedPointer ui; BlackMisc::CSetting m_xSwiftBusServerSettings { this, &CSimulatorXPlaneConfigWindow::onSettingsChanged }; }; diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui index 5d35eab8f..55d6864b5 100644 --- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui +++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.ui @@ -7,13 +7,13 @@ 0 0 300 - 325 + 450 300 - 200 + 425 @@ -66,7 +66,7 @@ - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -82,28 +82,28 @@ Settings - + Max.aircraft - + 250 - + Max.distance - + NM @@ -113,28 +113,14 @@ - - - - Labels - - - - - - - draw labels - - - - + - Follow aircraft distance + Follow acft. distance - + m @@ -144,7 +130,177 @@ + + + + Labels + + + + + + + draw labels + + + + + + + Bundle lights + + + + + + + bundle taxi and landing lights + + + + + + + Message box + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + lines + + + 3 + + + 100 + + + + + + + ms + + + 1000 + + + 25000 + + + 250 + + + + + + + + + + Box margins px. + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + left + + + + + + + bottom + + + + + + + top + + + + + + + bottom + + + + + + + top + + + + + + + right + + + + + + + left + + + + + + + right + + + + + + + + + + Night texture + + + + @@ -163,16 +319,22 @@ - - - - Night texture - - - + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -188,6 +350,14 @@ ds_MaxDrawDistanceNM sb_FollowAircraftDistanceM cb_DrawLabels + cb_BundleTaxiLandingLights + sb_MessageBoxLines + sb_MessageBoxDuration + le_MsgBoxMarginsTop + le_MsgBoxMarginsBottom + le_MsgBoxMarginsLeft + le_MsgBoxMarginsRight + cb_NightTextureMode