diff options
Diffstat (limited to 'src/widgets/widgets/qkeysequenceedit.cpp')
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 565ea08001..65ed7a465a 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -20,7 +20,7 @@ void QKeySequenceEditPrivate::init() lineEdit = new QLineEdit(q); lineEdit->setObjectName(QStringLiteral("qt_keysequenceedit_lineedit")); lineEdit->setClearButtonEnabled(false); - q->connect(lineEdit, &QLineEdit::textChanged, [q](const QString& text) { + q->connect(lineEdit, &QLineEdit::textChanged, q, [q](const QString& text) { // Clear the shortcut if the user clicked on the clear icon if (text.isEmpty()) q->clear(); @@ -177,12 +177,8 @@ bool QKeySequenceEdit::isClearButtonEnabled() const \property QKeySequenceEdit::maximumSequenceLength \brief The maximum sequence length. - The value is clamped to [1-4] inclusive, i.e. the maximum value of the - maximum sequence length is 4 driven by QKeySequence. The minimum value is - 1, which can be useful for single sequence, like a typical shortcut. - - The QKeySequence stored in QKeySequenceEdit is truncated if longer than the - value of this property. + The maximum number of key sequences a user can enter. The value needs to + be between 1 and 4, with 4 being the default. \since 6.5 */ @@ -348,22 +344,23 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) return; if (e->modifiers() & Qt::ShiftModifier) { - QList<int> possibleKeys = QKeyMapper::possibleKeys(e); - int pkTotal = possibleKeys.count(); + const QList<QKeyCombination> possibleKeys = QKeyMapper::possibleKeys(e); + int pkTotal = possibleKeys.size(); 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); + const int key = possibleKeys.at(i).toCombined(); + if (key - nextKey == int(e->modifiers()) + || (key == nextKey && e->modifiers() == Qt::ShiftModifier)) { + nextKey = key; found = true; break; } } // Use as fallback if (!found) - nextKey = possibleKeys.first(); + nextKey = possibleKeys.first().toCombined(); } else { nextKey |= d->translateModifiers(e->modifiers(), e->text()); } @@ -418,7 +415,8 @@ void QKeySequenceEdit::timerEvent(QTimerEvent *e) void QKeySequenceEdit::focusOutEvent(QFocusEvent *e) { Q_D(QKeySequenceEdit); - d->finishEditing(); + if (e->reason() != Qt::PopupFocusReason) + d->finishEditing(); QWidget::focusOutEvent(e); } |