diff --git a/src/swiftguistandard/swiftguistd.cpp b/src/swiftguistandard/swiftguistd.cpp index 97c0bc5db..4183c8665 100644 --- a/src/swiftguistandard/swiftguistd.cpp +++ b/src/swiftguistandard/swiftguistd.cpp @@ -489,6 +489,7 @@ void SwiftGuiStd::displayLog() void SwiftGuiStd::onPttChanged(bool enabled) { if (!enabled) { return; } + if (!sGui) { return; } sGui->getIContextAudio()->playNotification(CNotificationSounds::PTTClick, true); } @@ -522,3 +523,21 @@ void SwiftGuiStd::displayDBusReconnectDialog() msg.clampSeverity(CStatusMessage::SeverityWarning); CLogMessage::preformatted(msg); } + +void SwiftGuiStd::onShowOverlayVariant(const CVariant &variant, int durationMs) +{ + if (!sGui || sGui->isShuttingDown()) { return; } + ui->fr_CentralFrameInside->showOverlayVariant(variant, durationMs); +} + +void SwiftGuiStd::onShowOverlayInlineTextMessageTab(Components::TextMessageTab tab) +{ + if (!sGui || sGui->isShuttingDown()) { return; } + ui->fr_CentralFrameInside->showOverlayInlineTextMessage(tab); +} + +void SwiftGuiStd::onShowOverlayInlineTextMessageCallsign(const CCallsign &callsign) +{ + if (!sGui || sGui->isShuttingDown()) { return; } + ui->fr_CentralFrameInside->showOverlayInlineTextMessage(callsign); +} diff --git a/src/swiftguistandard/swiftguistd.h b/src/swiftguistandard/swiftguistd.h index 5daf5b27a..e9420f4eb 100644 --- a/src/swiftguistandard/swiftguistd.h +++ b/src/swiftguistandard/swiftguistd.h @@ -19,6 +19,7 @@ #include "blackgui/components/maininfoareacomponent.h" #include "blackgui/components/navigatordialog.h" #include "blackgui/components/aircraftmodelsetvalidationdialog.h" +#include "blackgui/components/textmessagecomponenttab.h" #include "blackgui/enableforframelesswindow.h" #include "blackgui/mainwindowaccess.h" #include "blackgui/managedstatusbar.h" @@ -27,10 +28,11 @@ #include "blackcore/network.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/audio/notificationsounds.h" -#include "blackmisc/icons.h" #include "blackmisc/identifiable.h" +#include "blackmisc/variant.h" #include "blackmisc/loghandler.h" #include "blackmisc/statusmessage.h" +#include "blackmisc/icons.h" #include #include @@ -42,7 +44,6 @@ class QCloseEvent; class QEvent; class QMouseEvent; class QTimer; -class QWidget; namespace BlackMisc { namespace Aviation { class CAltitude; } } namespace BlackGui { namespace Components { class CDbLoadDataDialog; }} @@ -280,6 +281,12 @@ private: //! Copy the XSwiftBus files from build directory void copyXSwiftBusDialog(bool checkFileTimestamp); + + //! Request overlay inline text message @{ + void onShowOverlayVariant(const BlackMisc::CVariant &variant, int durationMs); + void onShowOverlayInlineTextMessageTab(BlackGui::Components::TextMessageTab tab); + void onShowOverlayInlineTextMessageCallsign(const BlackMisc::Aviation::CCallsign &callsign); + //! @} }; #pragma pop_macro("interface") diff --git a/src/swiftguistandard/swiftguistdinit.cpp b/src/swiftguistandard/swiftguistdinit.cpp index 4529640d2..be315768d 100644 --- a/src/swiftguistandard/swiftguistdinit.cpp +++ b/src/swiftguistandard/swiftguistdinit.cpp @@ -48,13 +48,13 @@ #include #include #include - -class QHBoxLayout; +#include using namespace BlackConfig; using namespace BlackCore; using namespace BlackCore::Context; using namespace BlackMisc; +using namespace BlackMisc::Aviation; using namespace BlackMisc::Network; using namespace BlackMisc::Input; using namespace BlackGui; @@ -217,19 +217,14 @@ void SwiftGuiStd::initGuiSignals() connect(ui->menu_TestLocationsEDRY, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); connect(ui->menu_TestLocationsLOWW, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); - connect(ui->menu_WindowFont, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); - connect(ui->menu_WindowMinimize, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); + connect(ui->menu_WindowFont, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); + connect(ui->menu_WindowMinimize, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); connect(ui->menu_WindowToggleOnTop, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); connect(ui->menu_WindowToggleNavigator, &QAction::triggered, m_navigator.data(), &CNavigatorDialog::toggleNavigatorVisibility); connect(ui->menu_InternalsPage, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); - connect(ui->menu_MovingMap, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); + connect(ui->menu_MovingMap, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked); connect(m_navigator.data(), &CNavigatorDialog::navigatorClosed, this, &SwiftGuiStd::onNavigatorClosed); - // command line / text messages - // here we display SUP messages and such in a central window - ui->fr_CentralFrameInside->activateTextMessages(true); - connect(ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, ui->fr_CentralFrameInside, &COverlayMessagesFrame::showOverlayVariant); - // settings (GUI component), styles connect(ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedWindowsOpacity, this, &SwiftGuiStd::onChangedWindowOpacity); connect(sGui, &CGuiApplication::styleSheetsChanged, this, &SwiftGuiStd::onStyleSheetsChanged, Qt::QueuedConnection); @@ -253,13 +248,22 @@ void SwiftGuiStd::initGuiSignals() connect(this, &SwiftGuiStd::currentMainInfoAreaChanged, ui->comp_Login, &CLoginComponent::mainInfoAreaChanged); // text messages - connect(ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab); - connect(ui->comp_MainInfoArea->getMappingComponent(), &CMappingComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab); - connect(ui->comp_MainInfoArea->getAircraftComponent(), &CAircraftComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab); - connect(ui->comp_MainInfoArea->getUserComponent(), &CUserComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab); + connect(ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab, Qt::QueuedConnection); + connect(ui->comp_MainInfoArea->getMappingComponent(), &CMappingComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab, Qt::QueuedConnection); + connect(ui->comp_MainInfoArea->getAircraftComponent(), &CAircraftComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab, Qt::QueuedConnection); + connect(ui->comp_MainInfoArea->getUserComponent(), &CUserComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab, Qt::QueuedConnection); + + // command line / text messages + // here we display SUP messages and such in a central window + ui->fr_CentralFrameInside->activateTextMessages(true); + connect(ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this, &SwiftGuiStd::onShowOverlayVariant, Qt::QueuedConnection); + connect(ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestTextMessageEntryTab, this, &SwiftGuiStd::onShowOverlayInlineTextMessageTab, Qt::QueuedConnection); + connect(ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestTextMessageEntryCallsign, this, &SwiftGuiStd::onShowOverlayInlineTextMessageCallsign, Qt::QueuedConnection); + connect(ui->comp_MainInfoArea->getCockpitComponent(), &CCockpitComponent::requestTextMessageEntryTab, this, &SwiftGuiStd::onShowOverlayInlineTextMessageTab, Qt::QueuedConnection); + connect(ui->comp_MainInfoArea->getCockpitComponent(), &CCockpitComponent::requestTextMessageEntryCallsign, this, &SwiftGuiStd::onShowOverlayInlineTextMessageCallsign, Qt::QueuedConnection); // interpolation and validation - connect(ui->comp_MainInfoArea->getMappingComponent(), &CMappingComponent::requestValidationDialog, this, &SwiftGuiStd::displayValidationDialog); + connect(ui->comp_MainInfoArea->getMappingComponent(), &CMappingComponent::requestValidationDialog, this, &SwiftGuiStd::displayValidationDialog); connect(ui->comp_MainInfoArea->getInterpolationComponent(), &CInterpolationComponent::requestRenderingRestrictionsWidget, [ = ] { this->setSettingsPage(CSettingsComponent::SettingTabSimulator);