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
This commit is contained in:
parent
fa8ce4b0b3
commit
e376b64dee
@ -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<QKeyEvent*>(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("<b>" + ret_.toString(QKeySequence::NativeText) + "</b>");
|
||||
|
||||
if (!ke->text().isEmpty())
|
||||
if (!modifier_keys_.contains(ke->key()))
|
||||
accept();
|
||||
return true;
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ class GlobalShortcutGrabber : public QDialog {
|
||||
private:
|
||||
Ui_GlobalShortcutGrabber* ui_;
|
||||
QKeySequence ret_;
|
||||
|
||||
QList<int> modifier_keys_;
|
||||
};
|
||||
|
||||
#endif // GLOBALSHORTCUTGRABBER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user