From c540b4eef12d8251e25c608cd2c04fca724afa6f Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Sun, 20 Oct 2019 11:51:59 +0200 Subject: [dolphin/search] Reset search options when needed Summary: Adds a method to reset the options in `facetsWidget` in two cases: when disabled and before parsing a new search URL. Otherwise, controls for a parameter (ex. `rating`) which are not found in the new URL would stay on the old positions, instead of the default "any". See D24422 Test Plan: Controls on `facetsWidget` go back to the default in such two cases. Reviewers: #dolphin, elvisangelaccio, meven, ngraham Reviewed By: ngraham Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D24450 --- src/search/dolphinfacetswidget.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/search/dolphinfacetswidget.cpp') diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp index 35f0c67c1..08fe567b1 100644 --- a/src/search/dolphinfacetswidget.cpp +++ b/src/search/dolphinfacetswidget.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -106,15 +107,27 @@ DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) : topLayout->addLayout(ratingLayout); topLayout->addStretch(); - m_anyType->setChecked(true); - m_anytime->setChecked(true); - m_anyRating->setChecked(true); + resetOptions(); } DolphinFacetsWidget::~DolphinFacetsWidget() { } +void DolphinFacetsWidget::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::EnabledChange && !isEnabled()) { + resetOptions(); + } +} + +void DolphinFacetsWidget::resetOptions() +{ + m_anyType->setChecked(true); + m_anytime->setChecked(true); + m_anyRating->setChecked(true); +} + QString DolphinFacetsWidget::ratingTerm() const { QStringList terms; -- cgit v1.3