diff --git a/src/blackcore/context_network.h b/src/blackcore/context_network.h index cac6d709d..c31868d15 100644 --- a/src/blackcore/context_network.h +++ b/src/blackcore/context_network.h @@ -148,6 +148,9 @@ namespace BlackCore //! Aircraft for given callsign virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const = 0; + //! Online station for callsign + virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const = 0; + //! Get all users virtual BlackMisc::Network::CUserList getUsers() const = 0; diff --git a/src/blackcore/context_network_empty.h b/src/blackcore/context_network_empty.h index 3b75654eb..6f8c9d43c 100644 --- a/src/blackcore/context_network_empty.h +++ b/src/blackcore/context_network_empty.h @@ -65,6 +65,14 @@ namespace BlackCore return BlackMisc::Simulation::CSimulatedAircraft(); } + //! \copydoc IContextNetwork::getOnlineStationForCallsign + virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override + { + Q_UNUSED(callsign); + logEmptyContextWarning(Q_FUNC_INFO); + return BlackMisc::Aviation::CAtcStation(); + } + //! \copydoc IContextNetwork::connectToNetwork virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint mode) override { diff --git a/src/blackcore/context_network_impl.cpp b/src/blackcore/context_network_impl.cpp index abb8134a2..43a741fb9 100644 --- a/src/blackcore/context_network_impl.cpp +++ b/src/blackcore/context_network_impl.cpp @@ -483,6 +483,12 @@ namespace BlackCore return this->m_airspace->remoteAircraft().findFirstByCallsign(callsign); } + CAtcStation CContextNetwork::getOnlineStationForCallsign(const CCallsign &callsign) const + { + if (this->isDebugEnabled()) { BlackMisc::CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } + return this->m_airspace->getAtcStationsOnline().findFirstByCallsign(callsign); + } + void CContextNetwork::ps_receivedBookings(const CAtcStationList &) { if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } diff --git a/src/blackcore/context_network_impl.h b/src/blackcore/context_network_impl.h index 726354fae..1faf04cfa 100644 --- a/src/blackcore/context_network_impl.h +++ b/src/blackcore/context_network_impl.h @@ -105,6 +105,9 @@ namespace BlackCore //! \copydoc IContextNetwork::getAircraftForCallsign virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; + //! \copydoc IContextNetwork::getOnlineStationForCallsign + virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; + //! \copydoc IContextNetwork::connectToNetwork() virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint mode) override; diff --git a/src/blackcore/context_network_proxy.cpp b/src/blackcore/context_network_proxy.cpp index 8edc70a2a..597db1b0d 100644 --- a/src/blackcore/context_network_proxy.cpp +++ b/src/blackcore/context_network_proxy.cpp @@ -114,6 +114,11 @@ namespace BlackCore return this->m_dBusInterface->callDBusRet(QLatin1Literal("getAircraftForCallsign"), callsign); } + CAtcStation CContextNetworkProxy::getOnlineStationForCallsign(const CCallsign &callsign) const + { + return this->m_dBusInterface->callDBusRet(QLatin1Literal("getOnlineStationForCallsign"), callsign); + } + BlackMisc::Network::CUserList CContextNetworkProxy::getUsers() const { return this->m_dBusInterface->callDBusRet(QLatin1Literal("getUsers")); diff --git a/src/blackcore/context_network_proxy.h b/src/blackcore/context_network_proxy.h index ab83a90ff..b5ec69c68 100644 --- a/src/blackcore/context_network_proxy.h +++ b/src/blackcore/context_network_proxy.h @@ -68,6 +68,9 @@ namespace BlackCore //! \copydoc IContextNetwork::getAircraftForCallsign virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; + //! \copydoc IContextNetwork::getOnlineStationForCallsign + virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; + //! \copydoc IContextNetwork::connectToNetwork virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint mode) override; diff --git a/src/blackgui/components/aircraftcomponent.cpp b/src/blackgui/components/aircraftcomponent.cpp index de9a485c6..742e65509 100644 --- a/src/blackgui/components/aircraftcomponent.cpp +++ b/src/blackgui/components/aircraftcomponent.cpp @@ -32,7 +32,7 @@ namespace BlackGui ui->setupUi(this); this->tabBar()->setExpanding(false); this->ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce); - m_updateTimer = new CUpdateTimer(SLOT(update()), this); + m_updateTimer = new CUpdateTimer(&CAircraftComponent::update, this); connect(this->ui->tvp_AircraftInRange, &CAircraftView::rowCountChanged, this, &CAircraftComponent::ps_onRowCountChanged); connect(this->ui->tvp_AirportsInRange, &CAircraftView::rowCountChanged, this, &CAircraftComponent::ps_onRowCountChanged); diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index b75a838af..24ab681e7 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -33,7 +33,7 @@ namespace BlackGui { ui->setupUi(this); this->tabBar()->setExpanding(false); - this->m_updateTimer = new CUpdateTimer(SLOT(update()), this); + this->m_updateTimer = new CUpdateTimer(&CAtcStationComponent::update, this); // some icons this->ui->pb_AtcStationsAtisReload->setIcon(CIcons::atis()); @@ -275,6 +275,14 @@ namespace BlackGui } } + const QString &CAtcStationComponent::originator() + { + // string is generated once, the timestamp allows to use multiple + // components (as long as they are not generated at the same ms) + static const QString o = QString("ATCSTATIOCOMPONENT:").append(QString::number(QDateTime::currentMSecsSinceEpoch())); + return o; + } + void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index) { this->ui->te_AtcStationsOnlineInfo->setText(""); // reset diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 9c081b67b..d7cdaca7d 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -118,6 +118,7 @@ namespace BlackGui private: void updateTreeView(); + const QString &originator(); QScopedPointer ui; CUpdateTimer *m_updateTimer = nullptr; @@ -126,14 +127,6 @@ namespace BlackGui QDateTime m_timestampLastReadBookedStations = CUpdateTimer::epoch(); //!< stations read QDateTime m_timestampBookedStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed - const QString &originator() - { - // string is generated once, the timestamp allows to use multiple - // components (as long as they are not generated at the same ms) - static const QString o = QString("ATCSTATIOCOMPONENT:").append(QString::number(QDateTime::currentMSecsSinceEpoch())); - return o; - } - }; } // namespace } // namespace diff --git a/src/blackgui/components/enablefordockwidgetinfoarea.cpp b/src/blackgui/components/enablefordockwidgetinfoarea.cpp index 8cb0ce70e..3e9e54c45 100644 --- a/src/blackgui/components/enablefordockwidgetinfoarea.cpp +++ b/src/blackgui/components/enablefordockwidgetinfoarea.cpp @@ -79,5 +79,17 @@ namespace BlackGui return mw ? mw->getWidget() : nullptr; } + void CEnableForDockWidgetInfoArea::displayMyself() + { + // if we are already visible, we are done + if (this->isVisibleWidget()) { return; } + + // select myself + if (getParentInfoArea()) + { + getParentInfoArea()->selectArea(this->getDockWidgetInfoArea()); + } + } + } // namespace } // namespace diff --git a/src/blackgui/components/enablefordockwidgetinfoarea.h b/src/blackgui/components/enablefordockwidgetinfoarea.h index d957b1029..80de906d2 100644 --- a/src/blackgui/components/enablefordockwidgetinfoarea.h +++ b/src/blackgui/components/enablefordockwidgetinfoarea.h @@ -55,6 +55,9 @@ namespace BlackGui //! Main application window widget if any QWidget *mainApplicationWindowWidget() const; + //! Display myself + void displayMyself(); + protected: //! Constructor //! \remarks Normally the infoa area will be provided later \sa setParentDockWidgetInfoArea diff --git a/src/blackgui/components/maininfoareacomponent.cpp b/src/blackgui/components/maininfoareacomponent.cpp index aefccc654..c3defec26 100644 --- a/src/blackgui/components/maininfoareacomponent.cpp +++ b/src/blackgui/components/maininfoareacomponent.cpp @@ -45,6 +45,11 @@ namespace BlackGui return this->ui->comp_Aircraft; } + CMappingComponent *CMainInfoAreaComponent::getMappingComponet() + { + return this->ui->comp_Mappings; + } + CUserComponent *CMainInfoAreaComponent::getUserComponent() { return this->ui->comp_Users; diff --git a/src/blackgui/components/maininfoareacomponent.h b/src/blackgui/components/maininfoareacomponent.h index 9954098e0..b5d511694 100644 --- a/src/blackgui/components/maininfoareacomponent.h +++ b/src/blackgui/components/maininfoareacomponent.h @@ -62,6 +62,9 @@ namespace BlackGui //! Aircrafts CAircraftComponent *getAircraftComponent(); + //! Mappings + CMappingComponent *getMappingComponet(); + //! User component CUserComponent *getUserComponent(); diff --git a/src/blackgui/components/simulatorcomponent.cpp b/src/blackgui/components/simulatorcomponent.cpp index 2a7158cb0..b7ed1d3f0 100644 --- a/src/blackgui/components/simulatorcomponent.cpp +++ b/src/blackgui/components/simulatorcomponent.cpp @@ -32,7 +32,7 @@ namespace BlackGui this->ui->tvp_LiveData->setIconMode(true); this->ui->tvp_LiveData->setAutoResizeFrequency(10); // only resize every n-th time this->addOrUpdateByName("info", "no data yet", CIcons::StandardIconWarning16); - m_updateTimer = new CUpdateTimer(SLOT(update()), this); + m_updateTimer = new CUpdateTimer(&CSimulatorComponent::update, this); } CSimulatorComponent::~CSimulatorComponent() diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index 94bd2fd33..d7edd83ae 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -14,6 +14,7 @@ #include "blackmisc/notificationsounds.h" #include "blackmisc/logmessage.h" #include "blackmisc/simplecommandparser.h" +#include "blackmisc/simulation/simulatedaircraftlist.h" #include #include @@ -26,6 +27,7 @@ using namespace BlackMisc::Network; using namespace BlackMisc::Aviation; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Settings; +using namespace BlackMisc::Simulation; namespace BlackGui { @@ -48,7 +50,7 @@ namespace BlackGui CTextMessageComponent::~CTextMessageComponent() { } - QWidget *CTextMessageComponent::getTabWidget(CTextMessageComponent::Tab tab) + QWidget *CTextMessageComponent::getTabWidget(CTextMessageComponent::Tab tab) const { switch (tab) { @@ -67,9 +69,15 @@ namespace BlackGui return nullptr; } - /* - * Text messages received or send, append to GUI - */ + void CTextMessageComponent::selectTabWidget(CTextMessageComponent::Tab tab) + { + QWidget *w = getTabWidget(tab); + if (w) + { + this->ui->tw_TextMessages->setCurrentWidget(w); + } + } + void CTextMessageComponent::displayTextMessage(const CTextMessageList &messages) { if (messages.isEmpty()) return; @@ -178,7 +186,7 @@ namespace BlackGui CCallsign cs = textMessage.getSenderCallsign(); if (cs.isEmpty()) return false; QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet()); - if (!tab) return false; + if (!tab) { return false; } return this->ui->tw_TextMessages->currentWidget() == tab; } else @@ -198,6 +206,11 @@ namespace BlackGui } } + bool CTextMessageComponent::isNetworkConnected() const + { + return this->getIContextNetwork() && this->getIContextNetwork()->isConnected() ; + } + void CTextMessageComponent::showCurrentFrequenciesFromCockpit() { const CAircraft ownAircraft = this->getOwnAircraft(); @@ -212,6 +225,12 @@ namespace BlackGui this->ui->tw_TextMessages->setTabText(this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM2), f2); } + QWidget *CTextMessageComponent::addNewTextMessageTab(const CCallsign &callsign) + { + Q_ASSERT(!callsign.isEmpty()); + return addNewTextMessageTab(callsign.asString()); + } + QWidget *CTextMessageComponent::addNewTextMessageTab(const QString &tabName) { QWidget *newTab = new QWidget(this); @@ -242,10 +261,8 @@ namespace BlackGui if (!textMessage.isPrivateMessage()) { return; } CCallsign cs = textMessage.getRecipientCallsign(); if (cs.isEmpty()) { return; } - QString csStr(cs.asString()); - QWidget *tab = this->findTextMessageTabByName(csStr); - if (tab == nullptr) { tab = this->findTextMessageTabByName(csStr); } - if (tab == nullptr) { tab = this->addNewTextMessageTab(csStr); } + QWidget *tab = this->findTextMessageTabByCallsign(cs); + if (tab == nullptr) { tab = this->addNewTextMessageTab(cs); } Q_ASSERT(tab != nullptr); CTextMessageTextEdit *textEdit = tab->findChild(); Q_ASSERT(textEdit != nullptr); @@ -259,6 +276,34 @@ namespace BlackGui } } + const CAircraft CTextMessageComponent::getOwnAircraft() const + { + Q_ASSERT(this->getIContextOwnAircraft()); + return this->getIContextOwnAircraft()->getOwnAircraft(); + } + + QWidget *CTextMessageComponent::findTextMessageTabByCallsign(const CCallsign &callsign, bool callsignResolution) const + { + QWidget *w = findTextMessageTabByName(callsign.asString()); + if (w) { return w; } + if (!callsignResolution) { return nullptr; } + + // resolve callsign + CAtcStation station(getIContextNetwork()->getOnlineStationForCallsign(callsign)); + if (!station.getCallsign().isEmpty()) + { + if (this->getOwnAircraft().getCom1System().isActiveFrequencyWithin25kHzChannel(station.getFrequency())) + { + return getTabWidget(TextMessagesCom1); + } + else if (this->getOwnAircraft().getCom2System().isActiveFrequencyWithin25kHzChannel(station.getFrequency())) + { + return getTabWidget(TextMessagesCom2); + } + } + return nullptr; + } + QWidget *CTextMessageComponent::findTextMessageTabByName(const QString &name) const { if (name.isEmpty()) { return nullptr; } @@ -400,5 +445,30 @@ namespace BlackGui return false; // we never handle the message directly, but forward it } + void CTextMessageComponent::showCorrespondingTab(const CCallsign &callsign) + { + Q_ASSERT(getIContextOwnAircraft()); + Q_ASSERT(getIContextNetwork()); + + if (callsign.isEmpty()) + { + CLogMessage(this).warning("No callsign to display text message"); + return; + } + QWidget *w = findTextMessageTabByCallsign(callsign, true); + if (!w && getIContextNetwork()) + { + CSimulatedAircraft aircraft(getIContextNetwork()->getAircraftForCallsign(callsign)); + if (!aircraft.getCallsign().isEmpty()) + { + // we assume a private message + w = this->addNewTextMessageTab(aircraft.getCallsign()); + } + } + if (!w) { return; } + this->ui->tw_TextMessages->setCurrentWidget(w); + this->displayMyself(); + } + } // namespace } // namespace diff --git a/src/blackgui/components/textmessagecomponent.h b/src/blackgui/components/textmessagecomponent.h index a4a51aa24..7020caefd 100644 --- a/src/blackgui/components/textmessagecomponent.h +++ b/src/blackgui/components/textmessagecomponent.h @@ -68,7 +68,10 @@ namespace BlackGui void onTextMessageSent(const BlackMisc::Network::CTextMessage &sentMessage); //! Used to allow direct input from global command line when visible - virtual bool handleGlobalCommandLine(const QString &commandLine, const QString &originator); + bool handleGlobalCommandLine(const QString &commandLine, const QString &originator); + + //! Display the tab for given callsign + void showCorrespondingTab(const BlackMisc::Aviation::CCallsign &callsign); protected: //! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet @@ -76,16 +79,24 @@ namespace BlackGui private: QScopedPointer ui; - CTextMessageTextEdit *m_currentTextEdit = nullptr; //!< text edit currently visible //! Enum to widget - QWidget *getTabWidget(Tab tab); + QWidget *getTabWidget(Tab tab) const; + + //! Select given tab + void selectTabWidget(Tab tab); + + //! New message tab for given callsign + QWidget *addNewTextMessageTab(const BlackMisc::Aviation::CCallsign &callsign); //! Add new text message tab //! \param tabName name of the new tab, usually the channel name //! \return QWidget *addNewTextMessageTab(const QString &tabName); + //! Find text message tab by callsign + QWidget *findTextMessageTabByCallsign(const BlackMisc::Aviation::CCallsign &callsign, bool callsignResolution = false) const; + //! Find text message tab by its name QWidget *findTextMessageTabByName(const QString &name) const; @@ -93,13 +104,13 @@ namespace BlackGui void addPrivateChannelTextMessage(const BlackMisc::Network::CTextMessage &textMessage); //! own aircraft - const BlackMisc::Aviation::CAircraft getOwnAircraft() const { Q_ASSERT(this->getIContextOwnAircraft()); return this->getIContextOwnAircraft()->getOwnAircraft(); } + const BlackMisc::Aviation::CAircraft getOwnAircraft() const; //! For this text message's recepient, is the current tab selected? bool isCorrespondingTextMessageTabSelected(BlackMisc::Network::CTextMessage textMessage) const; //! Network connected? - bool isNetworkConnected() const { return this->getIContextNetwork() && this->getIContextNetwork()->isConnected() ; } + bool isNetworkConnected() const; //! Show current frequencies void showCurrentFrequenciesFromCockpit(); @@ -124,7 +135,7 @@ namespace BlackGui //! Close text message tab void ps_closeTextMessageTab(); - //! Top level was changed + //! Top level was changed (used to enable elements when floating) void ps_topLevelChanged(QWidget *widget, bool topLevel); //! Command line entered diff --git a/src/blackgui/components/updatetimer.cpp b/src/blackgui/components/updatetimer.cpp index 463cfd002..c6a2f6cb2 100644 --- a/src/blackgui/components/updatetimer.cpp +++ b/src/blackgui/components/updatetimer.cpp @@ -13,19 +13,11 @@ namespace BlackGui { namespace Components { - CUpdateTimer::CUpdateTimer(const char *slot, QObject *parent) : - QObject(parent) + void CUpdateTimer::initTimers() { - Q_ASSERT(parent); this->m_timer = new QTimer(this); this->m_timerSingleShot = new QTimer(this); this->m_timerSingleShot->setSingleShot(true); - - bool c = this->connect(this->m_timer, SIGNAL(timeout()), parent, slot); - Q_ASSERT(c); - c = this->connect(this->m_timerSingleShot, SIGNAL(timeout()), parent, slot); - Q_ASSERT(c); - Q_UNUSED(c); } CUpdateTimer::~CUpdateTimer() @@ -54,5 +46,6 @@ namespace BlackGui this->m_timer->start(); // restart other timer this->m_timerSingleShot->start(10); } - } + + } // namespace } // namespace diff --git a/src/blackgui/components/updatetimer.h b/src/blackgui/components/updatetimer.h index ea1294463..be77d7a2f 100644 --- a/src/blackgui/components/updatetimer.h +++ b/src/blackgui/components/updatetimer.h @@ -25,8 +25,18 @@ namespace BlackGui Q_OBJECT public: - //! Constructor - CUpdateTimer(const char *slot, QObject *parent); + //! Construct a timer which forwards messages to the given slot of parent. + template + CUpdateTimer(F slot, P *parent) : QObject(parent) + { + Q_ASSERT(parent); + this->initTimers(); + bool c = this->connect(this->m_timer, &QTimer::timeout, parent, slot); + Q_ASSERT(c); + c = this->connect(this->m_timerSingleShot, &QTimer::timeout, parent, slot); + Q_ASSERT(c); + Q_UNUSED(c); + } //! Destructor ~CUpdateTimer(); @@ -55,6 +65,7 @@ namespace BlackGui void fireTimer(); private: + void initTimers(); //!< init timers QTimer *m_timer = nullptr; //!< periodically updating QTimer *m_timerSingleShot = nullptr; //!< single update }; diff --git a/src/blackgui/components/usercomponent.cpp b/src/blackgui/components/usercomponent.cpp index d31e5645a..014b57d0e 100644 --- a/src/blackgui/components/usercomponent.cpp +++ b/src/blackgui/components/usercomponent.cpp @@ -30,7 +30,7 @@ namespace BlackGui { ui->setupUi(this); this->tabBar()->setExpanding(false); - this->m_updateTimer = new CUpdateTimer(SLOT(update()), this); + this->m_updateTimer = new CUpdateTimer(&CUserComponent::update, this); connect(this->ui->tvp_AllUsers, &CUserView::rowCountChanged, this, &CUserComponent::ps_onCountChanged); connect(this->ui->tvp_Clients, &CClientView::rowCountChanged, this, &CUserComponent::ps_onCountChanged); diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index 339214ade..d7f8592ae 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -297,7 +297,7 @@ namespace BlackGui } else { - this->setCurrentTabIndex(dw); + this->selectArea(dw); } } @@ -599,7 +599,7 @@ namespace BlackGui return getTabBarIndexByTitle(dockWidgetInfoArea->windowTitle()); } - void CInfoArea::setCurrentTabIndex(const CDockWidgetInfoArea *dockWidgetInfoArea) + void CInfoArea::selectArea(const CDockWidgetInfoArea *dockWidgetInfoArea) { if (!this->m_tabBar) { return; } int tabIndex = this->dockWidgetInfoAreaToTabBarIndex(dockWidgetInfoArea); @@ -654,7 +654,7 @@ namespace BlackGui if (!topLevel) { CDockWidgetInfoArea *dwia = dynamic_cast(dockWidget); - this->setCurrentTabIndex(dwia); + this->selectArea(dwia); } // when toplevel is changed, I need a round in the event loop until diff --git a/src/blackgui/infoarea.h b/src/blackgui/infoarea.h index 379e81baf..b38b56b85 100644 --- a/src/blackgui/infoarea.h +++ b/src/blackgui/infoarea.h @@ -89,6 +89,9 @@ namespace BlackGui //! Select area void selectArea(int areaIndex); + //! Set current tab bar index by given widget + void selectArea(const CDockWidgetInfoArea *dockWidgetInfoArea); + //! Select area (sender is QAction) void selectAreaByAction(); @@ -164,9 +167,6 @@ namespace BlackGui //! Widget to tab bar index int dockWidgetInfoAreaToTabBarIndex(const CDockWidgetInfoArea *dockWidgetInfoArea) const; - //! Set current tab bar index by given widget - void setCurrentTabIndex(const CDockWidgetInfoArea *dockWidgetInfoArea); - //! Features of the dockable widgets void setFeaturesForDockableWidgets(QDockWidget::DockWidgetFeatures features); diff --git a/src/blackgui/views/atcstationview.cpp b/src/blackgui/views/atcstationview.cpp index 3356feb23..7f4c70907 100644 --- a/src/blackgui/views/atcstationview.cpp +++ b/src/blackgui/views/atcstationview.cpp @@ -53,7 +53,7 @@ namespace BlackGui { menu.addAction(CIcons::appCockpit16(), "Tune in COM1", this, SLOT(ps_tuneInAtcCom1())); menu.addAction(CIcons::appCockpit16(), "Tune in COM2", this, SLOT(ps_tuneInAtcCom2())); - menu.addAction(CIcons::appTextMessages16(), "Text message", this, SLOT(ps_requestTextMessage())); + menu.addAction(CIcons::appTextMessages16(), "Show text messages", this, SLOT(ps_requestTextMessage())); menu.addSeparator(); } CViewBase::customMenu(menu); diff --git a/src/blackgui/views/simulatedaircraftview.cpp b/src/blackgui/views/simulatedaircraftview.cpp index d1ecfcd6f..448bfda2d 100644 --- a/src/blackgui/views/simulatedaircraftview.cpp +++ b/src/blackgui/views/simulatedaircraftview.cpp @@ -41,9 +41,9 @@ namespace BlackGui { CSimulatedAircraft aircraft(selectedObject()); Q_ASSERT(!aircraft.getCallsign().isEmpty()); - menu.addAction(CIcons::appTextMessages16(), "Text message", this, SLOT(ps_requestTextMessage())); - menu.addAction(CIcons::appAircrafts16(), aircraft.isEnabled() ? "disable aircraft" : "enabled aircraft", this, SLOT(ps_enableAircraft())); - menu.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "normal updates" : "fast position updates", this, SLOT(ps_fastPositionUpdates())); + menu.addAction(CIcons::appTextMessages16(), "Show text messages", this, SLOT(ps_requestTextMessage())); + menu.addAction(CIcons::appAircrafts16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", this, SLOT(ps_enableAircraft())); + menu.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", this, SLOT(ps_fastPositionUpdates())); menu.addSeparator(); } CViewBase::customMenu(menu); diff --git a/src/swiftgui_standard/swiftguistd.cpp b/src/swiftgui_standard/swiftguistd.cpp index e7c664552..47da6f307 100644 --- a/src/swiftgui_standard/swiftguistd.cpp +++ b/src/swiftgui_standard/swiftguistd.cpp @@ -56,9 +56,6 @@ SwiftGuiStd::SwiftGuiStd(BlackGui::CEnableForFramelessWindow::WindowMode windowM SwiftGuiStd::~SwiftGuiStd() { } -/* - * Graceful shutdown - */ void SwiftGuiStd::performGracefulShutdown() { if (!this->m_init) { return; } @@ -99,9 +96,6 @@ void SwiftGuiStd::performGracefulShutdown() } } -/* - * Close event, window closes - */ void SwiftGuiStd::closeEvent(QCloseEvent *event) { Q_UNUSED(event); @@ -109,9 +103,6 @@ void SwiftGuiStd::closeEvent(QCloseEvent *event) QApplication::exit(); } -/* - * Set main page - */ void SwiftGuiStd::ps_setMainPage(SwiftGuiStd::MainPageIndex mainPage) { this->ui->sw_MainMiddle->setCurrentIndex(mainPage); @@ -123,26 +114,11 @@ void SwiftGuiStd::ps_setMainPageInfoArea(CMainInfoAreaComponent::InfoArea infoAr this->ui->comp_MainInfoArea->selectArea(infoArea); } -/* - * Given main page selected? - */ bool SwiftGuiStd::isMainPageSelected(SwiftGuiStd::MainPageIndex mainPage) const { return this->ui->sw_MainMiddle->currentIndex() == static_cast(mainPage); } -void SwiftGuiStd::hideMainPage(bool hide) -{ - //! \todo further implement hide main page - if (hide) - { - - } - else - { - - } -} void SwiftGuiStd::ps_loginRequested() { @@ -157,9 +133,6 @@ void SwiftGuiStd::ps_loginRequested() } } -/* - * Is the network context available? - */ bool SwiftGuiStd::isContextNetworkAvailableCheck() { if (this->m_contextNetworkAvailable) return true; @@ -167,9 +140,6 @@ bool SwiftGuiStd::isContextNetworkAvailableCheck() return false; } -/* - * Is the audio context available? - */ bool SwiftGuiStd::isContextAudioAvailableCheck() { if (this->m_contextAudioAvailable) return true; @@ -177,9 +147,6 @@ bool SwiftGuiStd::isContextAudioAvailableCheck() return false; } -/* - * Display a status message - */ void SwiftGuiStd::ps_displayStatusMessageInGui(const CStatusMessage &statusMessage) { if (!this->m_init) return; @@ -205,17 +172,11 @@ void SwiftGuiStd::ps_onChangedSetttings(uint typeValue) if (type == IContextSettings::SettingsHotKeys) this->ps_registerHotkeyFunctions(); } -/* -* Connection terminated -*/ void SwiftGuiStd::ps_onConnectionTerminated() { this->updateGuiStatusInformation(); } -/* -* Connection status changed -*/ void SwiftGuiStd::ps_onConnectionStatusChanged(int from, int to) { Q_UNUSED(from); @@ -239,9 +200,6 @@ void SwiftGuiStd::ps_onConnectionStatusChanged(int from, int to) } } -/* -* Timer event -*/ void SwiftGuiStd::ps_handleTimerBasedUpdates() { QObject *sender = QObject::sender(); @@ -255,9 +213,6 @@ void SwiftGuiStd::ps_handleTimerBasedUpdates() this->ps_reloadOwnAircraft(); // regular updates } -/* -* Context availability -*/ void SwiftGuiStd::setContextAvailability() { qint64 t = QDateTime::currentMSecsSinceEpoch(); @@ -266,9 +221,6 @@ void SwiftGuiStd::setContextAvailability() this->m_contextAudioAvailable = this->m_coreAvailable || this->getIContextAudio()->isUsingImplementingObject(); } -/* -* Update GUI -*/ void SwiftGuiStd::updateGuiStatusInformation() { const QString now = QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd HH:mm:ss"); @@ -285,9 +237,6 @@ void SwiftGuiStd::updateGuiStatusInformation() this->ui->comp_InfoBarStatus->setDBusTooltip(s); } -/* - * Opacity 0-100 - */ void SwiftGuiStd::ps_onChangedWindowOpacity(int opacity) { qreal o = opacity / 100.0; @@ -297,9 +246,6 @@ void SwiftGuiStd::ps_onChangedWindowOpacity(int opacity) this->ui->comp_MainInfoArea->getSettingsComponent()->setGuiOpacity(o * 100.0); } -/* - * Stay on top - */ void SwiftGuiStd::ps_toogleWindowStayOnTop() { Qt::WindowFlags flags = this->windowFlags(); @@ -319,9 +265,6 @@ void SwiftGuiStd::ps_toogleWindowStayOnTop() this->show(); } -/* - * Hotkey functions - */ void SwiftGuiStd::ps_registerHotkeyFunctions() { CInputManager *m_inputManager = BlackCore::CInputManager::getInstance(); @@ -342,9 +285,6 @@ void SwiftGuiStd::ps_registerHotkeyFunctions() }); } -/* - * Styles - */ void SwiftGuiStd::ps_onStyleSheetsChanged() { const QString s = CStyleSheetUtility::instance().styles( @@ -357,26 +297,17 @@ void SwiftGuiStd::ps_onStyleSheetsChanged() } -/* - * Main widget (login, main info area...) - */ void SwiftGuiStd::ps_onCurrentMainWidgetChanged(int currentIndex) { emit currentMainInfoAreaChanged(this->ui->sw_MainMiddle->currentWidget()); Q_UNUSED(currentIndex); } -/* - * Main info area floating? - */ void SwiftGuiStd::ps_onChangedMainInfoAreaFloating(bool floating) { - this->hideMainPage(floating); + Q_UNUSED(floating); } -/* - * Notification - */ void SwiftGuiStd::playNotifcationSound(CNotificationSounds::Notification notification) const { if (!this->m_contextAudioAvailable) return; diff --git a/src/swiftgui_standard/swiftguistd.h b/src/swiftgui_standard/swiftguistd.h index 207ced72d..426084c15 100644 --- a/src/swiftgui_standard/swiftguistd.h +++ b/src/swiftgui_standard/swiftguistd.h @@ -155,9 +155,6 @@ private: */ bool isMainPageSelected(MainPageIndex mainPage) const; - //! Show or hide the main Page - void hideMainPage(bool hide); - //! Start all update timers void startUpdateTimersWhenConnected(); diff --git a/src/swiftgui_standard/swiftguistd_init.cpp b/src/swiftgui_standard/swiftguistd_init.cpp index 604d7751b..edceba3be 100644 --- a/src/swiftgui_standard/swiftguistd_init.cpp +++ b/src/swiftgui_standard/swiftguistd_init.cpp @@ -182,6 +182,10 @@ void SwiftGuiStd::initGuiSignals() this->ui->comp_MainInfoArea->getSettingsComponent()->setSettingsTab(CSettingsComponent::SettingTabNetworkServers); }); + // textmessages + connect(this->ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestTextMessage, this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab); + connect(this->ui->comp_MainInfoArea->getMappingComponet(), &CMappingComponent::requestTextMessage, this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab); + // main info area connect(this->ui->comp_MainInfoArea, &CMainInfoAreaComponent::changedWholeInfoAreaFloating, this, &SwiftGuiStd::ps_onChangedMainInfoAreaFloating); }