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();
315 if (
d->finishingKeyCombinations.contains(
e->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 if (possibleKeys.
at(
i) - nextKey ==
int(
e->modifiers())
355 nextKey = possibleKeys.
at(
i);
362 nextKey = possibleKeys.
first();
364 nextKey |=
d->translateModifiers(
e->modifiers(),
e->text());
371 d->rebuildKeySequence();
373 if (
d->keyNum <
d->maximumSequenceLength) {
377 d->lineEdit->setText(
text);
388 if (
d->prevKey ==
e->key()) {
389 if (
d->keyNum <
d->maximumSequenceLength)
403 if (
e->timerId() ==
d->releaseTimer) {
424#include "moc_qkeysequenceedit.cpp"
The QFocusEvent class contains event parameters for widget focus events.
static constexpr QKeyCombination fromCombined(int combined)
The QKeyEvent class describes a key event.
QKeyCombination keyCombination() const
Returns a QKeyCombination object containing both the key() and the modifiers() carried by this event.
static QList< int > possibleKeys(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.
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 setPlaceholderText(const QString &)
void textChanged(const QString &)
This signal is emitted whenever the text changes.
void setText(const QString &)
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
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
Returns true if the string has no characters; otherwise returns false.
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)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent