diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index e8207efe2..c9c3345db 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -58,7 +58,7 @@ namespace BlackGui namespace Components { CAtcStationComponent::CAtcStationComponent(QWidget *parent) : - QFrame(parent), + COverlayMessagesFrame(parent), CIdentifiable(this), ui(new Ui::CAtcStationComponent) { @@ -70,7 +70,7 @@ namespace BlackGui CUpperCaseValidator *ucv = new CUpperCaseValidator(ui->le_AtcStationsOnlineMetar); ui->le_AtcStationsOnlineMetar->setValidator(ucv); - this->deferredActivate(this); + this->activateTextMessages(true); // some icons ui->tb_AtcStationsAtisReload->setIcon(CIcons::atis()); @@ -469,7 +469,7 @@ namespace BlackGui void CAtcStationComponent::showOverlayInlineTextMessage() { - CEnableForDockWidgetInfoArea::showOverlayInlineTextMessage(TextMessagesCom1); + COverlayMessagesFrame::showOverlayInlineTextMessage(TextMessagesCom1); } void CAtcStationComponent::onDetailsToggled(bool checked) diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index cf7cfd300..9e2756b27 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -15,6 +15,7 @@ #include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/settings/viewupdatesettings.h" #include "blackgui/settings/atcstationssettings.h" +#include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include "blackcore/network.h" #include "blackmisc/aviation/atcstation.h" @@ -44,7 +45,7 @@ namespace BlackGui { //! ATC stations component class BLACKGUI_EXPORT CAtcStationComponent : - public QFrame, + public COverlayMessagesFrame, public CEnableForDockWidgetInfoArea, public BlackMisc::CIdentifiable { diff --git a/src/blackgui/components/cockpitcomponent.cpp b/src/blackgui/components/cockpitcomponent.cpp index ac770f37f..b27700bb4 100644 --- a/src/blackgui/components/cockpitcomponent.cpp +++ b/src/blackgui/components/cockpitcomponent.cpp @@ -22,13 +22,13 @@ namespace BlackGui namespace Components { CCockpitComponent::CCockpitComponent(QWidget *parent) : - QFrame(parent), + COverlayMessagesFrame(parent), CEnableForDockWidgetInfoArea(), ui(new Ui::CCockpitComponent) { ui->setupUi(this); m_minHeightInfoArea = ui->comp_CockpitInfoArea->minimumHeight(); - this->deferredActivate(this); + this->activateTextMessages(true); connect(ui->wip_CockpitComPanelShowHideBar, &CShowHideBar::toggleShowHide, this, &CCockpitComponent::onToggleShowHideDetails); connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom1TextMessage, this, &CCockpitComponent::onRequestTextMessageCom1); @@ -123,7 +123,7 @@ namespace BlackGui void CCockpitComponent::mouseDoubleClickEvent(QMouseEvent *event) { if (event) { this->showOverlayInlineTextMessage(TextMessagesAll); } - QWidget::mouseDoubleClickEvent(event); + COverlayMessagesFrame::mouseDoubleClickEvent(event); } void CCockpitComponent::onRequestTextMessageCom1() diff --git a/src/blackgui/components/cockpitcomponent.h b/src/blackgui/components/cockpitcomponent.h index 283fa9f5e..5826f06f3 100644 --- a/src/blackgui/components/cockpitcomponent.h +++ b/src/blackgui/components/cockpitcomponent.h @@ -13,6 +13,7 @@ #define BLACKGUI_COMPONENTS_COCKPITCOMPONENT_H #include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include @@ -29,7 +30,7 @@ namespace BlackGui { //! Cockpit component: COM unit, show / hide bar, voice rooms class BLACKGUI_EXPORT CCockpitComponent : - public QFrame, + public COverlayMessagesFrame, public CEnableForDockWidgetInfoArea { Q_OBJECT diff --git a/src/blackgui/components/enablefordockwidgetinfoarea.cpp b/src/blackgui/components/enablefordockwidgetinfoarea.cpp index aae267d2c..42f3ecc09 100644 --- a/src/blackgui/components/enablefordockwidgetinfoarea.cpp +++ b/src/blackgui/components/enablefordockwidgetinfoarea.cpp @@ -34,36 +34,6 @@ namespace BlackGui m_parentDockableInfoArea = parentInfoArea; } - void CEnableForDockWidgetInfoArea::deferredActivate(QObject *relatedObject, int delayMs) - { - if (!relatedObject) { return; } - QPointer myself(relatedObject); - QTimer::singleShot(delayMs, relatedObject, [ = ] - { - if (myself) { this->activateTextMessages(true); } - }); - } - - void CEnableForDockWidgetInfoArea::initOverlayMessages(QSize inner) - { - if (m_parentDockableInfoArea) { m_parentDockableInfoArea->initOverlayMessages(inner); } - } - - void CEnableForDockWidgetInfoArea::activateTextMessages(bool activate) - { - if (m_parentDockableInfoArea) { m_parentDockableInfoArea->activateTextMessages(activate); } - } - - void CEnableForDockWidgetInfoArea::showOverlayInlineTextMessage(TextMessageTab tab) - { - if (m_parentDockableInfoArea) { m_parentDockableInfoArea->showOverlayInlineTextMessage(tab); } - } - - void CEnableForDockWidgetInfoArea::showOverlayInlineTextMessage(const CCallsign &callsign) - { - if (m_parentDockableInfoArea) { m_parentDockableInfoArea->showOverlayInlineTextMessage(callsign); } - } - bool CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) { // sanity check diff --git a/src/blackgui/components/enablefordockwidgetinfoarea.h b/src/blackgui/components/enablefordockwidgetinfoarea.h index 8d991a3f2..a7ac5a3fe 100644 --- a/src/blackgui/components/enablefordockwidgetinfoarea.h +++ b/src/blackgui/components/enablefordockwidgetinfoarea.h @@ -68,21 +68,6 @@ namespace BlackGui //! Destructor virtual ~CEnableForDockWidgetInfoArea() {} - //! Deferred activation, as dockwidget is not directly initalized - void deferredActivate(QObject *relatedObject, int delayMs = 2500); - - //! \copydoc BlackGui::COverlayMessages::initOverlayMessages - void initOverlayMessages(QSize inner = {}); - - //! \copydoc BlackGui::COverlayMessages::showKillButton - void activateTextMessages(bool activate); - - //! \copydoc BlackGui::COverlayMessages::showOverlayImage - void showOverlayInlineTextMessage(Components::TextMessageTab tab); - - //! \copydoc BlackGui::COverlayMessages::showOverlayImage - void showOverlayInlineTextMessage(const BlackMisc::Aviation::CCallsign &callsign); - private: CDockWidgetInfoArea *m_parentDockableInfoArea = nullptr; //!< my parent dockable widget BlackMisc::CConnectionGuard m_connections;