From 1adfd16ec970648a994d64226492a51dd56acfad Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 4 Aug 2014 20:40:30 +0200 Subject: [PATCH] refs #313 Application context acts as com layer between settings and InputManager --- src/blackcore/context_application.cpp | 21 +++++++++++++++++++++ src/blackcore/context_application.h | 5 +++++ src/blackcore/context_runtime.cpp | 6 +++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/blackcore/context_application.cpp b/src/blackcore/context_application.cpp index 0023e7496..ee515fa60 100644 --- a/src/blackcore/context_application.cpp +++ b/src/blackcore/context_application.cpp @@ -1,11 +1,14 @@ #include "blackcore/context_application.h" #include "blackcore/context_application_impl.h" #include "blackcore/context_application_proxy.h" +#include "blackcore/context_settings.h" +#include "blackcore/input_manager.h" #include "blackmisc/statusmessage.h" #include #include using namespace BlackMisc; +using namespace BlackMisc::Settings; namespace BlackCore { @@ -57,6 +60,8 @@ namespace BlackCore IContextApplication::s_oldHandler = qInstallMessageHandler(IContextApplication::messageHandlerDispatch); } IContextApplication::s_contexts.append(this); + + changeSettings(IContextSettings::SettingsHotKeys); } /* @@ -81,6 +86,22 @@ namespace BlackCore qInstallMessageHandler(0); } + void IContextApplication::changeSettings(uint typeValue) + { + IContextSettings::SettingsType type = static_cast(typeValue); + switch (type) + { + case IContextSettings::SettingsHotKeys: + { + CSettingKeyboardHotkeyList hotkeys = getIContextSettings()->getHotkeys(); + CInputManager::getInstance()->changeHotkeySettings(hotkeys); + break; + } + default: + break; + } + } + /* * Dispatch message */ diff --git a/src/blackcore/context_application.h b/src/blackcore/context_application.h index 0aa881f01..103d31717 100644 --- a/src/blackcore/context_application.h +++ b/src/blackcore/context_application.h @@ -26,6 +26,8 @@ namespace BlackCore { + class CInputManager; + /*! * Application context interface */ @@ -148,6 +150,9 @@ namespace BlackCore //! Remote enabled version of file exists virtual bool existsFile(const QString &fileName) = 0; + + void changeSettings(uint typeValue); + private: //! All contexts, used with messageHandler static QList s_contexts; diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index 15ccdf96a..4748c3a84 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -407,11 +407,11 @@ namespace BlackCore { bool c; Q_UNUSED(c); // for release version - if (this->m_contextSettings && this->m_contextAudio && this->m_contextSettings->usingLocalObjects()) + + if (this->m_contextSettings && this->m_contextApplication) { - // only, when both contexts exists and only if settings originate locally c = connect(this->m_contextSettings, &IContextSettings::changedSettings, - this->getCContextAudio(), &CContextAudio::ps_settingsChanged); + this->getIContextApplication(), &IContextApplication::changeSettings); Q_ASSERT(c); }