mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +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) :
|
||||
IContextAudio(parent),
|
||||
m_voice(nullptr),
|
||||
m_keyboard(nullptr)
|
||||
m_keyboard(nullptr),
|
||||
m_contextSettings(nullptr)
|
||||
{
|
||||
// 1. Init by "voice driver"
|
||||
this->m_voice = new CVoiceVatlib(this);
|
||||
@@ -44,6 +45,12 @@ namespace BlackCore
|
||||
this->leaveAllVoiceRooms();
|
||||
}
|
||||
|
||||
void CContextAudio::init()
|
||||
{
|
||||
m_contextSettings = getRuntime()->getIContextSettings();
|
||||
connect(m_contextSettings, &IContextSettings::changedSettings, this, &CContextAudio::settingsChanged);
|
||||
}
|
||||
|
||||
/*
|
||||
* Own aircraft
|
||||
*/
|
||||
@@ -281,4 +288,15 @@ namespace BlackCore
|
||||
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
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
#define BLACKCORE_CONTEXTAUDIO_IMPL_H
|
||||
|
||||
#include "context_audio.h"
|
||||
#include "context_settings.h"
|
||||
#include "coreruntime.h"
|
||||
#include "dbus_server.h"
|
||||
#include "voice_vatlib.h"
|
||||
#include "blackcore/keyboard.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -52,6 +54,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextAudio::usingLocalObjects()
|
||||
virtual bool usingLocalObjects() const override { return true; }
|
||||
|
||||
//! \brief Initialize voice context
|
||||
void init();
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextAudio::setOwnAircraft()
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||
@@ -119,6 +124,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextAudio::getSquelchValue()
|
||||
virtual double getSquelchValue() const override;
|
||||
|
||||
private slots:
|
||||
void settingsChanged(IContextSettings::SettingsType type);
|
||||
|
||||
private:
|
||||
CVoiceVatlib *m_voice; //!< underlying voice lib
|
||||
IKeyboard *m_keyboard;
|
||||
|
||||
@@ -6,10 +6,14 @@
|
||||
#ifndef 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/settingutilities.h"
|
||||
#include "blackmisc/setnetwork.h"
|
||||
#include "blackmisc/hwkeyboardkeylist.h"
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
@@ -30,6 +34,12 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
|
||||
enum SettingsType
|
||||
{
|
||||
SettingsHotKeys,
|
||||
SettingsNetwork
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Service name
|
||||
*/
|
||||
@@ -103,7 +113,7 @@ namespace BlackCore
|
||||
|
||||
signals:
|
||||
//! \brief Settings have been changed
|
||||
void changedSettings();
|
||||
void changedSettings(SettingsType type);
|
||||
|
||||
//! \brief Network settings have been changed
|
||||
void changedNetworkSettings();
|
||||
|
||||
@@ -68,7 +68,8 @@ namespace BlackCore
|
||||
{
|
||||
BlackMisc::Hardware::CKeyboardKeyList hotkeys = value.value<BlackMisc::Hardware::CKeyboardKeyList>();
|
||||
this->m_hotkeys = hotkeys;
|
||||
emit this->changedSettings();
|
||||
emit this->changedSettings(SettingsHotKeys);
|
||||
|
||||
msgs.push_back(CStatusMessage::getInfoMessage("set hotkeys"));
|
||||
return msgs;
|
||||
}
|
||||
@@ -84,7 +85,7 @@ namespace BlackCore
|
||||
if (changed)
|
||||
{
|
||||
emit this->changedNetworkSettings();
|
||||
emit this->changedSettings();
|
||||
emit this->changedSettings(SettingsNetwork);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -52,6 +52,8 @@ void CCoreRuntime::init(bool withDbus)
|
||||
this->m_contextSimulator = new CContextSimulator(this);
|
||||
if (withDbus) this->m_contextSimulator->registerWithDBus(this->m_dbusServer);
|
||||
|
||||
m_contextAudio->init();
|
||||
|
||||
// flag
|
||||
m_init = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user