refs #313 Change hotkey sample to new API

This commit is contained in:
Roland Winklmeier
2014-08-04 20:35:08 +02:00
parent 4ac6a673c1
commit 88e7a38796
2 changed files with 19 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ HotkeyDialog::HotkeyDialog(QWidget *parent) :
setupUi();
setupConnections();
}
HotkeyDialog::~HotkeyDialog()
@@ -40,8 +41,17 @@ void HotkeyDialog::keySelectionChanged(BlackMisc::Hardware::CKeyboardKey key)
void HotkeyDialog::keySelectionFinished(BlackMisc::Hardware::CKeyboardKey key)
{
m_lblHotkey->setText(key.toFormattedQString());
m_keyboard->unregisterAllHotkeys();
m_keyboard->registerHotkey(key, this, &HotkeyDialog::setPressed);
m_key = key;
}
void HotkeyDialog::processKeyDown(const BlackMisc::Hardware::CKeyboardKey &key)
{
if (key == m_key) setPressed(true);
}
void HotkeyDialog::processKeyUp(const BlackMisc::Hardware::CKeyboardKey &key)
{
if (key == m_key) setPressed(false);
}
void HotkeyDialog::setPressed(bool isPressed)
@@ -89,5 +99,7 @@ void HotkeyDialog::setupConnections()
{
connect(m_keyboard, &BlackInput::IKeyboard::keySelectionChanged, this, &HotkeyDialog::keySelectionChanged);
connect(m_keyboard, &BlackInput::IKeyboard::keySelectionFinished, this, &HotkeyDialog::keySelectionFinished);
connect(m_keyboard, &BlackInput::IKeyboard::keyDown, this, &HotkeyDialog::processKeyDown);
connect(m_keyboard, &BlackInput::IKeyboard::keyUp, this, &HotkeyDialog::processKeyUp);
connect(m_pbSelect, &QPushButton::clicked, this, &HotkeyDialog::selectHotKey);
}

View File

@@ -46,6 +46,10 @@ private slots:
*/
void keySelectionFinished(BlackMisc::Hardware::CKeyboardKey key);
void processKeyDown(const BlackMisc::Hardware::CKeyboardKey &);
void processKeyUp(const BlackMisc::Hardware::CKeyboardKey &);
private:
/*!
* \brief Set the key status
@@ -58,6 +62,7 @@ private:
void setupConnections();
BlackInput::IKeyboard *m_keyboard;
BlackMisc::Hardware::CKeyboardKey m_key;
QPushButton *m_pbSelect;
QLabel *m_lblHotkey;
CLed *m_led;