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
This commit is contained in:
Martchus 2020-06-16 00:16:52 +02:00
parent ee9ec87386
commit 106ac4c57e
2 changed files with 5 additions and 1 deletions

View File

@ -324,7 +324,7 @@ void ButtonOverlay::fallbackToUsingCustomLayout()
QPixmap infoPixmap;
QString infoText;
QList<QAction *> 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

View File

@ -27,6 +27,7 @@ ClearComboBox::ClearComboBox(QWidget *parent)
: QComboBox(parent)
, ButtonOverlay(this, getComboBoxLineEdit(this))
{
ButtonOverlay::setClearButtonEnabled(true);
}
/*!