diff --git a/include/ui/multikeyedit.h b/include/ui/multikeyedit.h index c1736280..27231330 100644 --- a/include/ui/multikeyedit.h +++ b/include/ui/multikeyedit.h @@ -23,6 +23,8 @@ public: bool removeOne(const QKeySequence &keySequence); bool contains(const QKeySequence &keySequence) const; void setContextMenuPolicy(Qt::ContextMenuPolicy policy); + bool isClearButtonEnabled() const; + void setClearButtonEnabled(bool enable); public slots: void clear(); diff --git a/src/ui/multikeyedit.cpp b/src/ui/multikeyedit.cpp index 34ac19c8..09943861 100644 --- a/src/ui/multikeyedit.cpp +++ b/src/ui/multikeyedit.cpp @@ -98,6 +98,15 @@ void MultiKeyEdit::setContextMenuPolicy(Qt::ContextMenuPolicy policy) { lineEdit->setContextMenuPolicy(policy); } +bool MultiKeyEdit::isClearButtonEnabled() const { + return findChild()->isClearButtonEnabled(); +} + +void MultiKeyEdit::setClearButtonEnabled(bool enable) { + for (auto *lineEdit : findChildren()) + lineEdit->setClearButtonEnabled(enable); +} + void MultiKeyEdit::clear() { for (auto *keySequenceEdit : keySequenceEdit_vec) keySequenceEdit->clear(); @@ -126,6 +135,7 @@ void MultiKeyEdit::addNewKeySequenceEdit() { this, &MultiKeyEdit::keySequenceChanged); auto *lineEdit = keySequenceEdit->findChild(); + lineEdit->setClearButtonEnabled(true); lineEdit->installEventFilter(this); connect(lineEdit, &QLineEdit::customContextMenuRequested, this, &MultiKeyEdit::customContextMenuRequested);