mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
refs #313 Register hotkey functions instead keyboard keys
This commit is contained in:
@@ -79,8 +79,6 @@ void MainWindow::gracefulShutdown()
|
||||
if (!this->m_init) return;
|
||||
this->m_init = false;
|
||||
|
||||
if (this->m_keyboard) this->m_keyboard->unregisterAllHotkeys();
|
||||
|
||||
if (this->getIContextApplication())
|
||||
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStops);
|
||||
|
||||
@@ -333,7 +331,7 @@ void MainWindow::displayRedirectedOutput(const CStatusMessage &statusMessage, qi
|
||||
void MainWindow::ps_onChangedSetttings(uint typeValue)
|
||||
{
|
||||
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
|
||||
if (type == IContextSettings::SettingsHotKeys) this->ps_registerHotkeys();
|
||||
if (type == IContextSettings::SettingsHotKeys) this->ps_registerHotkeyFunctions();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -521,31 +519,26 @@ void MainWindow::ps_toogleWindowStayOnTop()
|
||||
}
|
||||
|
||||
/*
|
||||
* Hotkeys
|
||||
* Hotkey functions
|
||||
*/
|
||||
void MainWindow::ps_registerHotkeys()
|
||||
void MainWindow::ps_registerHotkeyFunctions()
|
||||
{
|
||||
if (!this->getIContextSettings()) qFatal("Missing settings");
|
||||
if (!this->m_keyboard)
|
||||
CInputManager *m_inputManager = BlackCore::CInputManager::getInstance();
|
||||
|
||||
m_inputManager->registerHotkeyFunc(CHotkeyFunction::Opacity50(), this, [ this ](bool isPressed)
|
||||
{
|
||||
this->m_keyboard = BlackInput::IKeyboard::getInstance();
|
||||
}
|
||||
else
|
||||
if (isPressed) this->changeWindowOpacity(50);
|
||||
});
|
||||
|
||||
m_inputManager->registerHotkeyFunc(CHotkeyFunction::Opacity100(), this, [ this ](bool isPressed)
|
||||
{
|
||||
this->m_keyboard->unregisterAllHotkeys();
|
||||
}
|
||||
if (isPressed) this->changeWindowOpacity(100);
|
||||
});
|
||||
|
||||
CKeyboardKeyList keys = this->getIContextSettings()->getHotkeys();
|
||||
if (keys.isEmpty()) return;
|
||||
|
||||
CKeyboardKey key = keys.keyForFunction(CKeyboardKey::HotkeyOpacity50);
|
||||
if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->ps_changeWindowOpacity(50); });
|
||||
|
||||
key = keys.keyForFunction(CKeyboardKey::HotkeyOpacity100);
|
||||
if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->ps_changeWindowOpacity(100); });
|
||||
|
||||
key = keys.keyForFunction(CKeyboardKey::HotkeyToogleWindowsStayOnTop);
|
||||
if (!key.isEmpty()) this->m_keyboard->registerHotkey(key, this, [ this ](bool isPressed) { if (isPressed) this->ps_toogleWindowStayOnTop(); });
|
||||
m_inputManager->registerHotkeyFunc(CHotkeyFunction::ToogleWindowsStayOnTop(), this, [ this ](bool isPressed)
|
||||
{
|
||||
if (isPressed) this->toogleWindowStayOnTop();
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
#undef interface
|
||||
|
||||
#include "guimodeenums.h"
|
||||
#include "blackinput/keyboard.h"
|
||||
#include "blackcore/context_audio.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_settings.h"
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackcore/input_manager.h"
|
||||
#include "blackgui/components/runtimebasedcomponent.h"
|
||||
#include "blackgui/components/infowindowcomponent.h"
|
||||
#include "blackgui/transpondermodeselector.h"
|
||||
@@ -240,8 +240,8 @@ private slots:
|
||||
//! Toogle Windows stay on top
|
||||
void ps_toogleWindowStayOnTop();
|
||||
|
||||
//! Set the hotkeys
|
||||
void ps_registerHotkeys();
|
||||
//! Set the hotkey functions
|
||||
void ps_registerHotkeyFunctions();
|
||||
|
||||
//! Style sheet has been changed
|
||||
void ps_onStyleSheetsChanged();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/avselcal.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/hotkeyfunction.h"
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QSizeGrip>
|
||||
#include <QHBoxLayout>
|
||||
@@ -140,7 +141,7 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
|
||||
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(CProject::compiledInfo());
|
||||
|
||||
// hotkeys
|
||||
this->ps_registerHotkeys();
|
||||
this->ps_registerHotkeyFunctions();
|
||||
|
||||
// update timers
|
||||
this->startUpdateTimers();
|
||||
|
||||
Reference in New Issue
Block a user