summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qkeysequenceedit.h
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2022-05-07 09:55:31 +0100
committerLaszlo Papp <laszlo.papp@foundry.com>2022-05-11 15:56:55 +0100
commitd9be9fedfb15c3eca69adedf9e2e95c0df9643e7 (patch)
tree388c98182ffe9a18461ae6ce9caa3e7ab75bf7b5 /src/widgets/widgets/qkeysequenceedit.h
parent4872392925b5d4df3e307b71a9a575b7d26e4c7e (diff)
Add a clear action to QKeySequenceEdit
This can be really helpful for deleting shortcuts that one may never intend to use so that they do not accidentally get in the way while interacting with the user interface. The workaround is to try to find the QLineEdit child of the QKeySequenceEdit widget, but it is suboptimal. Some first-class citizen API for this would be a more stable and cleaner solution as opposed to poking implementation details as a user of the QKeySequenceEdit API. The clear action would be configurable and opt-in as not everyone may potentially want this to be turned on. Or at least, not by default anyway. Also, not to suddenly change existing QKeySequenceEdit uses with surprising UI changes after a Qt upgrade, this needs to be opt-in. Moreover, some customers may have already used findChild<QLineEdit *>() to add actions to QKeySequenceEdit in this way on the client side. So, if it was enabled by default, they would suddenly get multiple actions potentially for the same clear action. This would be certainly undesirable. The new clear property is based on the corresponding QLineEdit API for consistency. [ChangeLog][QtWidgets][QKeySequenceEdit] Added a clear action to QKeySequenceEdit to be able to remove existing hotkey configurations. Change-Id: I3a90bfacd49bff10c1284abb155d7edd4f537900 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qkeysequenceedit.h')
-rw-r--r--src/widgets/widgets/qkeysequenceedit.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h
index 999b400963..f0dea69ae3 100644
--- a/src/widgets/widgets/qkeysequenceedit.h
+++ b/src/widgets/widgets/qkeysequenceedit.h
@@ -54,6 +54,7 @@ class Q_WIDGETS_EXPORT QKeySequenceEdit : public QWidget
Q_OBJECT
Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence
NOTIFY keySequenceChanged USER true)
+ Q_PROPERTY(bool clearButtonEnabled READ isClearButtonEnabled WRITE setClearButtonEnabled)
public:
explicit QKeySequenceEdit(QWidget *parent = nullptr);
@@ -62,6 +63,9 @@ public:
QKeySequence keySequence() const;
+ void setClearButtonEnabled(bool enable);
+ bool isClearButtonEnabled() const;
+
public Q_SLOTS:
void setKeySequence(const QKeySequence &keySequence);
void clear();