mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 03:35:35 +08:00
refs #313 Application context acts as com layer between settings and InputManager
This commit is contained in:
@@ -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 <QCoreApplication>
|
||||
#include <QThread>
|
||||
|
||||
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<IContextSettings::SettingsType>(typeValue);
|
||||
switch (type)
|
||||
{
|
||||
case IContextSettings::SettingsHotKeys:
|
||||
{
|
||||
CSettingKeyboardHotkeyList hotkeys = getIContextSettings()->getHotkeys();
|
||||
CInputManager::getInstance()->changeHotkeySettings(hotkeys);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dispatch message
|
||||
*/
|
||||
|
||||
@@ -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<IContextApplication *> s_contexts;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user