From d5a3bfe10a940c2e1f4227f3adea71e55a449ca2 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 4 Jul 2018 21:21:45 +0000 Subject: hotkey plugin: fixed windows support git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8108 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/hotkey/hotkeydialog.cpp | 19 ++++++++++++++----- src/plugins/General/hotkey/hotkeydialog.h | 10 +++++----- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/plugins/General/hotkey') diff --git a/src/plugins/General/hotkey/hotkeydialog.cpp b/src/plugins/General/hotkey/hotkeydialog.cpp index 654b871e9..45a3c3e39 100644 --- a/src/plugins/General/hotkey/hotkeydialog.cpp +++ b/src/plugins/General/hotkey/hotkeydialog.cpp @@ -29,13 +29,10 @@ HotkeyDialog::HotkeyDialog(quint32 key, quint32 mod, QWidget *parent) m_key = key; m_modifiers = mod; m_ui.keyLineEdit->setText(HotkeyManager::getKeyString(m_key, m_modifiers)); - grabKeyboard(); } HotkeyDialog::~HotkeyDialog() -{ - releaseKeyboard(); -} +{} void HotkeyDialog::keyPressEvent (QKeyEvent *event) { @@ -45,7 +42,12 @@ void HotkeyDialog::keyPressEvent (QKeyEvent *event) m_modifiers &= ~mask_mod; //remove ignored modifiers (num lock, caps lock, etc) m_ui.keyLineEdit->setText(HotkeyManager::getKeyString(m_key, m_modifiers)); - QWidget::keyPressEvent(event); + QDialog::keyPressEvent(event); +} + +void HotkeyDialog::showEvent(QShowEvent *) +{ + grabKeyboard(); } quint32 HotkeyDialog::nativeModifiers () const @@ -65,5 +67,12 @@ void HotkeyDialog::accept() m_key = 0; m_modifiers = 0; } + releaseKeyboard(); QDialog::accept(); } + +void HotkeyDialog::reject() +{ + releaseKeyboard(); + QDialog::reject(); +} diff --git a/src/plugins/General/hotkey/hotkeydialog.h b/src/plugins/General/hotkey/hotkeydialog.h index 490539eac..4124e8c8f 100644 --- a/src/plugins/General/hotkey/hotkeydialog.h +++ b/src/plugins/General/hotkey/hotkeydialog.h @@ -41,15 +41,15 @@ public: quint32 keySym () const; public slots: - virtual void accept(); - -protected: - virtual void keyPressEvent (QKeyEvent *event); + void accept(); + void reject(); private: + void keyPressEvent (QKeyEvent *event); + void showEvent(QShowEvent *); + Ui::HotkeyDialog m_ui; quint32 m_key, m_modifiers; - }; #endif -- cgit v1.2.3-13-gbd6f