summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp18
-rw-r--r--src/widgets/widgets/qkeysequenceedit_p.h5
2 files changed, 8 insertions, 15 deletions
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp
index db39ceb08a..c056967cf7 100644
--- a/src/widgets/widgets/qkeysequenceedit.cpp
+++ b/src/widgets/widgets/qkeysequenceedit.cpp
@@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_KEYSEQUENCEEDIT
+Q_STATIC_ASSERT(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here
+
void QKeySequenceEditPrivate::init()
{
Q_Q(QKeySequenceEdit);
@@ -222,15 +224,7 @@ void QKeySequenceEdit::setKeySequence(const QKeySequence &keySequence)
*/
void QKeySequenceEdit::clear()
{
- Q_D(QKeySequenceEdit);
-
- d->resetState();
-
- d->lineEdit->clear();
- d->keySequence = QKeySequence();
- d->keyNum = d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0;
- d->prevKey = -1;
- emit keySequenceChanged(d->keySequence);
+ setKeySequence(QKeySequence());
}
/*!
@@ -280,7 +274,7 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e)
return;
}
- if (d->keyNum >= QKeySequenceEditPrivate::MaxKeyCount)
+ if (d->keyNum >= QKeySequencePrivate::MaxKeyCount)
return;
nextKey |= d->translateModifiers(e->modifiers(), e->text());
@@ -291,7 +285,7 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e)
QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]);
d->keySequence = key;
QString text = key.toString(QKeySequence::NativeText);
- if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) {
+ if (d->keyNum < QKeySequencePrivate::MaxKeyCount) {
//: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..."
text = tr("%1, ...").arg(text);
}
@@ -307,7 +301,7 @@ void QKeySequenceEdit::keyReleaseEvent(QKeyEvent *e)
Q_D(QKeySequenceEdit);
if (d->prevKey == e->key()) {
- if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount)
+ if (d->keyNum < QKeySequencePrivate::MaxKeyCount)
d->releaseTimer = startTimer(1000);
else
d->finishEditing();
diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h
index 58c9699059..f74433bb71 100644
--- a/src/widgets/widgets/qkeysequenceedit_p.h
+++ b/src/widgets/widgets/qkeysequenceedit_p.h
@@ -46,6 +46,7 @@
#include "qkeysequenceedit.h"
#include <private/qwidget_p.h>
+#include <private/qkeysequence_p.h>
QT_BEGIN_NAMESPACE
@@ -57,8 +58,6 @@ class QKeySequenceEditPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QKeySequenceEdit)
public:
- enum { MaxKeyCount = 4 };
-
void init();
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
void resetState();
@@ -67,7 +66,7 @@ public:
QLineEdit *lineEdit;
QKeySequence keySequence;
int keyNum;
- int key[MaxKeyCount];
+ int key[QKeySequencePrivate::MaxKeyCount];
int prevKey;
int releaseTimer;
};