diff --git a/src/blackcore/context_application.h b/src/blackcore/context_application.h index 394be6390..5722c99a5 100644 --- a/src/blackcore/context_application.h +++ b/src/blackcore/context_application.h @@ -10,6 +10,7 @@ #include "blackcore/context.h" #include "blackmisc/statusmessagelist.h" +#include "blackmisc/eveventhotkeyfunction.h" #include #include @@ -150,6 +151,9 @@ namespace BlackCore //! Remote enabled version of file exists virtual bool existsFile(const QString &fileName) = 0; + //! Process remote event + virtual void processHotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event) = 0; + //! Change settings void changeSettings(uint typeValue); diff --git a/src/blackcore/context_application_impl.cpp b/src/blackcore/context_application_impl.cpp index 82790c28f..15a7adc29 100644 --- a/src/blackcore/context_application_impl.cpp +++ b/src/blackcore/context_application_impl.cpp @@ -5,6 +5,7 @@ #include "context_application_impl.h" #include "context_runtime.h" +#include "input_manager.h" #include "blackmisc/settingutilities.h" #include #include @@ -106,4 +107,10 @@ namespace BlackCore return QFile::exists(fileName); } + void CContextApplication::processHotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event) + { + CInputManager::getInstance()->callFunctionsBy(event.getFunction(), event.getFunctionArgument()); + qDebug() << "Calling function from origin" << event.getEventOriginator().toQString(); + } + } // namespace diff --git a/src/blackcore/context_application_impl.h b/src/blackcore/context_application_impl.h index 5e881b57d..2df32ea74 100644 --- a/src/blackcore/context_application_impl.h +++ b/src/blackcore/context_application_impl.h @@ -49,6 +49,9 @@ namespace BlackCore //! \copydoc IContextApplication::existsFile virtual bool existsFile(const QString &fileName) override; + //! \copydoc IContextApplication::processHotkeyFuncEvent + virtual void processHotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event) override; + protected: static const auto c_logContext = CRuntime::LogForApplication; //!< identifier diff --git a/src/blackcore/context_application_proxy.cpp b/src/blackcore/context_application_proxy.cpp index 34b513d3b..6eae14218 100644 --- a/src/blackcore/context_application_proxy.cpp +++ b/src/blackcore/context_application_proxy.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "blackcore/context_application_proxy.h" +#include "blackcore/input_manager.h" #include "blackmisc/blackmiscfreefunctions.h" #include #include @@ -19,6 +20,11 @@ namespace BlackCore { this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(serviceName , IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), connection, this); this->relaySignals(serviceName, connection); + + // Enable event forwarding from GUI process to core + CInputManager *inputManager = CInputManager::getInstance(); + connect(inputManager, &CInputManager::hotkeyFuncEvent, this, &CContextApplicationProxy::processHotkeyFuncEvent); + inputManager->setEventForwarding(true); } /* @@ -110,4 +116,10 @@ namespace BlackCore if (fileName.isEmpty()) return false; return this->m_dBusInterface->callDBusRet(QLatin1Literal("existsFile"), fileName); } + + void CContextApplicationProxy::processHotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event) + { + this->m_dBusInterface->callDBus(QLatin1Literal("processHotkeyFuncEvent"), event); + } + } // namespace diff --git a/src/blackcore/context_application_proxy.h b/src/blackcore/context_application_proxy.h index 05ae195d8..50babfe19 100644 --- a/src/blackcore/context_application_proxy.h +++ b/src/blackcore/context_application_proxy.h @@ -48,6 +48,9 @@ namespace BlackCore //! \copydoc IContextApplication::existsFile virtual bool existsFile(const QString &fileName) override; + //! \copydoc IContextApplication::processHotkeyFuncEvent + virtual void processHotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event) override; + protected: //! Constructor CContextApplicationProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextApplication(mode, runtime), m_dBusInterface(nullptr) {}