From 788078f72a5ccfeb1a8a23b5f2499042c5bb1385 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 29 Nov 2014 20:03:41 +0000 Subject: [PATCH] refs #288, parseCommand in runtime, which distributes it to the contexts (easier, also for core command line) --- src/blackcore/context_runtime.cpp | 9 +++++++++ src/blackcore/context_runtime.h | 4 ++++ src/blackgui/components/mainkeypadareacomponent.cpp | 5 +---- src/blackgui/components/textmessagecomponent.cpp | 5 +---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index 76c0a56aa..3a7da72df 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -126,6 +126,15 @@ namespace BlackCore return (token == this->m_contextApplication->ping(token)); } + bool CRuntime::parseCommandLine(const QString commandLine) + { + bool handled = false; + if (this->getIContextAudio()) { handled = handled || this->getIContextAudio()->parseCommandLine(commandLine); } + if (this->getIContextNetwork()) { handled = handled || this->getIContextNetwork()->parseCommandLine(commandLine); } + if (this->getIContextOwnAircraft()) { handled = handled || this->getIContextOwnAircraft()->parseCommandLine(commandLine); } + return handled; + } + void CRuntime::initDBusServer(const QString &dBusAddress) { if (this->m_dbusServer) return; diff --git a/src/blackcore/context_runtime.h b/src/blackcore/context_runtime.h index 0adeecc3e..55361db60 100644 --- a/src/blackcore/context_runtime.h +++ b/src/blackcore/context_runtime.h @@ -149,6 +149,10 @@ namespace BlackCore //! Is application context available? bool canPingApplicationContext() const; + public slots: + //! Parse command line in all contexts + bool parseCommandLine(const QString commandLine); + private: bool m_init = false; /*!< flag */ diff --git a/src/blackgui/components/mainkeypadareacomponent.cpp b/src/blackgui/components/mainkeypadareacomponent.cpp index c184a8eda..6e7799557 100644 --- a/src/blackgui/components/mainkeypadareacomponent.cpp +++ b/src/blackgui/components/mainkeypadareacomponent.cpp @@ -86,10 +86,7 @@ namespace BlackGui connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMainKeypadAreaComponent::ps_connectionStatusChanged); connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ps_ownAircraftCockpitChanged); connect(this->getIContextAudio(), &IContextAudio::changedMute, this, &CMainKeypadAreaComponent::ps_muteChanged); - - connect(this, &CMainKeypadAreaComponent::commandEntered, this->getIContextOwnAircraft(), &IContextOwnAircraft::parseCommandLine); - connect(this, &CMainKeypadAreaComponent::commandEntered, this->getIContextNetwork(), &IContextNetwork::parseCommandLine); - connect(this, &CMainKeypadAreaComponent::commandEntered, this->getIContextAudio(), &IContextAudio::parseCommandLine); + connect(this, &CMainKeypadAreaComponent::commandEntered, this->getRuntime(), &CRuntime::parseCommandLine); } void CMainKeypadAreaComponent::ps_buttonSelected() diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index d9ed41898..5e7ab36f7 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -163,10 +163,7 @@ namespace BlackGui connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CTextMessageComponent::ps_onChangedAircraftCockpit); connect(this->getDockWidgetInfoArea(), &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CTextMessageComponent::ps_topLevelChanged); - - connect(this, &CTextMessageComponent::commandEntered, this->getIContextOwnAircraft(), &IContextOwnAircraft::parseCommandLine); - connect(this, &CTextMessageComponent::commandEntered, this->getIContextNetwork(), &IContextNetwork::parseCommandLine); - connect(this, &CTextMessageComponent::commandEntered, this->getIContextAudio(), &IContextAudio::parseCommandLine); + connect(this, &CTextMessageComponent::commandEntered, this->getRuntime(), &CRuntime::parseCommandLine); } /*