Reload hotkey settings when they have changed

This also includes changing the registration

refs #83
This commit is contained in:
Roland Winklmeier
2014-03-05 17:31:08 +01:00
parent abb20a5154
commit 811bbdfe4e
5 changed files with 44 additions and 5 deletions

View File

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