refs #318 Add method in Application Context to process a remote event

This commit is contained in:
Roland Winklmeier
2014-08-20 01:31:20 +02:00
parent bdd7de1459
commit f72ff4e495
5 changed files with 29 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
#include "blackcore/context.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/eveventhotkeyfunction.h"
#include <QObject>
#include <QReadWriteLock>
@@ -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);

View File

@@ -5,6 +5,7 @@
#include "context_application_impl.h"
#include "context_runtime.h"
#include "input_manager.h"
#include "blackmisc/settingutilities.h"
#include <QtMsgHandler>
#include <QFile>
@@ -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

View File

@@ -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

View File

@@ -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 <QObject>
#include <QMetaEnum>
@@ -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<bool>(QLatin1Literal("existsFile"), fileName);
}
void CContextApplicationProxy::processHotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event)
{
this->m_dBusInterface->callDBus(QLatin1Literal("processHotkeyFuncEvent"), event);
}
} // namespace

View File

@@ -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) {}