From e376b64deed84b47fe485d2138a8eeed128ef26e Mon Sep 17 00:00:00 2001 From: David Sansome Date: Thu, 17 Jun 2010 13:59:32 +0000 Subject: [PATCH] Make the global shortcut grabber grab keys that don't have any "text" associated with them, like Home or the F-keys. Fixes issue #412 --- src/ui/globalshortcutgrabber.cpp | 8 +++++--- src/ui/globalshortcutgrabber.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ui/globalshortcutgrabber.cpp b/src/ui/globalshortcutgrabber.cpp index eec6f1d38..57c7da07a 100644 --- a/src/ui/globalshortcutgrabber.cpp +++ b/src/ui/globalshortcutgrabber.cpp @@ -25,6 +25,9 @@ GlobalShortcutGrabber::GlobalShortcutGrabber(QWidget *parent) ui_(new Ui::GlobalShortcutGrabber) { ui_->setupUi(this); + + modifier_keys_ << Qt::Key_Shift << Qt::Key_Control << Qt::Key_Meta + << Qt::Key_Alt << Qt::Key_AltGr; } GlobalShortcutGrabber::~GlobalShortcutGrabber() { @@ -56,15 +59,14 @@ bool GlobalShortcutGrabber::event(QEvent* e) { if (e->type() == QEvent::ShortcutOverride) { QKeyEvent* ke = static_cast(e); - if (ke->text().isEmpty()) + if (modifier_keys_.contains(ke->key())) ret_ = QKeySequence(ke->modifiers()); else ret_ = QKeySequence(ke->modifiers() | ke->key()); - ui_->combo->setText("" + ret_.toString(QKeySequence::NativeText) + ""); - if (!ke->text().isEmpty()) + if (!modifier_keys_.contains(ke->key())) accept(); return true; } diff --git a/src/ui/globalshortcutgrabber.h b/src/ui/globalshortcutgrabber.h index bfca490f9..bec79aa16 100644 --- a/src/ui/globalshortcutgrabber.h +++ b/src/ui/globalshortcutgrabber.h @@ -38,6 +38,8 @@ class GlobalShortcutGrabber : public QDialog { private: Ui_GlobalShortcutGrabber* ui_; QKeySequence ret_; + + QList modifier_keys_; }; #endif // GLOBALSHORTCUTGRABBER_H