10#include <private/qkeymapper_p.h>
82 emit q->editingFinished();
148 return d->keySequence;
166 d->lineEdit->setClearButtonEnabled(
enable);
173 return d->lineEdit->isClearButtonEnabled();
188 return d->maximumSequenceLength;
196 qWarning(
"QKeySequenceEdit: maximumSequenceLength %lld is out of range (1..%d)",
200 d->maximumSequenceLength = int(
count);
205 d->rebuildKeySequence();
231 return d->finishingKeyCombinations;
244 if (desiredCount >
d->maximumSequenceLength) {
245 qWarning(
"QKeySequenceEdit: setting a key sequence of length %d "
246 "when maximumSequenceLength is %d, truncating.",
247 desiredCount,
d->maximumSequenceLength);
250 d->keyNum = std::min(desiredCount,
d->maximumSequenceLength);
251 for (
int i = 0;
i <
d->keyNum; ++
i)
256 d->rebuildKeySequence();
295 if (!
d->finishingKeyCombinations.contains(ke->keyCombination())) {
320 int nextKey = e->
key();
322 if (
d->prevKey == -1) {
324 d->prevKey = nextKey;
327 d->lineEdit->setPlaceholderText(
QString());
336 QString selectedText =
d->lineEdit->selectedText();
337 if (!selectedText.
isEmpty() && selectedText ==
d->lineEdit->text()) {
343 if (
d->keyNum >=
d->maximumSequenceLength)
348 int pkTotal = possibleKeys.size();
352 for (
int i = 0;
i < possibleKeys.size(); ++
i) {
353 const int key = possibleKeys.at(
i).toCombined();
363 nextKey = possibleKeys.first().toCombined();
372 d->rebuildKeySequence();
374 if (
d->keyNum <
d->maximumSequenceLength) {
378 d->lineEdit->setText(
text);
389 if (
d->prevKey == e->
key()) {
390 if (
d->keyNum <
d->maximumSequenceLength)
404 if (e->
timerId() ==
d->releaseTimer) {
425#include "moc_qkeysequenceedit.cpp"
Type type() const
Returns the event type.
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QFocusEvent class contains event parameters for widget focus events.
Qt::FocusReason reason() const
Returns the reason for this focus event.
static constexpr QKeyCombination fromCombined(int combined)
The QKeyEvent class describes a key event.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
QString text() const
Returns the Unicode text that this key generated.
int key() const
Returns the code of the key that was pressed or released.
QKeyCombination keyCombination() const
Returns a QKeyCombination object containing both the key() and the modifiers() carried by this event.
static QList< QKeyCombination > possibleKeys(const QKeyEvent *e)
QList< QKeyCombination > finishingKeyCombinations
int translateModifiers(Qt::KeyboardModifiers state, const QString &text)
The QKeySequenceEdit widget allows to input a QKeySequence.
void keyPressEvent(QKeyEvent *) override
\reimp
void timerEvent(QTimerEvent *) override
\reimp
bool isClearButtonEnabled() const
bool event(QEvent *) override
\reimp
void setMaximumSequenceLength(qsizetype count)
QKeySequenceEdit(QWidget *parent=nullptr)
Constructs a QKeySequenceEdit widget with the given parent.
void focusOutEvent(QFocusEvent *) override
\reimp
void keyReleaseEvent(QKeyEvent *) override
\reimp
void setClearButtonEnabled(bool enable)
void keySequenceChanged(const QKeySequence &keySequence)
void setKeySequence(const QKeySequence &keySequence)
qsizetype maximumSequenceLength
The maximum sequence length.
void clear()
Clears the current key sequence.
QKeySequence keySequence
This property contains the currently chosen key sequence.
void setFinishingKeyCombinations(const QList< QKeyCombination > &finishingKeyCombinations)
QList< QKeyCombination > finishingKeyCombinations
The list of key combinations that finish editing the key sequences.
~QKeySequenceEdit()
Destroys the QKeySequenceEdit object.
static constexpr int MaxKeyCount
The QKeySequence class encapsulates a key sequence as used by shortcuts.
int count() const
Returns the number of keys in the key sequence.
QString toString(SequenceFormat format=PortableText) const
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
void setContentsMargins(int left, int top, int right, int bottom)
The QLineEdit widget is a one-line text editor.
void setClearButtonEnabled(bool enable)
void clear()
Clears the contents of the line edit.
void setPlaceholderText(const QString &)
void textChanged(const QString &)
This signal is emitted whenever the text changes.
void setText(const QString &)
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
The QVBoxLayout class lines up widgets vertically.
Combined button and popup list for selecting options.
GLenum GLenum GLsizei count
GLdouble GLdouble GLdouble GLdouble q
#define QStringLiteral(str)