From d68726080f54a8c2dd113191cdfed5906bb1e964 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 14 Feb 2019 19:27:53 +0100 Subject: [PATCH] Ref T536, Ref T531 improved message handling * do not activate COM/ATC overlay messages as central frame overlay is used * ignore signals if not activated --- .../components/atcstationcomponent.cpp | 2 -- src/blackgui/components/cockpitcomponent.cpp | 1 - .../components/textmessagecomponent.cpp | 23 +++++++++++++--- .../components/textmessagecomponent.h | 26 ++++++++++--------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index a6ddba23a..f2991a1f0 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -70,8 +70,6 @@ namespace BlackGui CUpperCaseValidator *ucv = new CUpperCaseValidator(ui->le_AtcStationsOnlineMetar); ui->le_AtcStationsOnlineMetar->setValidator(ucv); - this->activateTextMessages(true); - // some icons ui->tb_AtcStationsAtisReload->setIcon(CIcons::atis()); ui->tb_AtcStationsAtisReload->setText("ATIS"); diff --git a/src/blackgui/components/cockpitcomponent.cpp b/src/blackgui/components/cockpitcomponent.cpp index 63ea20275..6c0fbf8c9 100644 --- a/src/blackgui/components/cockpitcomponent.cpp +++ b/src/blackgui/components/cockpitcomponent.cpp @@ -27,7 +27,6 @@ namespace BlackGui { ui->setupUi(this); m_minHeightInfoArea = ui->comp_CockpitInfoArea->minimumHeight(); - this->activateTextMessages(true); connect(ui->wip_CockpitComPanelShowHideBar, &CShowHideBar::toggleShowHide, this, &CCockpitComponent::onToggleShowHideDetails); connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom1TextMessage, this, &CCockpitComponent::onRequestTextMessageCom1); diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index bab61d14b..30f8be568 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -94,7 +94,7 @@ namespace BlackGui Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); c = connect(sGui->getIContextNetwork(), &IContextNetwork::textMessageSent, this, &CTextMessageComponent::onTextMessageSent, Qt::QueuedConnection); Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); - c = connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CTextMessageComponent::onChangedAircraftCockpit); + c = connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CTextMessageComponent::onChangedAircraftCockpit, Qt::QueuedConnection); Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); } Q_UNUSED(c); @@ -106,7 +106,7 @@ namespace BlackGui // init decoupled when sub components are fully init if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->onSettingsChanged(); - this->onChangedAircraftCockpit(); + this->showCurrentFrequenciesFromCockpit(); // hde for the beginning ui->gb_Settings->setChecked(false); @@ -257,9 +257,12 @@ namespace BlackGui } // for } - void CTextMessageComponent::onChangedAircraftCockpit() + void CTextMessageComponent::onChangedAircraftCockpit(const CSimulatedAircraft &aircraft, const CIdentifier &originator) { - this->showCurrentFrequenciesFromCockpit(); + // this is called for every overlay widget as well + Q_UNUSED(originator); + if (!this->isActivated()) { return; } + this->showCurrentFrequenciesFromCockpit(aircraft); } void CTextMessageComponent::onSettingsChecked(bool checked) @@ -361,6 +364,11 @@ namespace BlackGui void CTextMessageComponent::showCurrentFrequenciesFromCockpit() { const CSimulatedAircraft ownAircraft = this->getOwnAircraft(); + this->showCurrentFrequenciesFromCockpit(ownAircraft); + } + + void CTextMessageComponent::showCurrentFrequenciesFromCockpit(const CSimulatedAircraft &ownAircraft) + { const CFrequency freq1 = ownAircraft.getCom1System().getFrequencyActive(); const CFrequency freq2 = ownAircraft.getCom2System().getFrequencyActive(); @@ -760,5 +768,12 @@ namespace BlackGui { ui->tw_TextMessages->removeTab(0); } + + void CTextMessageComponent::activate(bool send, bool receive) + { + m_activeSend = send; + m_activeReceive = receive; + } + } // namespace } // namespace diff --git a/src/blackgui/components/textmessagecomponent.h b/src/blackgui/components/textmessagecomponent.h index 180e017d7..0cb2e4db8 100644 --- a/src/blackgui/components/textmessagecomponent.h +++ b/src/blackgui/components/textmessagecomponent.h @@ -16,9 +16,9 @@ #include "blackgui/settings/textmessagesettings.h" #include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" -#include "blackmisc/audio/audiosettings.h" -#include "blackmisc/aviation/atcstation.h" #include "blackmisc/simulation/simulatedaircraft.h" +#include "blackmisc/aviation/atcstation.h" +#include "blackmisc/audio/audiosettings.h" #include "blackmisc/identifier.h" #include "blackmisc/variant.h" @@ -56,17 +56,17 @@ namespace BlackGui //! \remark takes the messages, turns it into a ".msg" command, and emits it bool handleGlobalCommandLineText(const QString &commandLine, const BlackMisc::CIdentifier &originator); + //! Font size @{ + void fontSizeMinus(); + void fontSizePlus(); + //! @} + //! Display the tab for given callsign void showCorrespondingTab(const BlackMisc::Aviation::CCallsign &callsign); //! Display the tab for given frequency void showCorrespondingTabForFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency); - //! Font size @{ - void fontSizeMinus(); - void fontSizePlus(); - //! @} - //! Set tab void setTab(TextMessageTab tab); @@ -91,10 +91,10 @@ namespace BlackGui void setAsUsedInOverlayMode() { m_usedAsOverlayWidget = true; } //! Ignore incoming send/receive signals - void activate(bool send, bool receive) { m_activeSend = send; m_activeReceive = receive; } + void activate(bool send, bool receive); //! Text activated - bool isActivated() const { return m_activeSend && m_activeReceive; } + bool isActivated() const { return m_activeSend || m_activeReceive; } //! Rows/columns void setAtcButtonsRowsColumns(int rows, int cols, bool setMaxElements); @@ -119,7 +119,7 @@ namespace BlackGui BlackMisc::CSetting m_messageSettings { this, &CTextMessageComponent::onSettingsChanged }; BlackMisc::CSetting m_audioSettings { this }; bool m_usedAsOverlayWidget = false; //!< disables dockwidget parts if used as overlay widget - bool m_activeSend = true; //!< ignore sent callback + bool m_activeSend = true; //!< ignore sent messages bool m_activeReceive = true; //!< ignore received messages //! Enum to widget @@ -158,8 +158,10 @@ namespace BlackGui //! Network connected? bool isNetworkConnected() const; - //! Show current frequencies + //! Show current frequencies @{ void showCurrentFrequenciesFromCockpit(); + void showCurrentFrequenciesFromCockpit(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft); + //! @} //! Append text messages (received, to be sent) to GUI void displayTextMessage(const BlackMisc::Network::CTextMessageList &messages); @@ -180,7 +182,7 @@ namespace BlackGui void onTextMessageSent(const BlackMisc::Network::CTextMessage &sentMessage); //! Cockpit values changed, used to updated some components - void onChangedAircraftCockpit(); + void onChangedAircraftCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator); //! Settings have been checked (group box visible/invisible) void onSettingsChecked(bool checked);