diff options
author | Liang Qi <liang.qi@qt.io> | 2017-01-30 12:39:22 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-01-30 12:46:20 +0100 |
commit | 246799d8a7bf42c1f22fca7ef6d77e8d58054bad (patch) | |
tree | a0b92a804d7d2a30cd68fa327df5777d8bcc36ba /src/widgets/widgets/qkeysequenceedit.cpp | |
parent | 5ad191850becd7dc1d61d0975f141a5db64e6373 (diff) | |
parent | 02cc57f4edbae450ecfa8368052afa44f8aeee19 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
examples/network/network-chat/peermanager.cpp
src/widgets/util/qsystemtrayicon.cpp
src/widgets/util/qsystemtrayicon_qpa.cpp
src/widgets/util/qsystemtrayicon_win.cpp
src/widgets/util/qsystemtrayicon_x11.cpp
Change-Id: I1c026df83818c0ccaf956980370e7522960627db
Diffstat (limited to 'src/widgets/widgets/qkeysequenceedit.cpp')
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 3252ce5941..4d86c7cfc7 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -43,6 +43,7 @@ #include "qboxlayout.h" #include "qlineedit.h" +#include <private/qkeymapper_p.h> QT_BEGIN_NAMESPACE @@ -80,15 +81,8 @@ void QKeySequenceEditPrivate::init() int QKeySequenceEditPrivate::translateModifiers(Qt::KeyboardModifiers state, const QString &text) { + Q_UNUSED(text); int result = 0; - // The shift modifier only counts when it is not used to type a symbol - // that is only reachable using the shift key anyway - if ((state & Qt::ShiftModifier) && (text.isEmpty() || - !text.at(0).isPrint() || - text.at(0).isLetterOrNumber() || - text.at(0).isSpace())) - result |= Qt::SHIFT; - if (state & Qt::ControlModifier) result |= Qt::CTRL; if (state & Qt::MetaModifier) @@ -272,7 +266,27 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) if (d->keyNum >= QKeySequencePrivate::MaxKeyCount) return; - nextKey |= d->translateModifiers(e->modifiers(), e->text()); + if (e->modifiers() & Qt::ShiftModifier) { + QList<int> possibleKeys = QKeyMapper::possibleKeys(e); + int pkTotal = possibleKeys.count(); + if (!pkTotal) + return; + bool found = false; + for (int i = 0; i < possibleKeys.size(); ++i) { + if (possibleKeys.at(i) - nextKey == int(e->modifiers()) + || (possibleKeys.at(i) == nextKey && e->modifiers() == Qt::ShiftModifier)) { + nextKey = possibleKeys.at(i); + found = true; + break; + } + } + // Use as fallback + if (!found) + nextKey = possibleKeys.first(); + } else { + nextKey |= d->translateModifiers(e->modifiers(), e->text()); + } + d->key[d->keyNum] = nextKey; d->keyNum++; |