Add clear button to MultiKeyEdit
This commit is contained in:
parent
bb6786f24e
commit
300a41c149
2 changed files with 12 additions and 0 deletions
|
@ -23,6 +23,8 @@ public:
|
||||||
bool removeOne(const QKeySequence &keySequence);
|
bool removeOne(const QKeySequence &keySequence);
|
||||||
bool contains(const QKeySequence &keySequence) const;
|
bool contains(const QKeySequence &keySequence) const;
|
||||||
void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
|
void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
|
||||||
|
bool isClearButtonEnabled() const;
|
||||||
|
void setClearButtonEnabled(bool enable);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -98,6 +98,15 @@ void MultiKeyEdit::setContextMenuPolicy(Qt::ContextMenuPolicy policy) {
|
||||||
lineEdit->setContextMenuPolicy(policy);
|
lineEdit->setContextMenuPolicy(policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MultiKeyEdit::isClearButtonEnabled() const {
|
||||||
|
return findChild<QLineEdit *>()->isClearButtonEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiKeyEdit::setClearButtonEnabled(bool enable) {
|
||||||
|
for (auto *lineEdit : findChildren<QLineEdit *>())
|
||||||
|
lineEdit->setClearButtonEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void MultiKeyEdit::clear() {
|
void MultiKeyEdit::clear() {
|
||||||
for (auto *keySequenceEdit : keySequenceEdit_vec)
|
for (auto *keySequenceEdit : keySequenceEdit_vec)
|
||||||
keySequenceEdit->clear();
|
keySequenceEdit->clear();
|
||||||
|
@ -126,6 +135,7 @@ void MultiKeyEdit::addNewKeySequenceEdit() {
|
||||||
this, &MultiKeyEdit::keySequenceChanged);
|
this, &MultiKeyEdit::keySequenceChanged);
|
||||||
|
|
||||||
auto *lineEdit = keySequenceEdit->findChild<QLineEdit *>();
|
auto *lineEdit = keySequenceEdit->findChild<QLineEdit *>();
|
||||||
|
lineEdit->setClearButtonEnabled(true);
|
||||||
lineEdit->installEventFilter(this);
|
lineEdit->installEventFilter(this);
|
||||||
connect(lineEdit, &QLineEdit::customContextMenuRequested,
|
connect(lineEdit, &QLineEdit::customContextMenuRequested,
|
||||||
this, &MultiKeyEdit::customContextMenuRequested);
|
this, &MultiKeyEdit::customContextMenuRequested);
|
||||||
|
|
Loading…
Reference in a new issue