mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #318 Add method in Application Context to process a remote event
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user