diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 3dc587521..7adb28acf 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -176,6 +176,13 @@ private: */ bool isCockpitUpdatePending() const; + /*! + * \brief Round the com frequency display + * \param com1 + * \param com2 + */ + void roundComFrequencyDisplays(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2); + /*! * \brief Add new text message tab * \param tabName diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index 053aa5f81..4d35fbe31 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -388,7 +388,7 @@ QSizeGrip { QFrame::NoFrame - 6 + 3 @@ -894,7 +894,7 @@ QSizeGrip { 136.000000000000000 - 0.250000000000000 + 0.025000000000000 118.000000000000000 @@ -946,7 +946,7 @@ QSizeGrip { 136.000000000000000 - 0.250000000000000 + 0.025000000000000 119.000000000000000 @@ -980,7 +980,7 @@ QSizeGrip { 136.000000000000000 - 0.250000000000000 + 0.025000000000000 118.250000000000000 @@ -1011,7 +1011,7 @@ QSizeGrip { 136.000000000000000 - 0.250000000000000 + 0.025000000000000 119.250000000000000 diff --git a/samples/blackgui/mainwindow_cockpit.cpp b/samples/blackgui/mainwindow_cockpit.cpp index c82812a22..12d749339 100644 --- a/samples/blackgui/mainwindow_cockpit.cpp +++ b/samples/blackgui/mainwindow_cockpit.cpp @@ -54,6 +54,7 @@ void MainWindow::cockpitValuesChanged() } // this will call send cockpit updates with all changes made + // send cockpit updates this->m_timerCollectedCockpitUpdates->stop(); this->m_timerCollectedCockpitUpdates->start(1000); // start this->m_timerCollectedCockpitUpdates->setSingleShot(true); @@ -78,22 +79,7 @@ void MainWindow::updateCockpitFromContext() const CComSystem com2 = this->m_ownAircraft.getCom2System(); const CTransponder transponder = this->m_ownAircraft.getTransponder(); - double freq = com1.getFrequencyActive().valueRounded(3); - if (freq != this->ui->ds_CockpitCom1Active->value()) - this->ui->ds_CockpitCom1Active->setValue(freq); - - freq = com2.getFrequencyActive().valueRounded(3); - if (freq != this->ui->ds_CockpitCom2Active->value()) - this->ui->ds_CockpitCom2Active->setValue(freq); - - freq = com1.getFrequencyStandby().valueRounded(3); - if (freq != this->ui->ds_CockpitCom1Standby->value()) - this->ui->ds_CockpitCom1Standby->setValue(freq); - - freq = com2.getFrequencyStandby().valueRounded(3); - if (freq != this->ui->ds_CockpitCom2Standby->value()) - this->ui->ds_CockpitCom2Standby->setValue(freq); - + this->roundComFrequencyDisplays(com1, com2); qint32 tc = transponder.getTransponderCode(); if (tc != static_cast(this->ui->ds_CockpitTransponder->value())) this->ui->ds_CockpitTransponder->setValue(tc); @@ -146,6 +132,30 @@ void MainWindow::updateCockpitFromContext() } } +/* + * Round the com frequency displays + */ +void MainWindow::roundComFrequencyDisplays(const CComSystem &com1, const CComSystem &com2) +{ + // do not just set! Leads to unwanted signals fired + double freq = com1.getFrequencyActive().valueRounded(3); + if (freq != this->ui->ds_CockpitCom1Active->value()) + this->ui->ds_CockpitCom1Active->setValue(freq); + + freq = com2.getFrequencyActive().valueRounded(3); + if (freq != this->ui->ds_CockpitCom2Active->value()) + this->ui->ds_CockpitCom2Active->setValue(freq); + + freq = com1.getFrequencyStandby().valueRounded(3); + if (freq != this->ui->ds_CockpitCom1Standby->value()) + + this->ui->ds_CockpitCom1Standby->setValue(freq); + + freq = com2.getFrequencyStandby().valueRounded(3); + if (freq != this->ui->ds_CockpitCom2Standby->value()) + this->ui->ds_CockpitCom2Standby->setValue(freq); +} + /* * Reset transponder mode to Standby / Charly */ @@ -210,6 +220,7 @@ void MainWindow::sendCockpitUpdates() com1.setFrequencyStandbyMHz(this->ui->ds_CockpitCom1Standby->value()); com2.setFrequencyActiveMHz(this->ui->ds_CockpitCom2Active->value()); com2.setFrequencyStandbyMHz(this->ui->ds_CockpitCom2Standby->value()); + this->roundComFrequencyDisplays(com1, com2); // // Send to context