diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-18 12:02:07 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-05-18 12:36:44 +0000 |
commit | 20d5f8461f36596723fa324a12a4d7ad4ea679c6 (patch) | |
tree | 6efb3be90cdbcf77ab4bdadc12aa413dbe502246 /src/widgets | |
parent | 1ad456c908467212bc30223a69eb7524b64b86e1 (diff) |
QKeySequenceEdit: Extract Method Private::rebuildKeySequence()
Factor the construction of Private::keySequence from Private::key into
a helper function, as we'll need this functionality in more places
when we add a maxKeyCount property to the class.
Change-Id: I6b08a619c3b6b2a9ff660e9f51b02632c2359a47
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit_p.h | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index a2239f8c16..3dafb9396b 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -283,9 +283,8 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) d->key[d->keyNum] = QKeyCombination::fromCombined(nextKey); d->keyNum++; - QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]); - d->keySequence = key; - QString text = key.toString(QKeySequence::NativeText); + d->rebuildKeySequence(); + QString text = d->keySequence.toString(QKeySequence::NativeText); if (d->keyNum < QKeySequencePrivate::MaxKeyCount) { //: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..." text = tr("%1, ...").arg(text); diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h index 0ef664a21d..eaaaf63e8a 100644 --- a/src/widgets/widgets/qkeysequenceedit_p.h +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -36,6 +36,8 @@ public: int translateModifiers(Qt::KeyboardModifiers state, const QString &text); void resetState(); void finishEditing(); + void rebuildKeySequence() + { keySequence = QKeySequence(key[0], key[1], key[2], key[3]); } QLineEdit *lineEdit; QKeySequence keySequence; |