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>
This commit is contained in:
parent
1ad456c908
commit
20d5f8461f
src/widgets/widgets
@ -283,9 +283,8 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e)
|
|||||||
d->key[d->keyNum] = QKeyCombination::fromCombined(nextKey);
|
d->key[d->keyNum] = QKeyCombination::fromCombined(nextKey);
|
||||||
d->keyNum++;
|
d->keyNum++;
|
||||||
|
|
||||||
QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]);
|
d->rebuildKeySequence();
|
||||||
d->keySequence = key;
|
QString text = d->keySequence.toString(QKeySequence::NativeText);
|
||||||
QString text = key.toString(QKeySequence::NativeText);
|
|
||||||
if (d->keyNum < QKeySequencePrivate::MaxKeyCount) {
|
if (d->keyNum < QKeySequencePrivate::MaxKeyCount) {
|
||||||
//: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..."
|
//: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..."
|
||||||
text = tr("%1, ...").arg(text);
|
text = tr("%1, ...").arg(text);
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
|
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
|
||||||
void resetState();
|
void resetState();
|
||||||
void finishEditing();
|
void finishEditing();
|
||||||
|
void rebuildKeySequence()
|
||||||
|
{ keySequence = QKeySequence(key[0], key[1], key[2], key[3]); }
|
||||||
|
|
||||||
QLineEdit *lineEdit;
|
QLineEdit *lineEdit;
|
||||||
QKeySequence keySequence;
|
QKeySequence keySequence;
|
||||||
|
Loading…
Reference in New Issue
Block a user