mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-11 06:25:33 +08:00
Reload hotkey settings when they have changed
This also includes changing the registration refs #83
This commit is contained in:
@@ -25,7 +25,8 @@ namespace BlackCore
|
|||||||
CContextAudio::CContextAudio(QObject *parent) :
|
CContextAudio::CContextAudio(QObject *parent) :
|
||||||
IContextAudio(parent),
|
IContextAudio(parent),
|
||||||
m_voice(nullptr),
|
m_voice(nullptr),
|
||||||
m_keyboard(nullptr)
|
m_keyboard(nullptr),
|
||||||
|
m_contextSettings(nullptr)
|
||||||
{
|
{
|
||||||
// 1. Init by "voice driver"
|
// 1. Init by "voice driver"
|
||||||
this->m_voice = new CVoiceVatlib(this);
|
this->m_voice = new CVoiceVatlib(this);
|
||||||
@@ -44,6 +45,12 @@ namespace BlackCore
|
|||||||
this->leaveAllVoiceRooms();
|
this->leaveAllVoiceRooms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudio::init()
|
||||||
|
{
|
||||||
|
m_contextSettings = getRuntime()->getIContextSettings();
|
||||||
|
connect(m_contextSettings, &IContextSettings::changedSettings, this, &CContextAudio::settingsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Own aircraft
|
* Own aircraft
|
||||||
*/
|
*/
|
||||||
@@ -281,4 +288,15 @@ namespace BlackCore
|
|||||||
return static_cast<double>(this->m_voice->inputSquelch());
|
return static_cast<double>(this->m_voice->inputSquelch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudio::settingsChanged(IContextSettings::SettingsType type)
|
||||||
|
{
|
||||||
|
if (type == IContextSettings::SettingsHotKeys)
|
||||||
|
{
|
||||||
|
CKeyboardKeyList hotKeys = m_contextSettings->getHotkeys();
|
||||||
|
CKeyboardKey pttKey = hotKeys.findBy(&BlackMisc::Hardware::CKeyboardKey::getFunction, BlackMisc::Hardware::CKeyboardKey::HotkeyPtt).front();
|
||||||
|
m_keyboard->unregisterHotkey(m_handlePtt);
|
||||||
|
m_handlePtt = m_keyboard->registerHotkey(pttKey, m_voice, &CVoiceVatlib::handlePushToTalk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
#define BLACKCORE_CONTEXTAUDIO_IMPL_H
|
#define BLACKCORE_CONTEXTAUDIO_IMPL_H
|
||||||
|
|
||||||
#include "context_audio.h"
|
#include "context_audio.h"
|
||||||
|
#include "context_settings.h"
|
||||||
#include "coreruntime.h"
|
#include "coreruntime.h"
|
||||||
#include "dbus_server.h"
|
#include "dbus_server.h"
|
||||||
#include "voice_vatlib.h"
|
#include "voice_vatlib.h"
|
||||||
|
#include "blackcore/keyboard.h"
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -52,6 +54,9 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextAudio::usingLocalObjects()
|
//! \copydoc IContextAudio::usingLocalObjects()
|
||||||
virtual bool usingLocalObjects() const override { return true; }
|
virtual bool usingLocalObjects() const override { return true; }
|
||||||
|
|
||||||
|
//! \brief Initialize voice context
|
||||||
|
void init();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! \copydoc IContextAudio::setOwnAircraft()
|
//! \copydoc IContextAudio::setOwnAircraft()
|
||||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||||
@@ -119,6 +124,9 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextAudio::getSquelchValue()
|
//! \copydoc IContextAudio::getSquelchValue()
|
||||||
virtual double getSquelchValue() const override;
|
virtual double getSquelchValue() const override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void settingsChanged(IContextSettings::SettingsType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CVoiceVatlib *m_voice; //!< underlying voice lib
|
CVoiceVatlib *m_voice; //!< underlying voice lib
|
||||||
IKeyboard *m_keyboard;
|
IKeyboard *m_keyboard;
|
||||||
|
|||||||
@@ -6,10 +6,14 @@
|
|||||||
#ifndef BLACKCORE_CONTEXTSETTINGS_H
|
#ifndef BLACKCORE_CONTEXTSETTINGS_H
|
||||||
#define BLACKCORE_CONTEXTSETTINGS_H
|
#define BLACKCORE_CONTEXTSETTINGS_H
|
||||||
|
|
||||||
|
#include "blackcore/coreruntime.h"
|
||||||
|
#include "blackcore/dbus_server.h"
|
||||||
|
#include "blackcore/keyboard.h"
|
||||||
|
#include "blackmisc/hwkeyboardkeylist.h"
|
||||||
#include "blackmisc/statusmessagelist.h"
|
#include "blackmisc/statusmessagelist.h"
|
||||||
#include "blackmisc/settingutilities.h"
|
#include "blackmisc/settingutilities.h"
|
||||||
#include "blackmisc/setnetwork.h"
|
#include "blackmisc/setnetwork.h"
|
||||||
#include "blackmisc/hwkeyboardkeylist.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@@ -30,6 +34,12 @@ namespace BlackCore
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum SettingsType
|
||||||
|
{
|
||||||
|
SettingsHotKeys,
|
||||||
|
SettingsNetwork
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Service name
|
* \brief Service name
|
||||||
*/
|
*/
|
||||||
@@ -103,7 +113,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! \brief Settings have been changed
|
//! \brief Settings have been changed
|
||||||
void changedSettings();
|
void changedSettings(SettingsType type);
|
||||||
|
|
||||||
//! \brief Network settings have been changed
|
//! \brief Network settings have been changed
|
||||||
void changedNetworkSettings();
|
void changedNetworkSettings();
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
BlackMisc::Hardware::CKeyboardKeyList hotkeys = value.value<BlackMisc::Hardware::CKeyboardKeyList>();
|
BlackMisc::Hardware::CKeyboardKeyList hotkeys = value.value<BlackMisc::Hardware::CKeyboardKeyList>();
|
||||||
this->m_hotkeys = hotkeys;
|
this->m_hotkeys = hotkeys;
|
||||||
emit this->changedSettings();
|
emit this->changedSettings(SettingsHotKeys);
|
||||||
|
|
||||||
msgs.push_back(CStatusMessage::getInfoMessage("set hotkeys"));
|
msgs.push_back(CStatusMessage::getInfoMessage("set hotkeys"));
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
@@ -84,7 +85,7 @@ namespace BlackCore
|
|||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
emit this->changedNetworkSettings();
|
emit this->changedNetworkSettings();
|
||||||
emit this->changedSettings();
|
emit this->changedSettings(SettingsNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ void CCoreRuntime::init(bool withDbus)
|
|||||||
this->m_contextSimulator = new CContextSimulator(this);
|
this->m_contextSimulator = new CContextSimulator(this);
|
||||||
if (withDbus) this->m_contextSimulator->registerWithDBus(this->m_dbusServer);
|
if (withDbus) this->m_contextSimulator->registerWithDBus(this->m_dbusServer);
|
||||||
|
|
||||||
|
m_contextAudio->init();
|
||||||
|
|
||||||
// flag
|
// flag
|
||||||
m_init = true;
|
m_init = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user