From 106ac4c57e66f792a6d561785cb1a1a60c9ef687 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 16 Jun 2020 00:16:52 +0200 Subject: [PATCH] Improve behavior of ButtonOverlay * Remove all existing actions when falling back to using a custom layout to prevent duplicating those buttons * Enable clear button of ClearComboBox by default for consistency with other widgets --- widgets/buttonoverlay.cpp | 5 ++++- widgets/clearcombobox.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/widgets/buttonoverlay.cpp b/widgets/buttonoverlay.cpp index 723f6b5..22abfa6 100644 --- a/widgets/buttonoverlay.cpp +++ b/widgets/buttonoverlay.cpp @@ -324,7 +324,7 @@ void ButtonOverlay::fallbackToUsingCustomLayout() QPixmap infoPixmap; QString infoText; QList actions; - if (auto const *le = lineEditForWidget()) { + if (auto *const le = lineEditForWidget()) { if ((clearButtonEnabled = le->isClearButtonEnabled())) { setClearButtonEnabled(false); } @@ -336,6 +336,9 @@ void ButtonOverlay::fallbackToUsingCustomLayout() disableInfoButton(); } actions = le->actions(); + for (auto *const action : actions) { + le->removeAction(action); + } } // initialize custom layout diff --git a/widgets/clearcombobox.cpp b/widgets/clearcombobox.cpp index a06354e..6a4efe6 100644 --- a/widgets/clearcombobox.cpp +++ b/widgets/clearcombobox.cpp @@ -27,6 +27,7 @@ ClearComboBox::ClearComboBox(QWidget *parent) : QComboBox(parent) , ButtonOverlay(this, getComboBoxLineEdit(this)) { + ButtonOverlay::setClearButtonEnabled(true); } /*!