diff options
| author | Ismael Asensio <[email protected]> | 2019-10-20 11:51:59 +0200 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2019-10-20 11:51:59 +0200 |
| commit | c540b4eef12d8251e25c608cd2c04fca724afa6f (patch) | |
| tree | 7268b0e3bff51878118f4d1e17ecbe81828b59a1 /src/search | |
| parent | 167d5184eda19f8ce549d6a645c800ab39bce936 (diff) | |
[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
Diffstat (limited to 'src/search')
| -rw-r--r-- | src/search/dolphinfacetswidget.cpp | 19 | ||||
| -rw-r--r-- | src/search/dolphinfacetswidget.h | 6 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.cpp | 2 |
3 files changed, 24 insertions, 3 deletions
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 <QButtonGroup> #include <QCheckBox> #include <QDate> +#include <QEvent> #include <QHBoxLayout> #include <QRadioButton> @@ -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; diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h index 1e8ab6cea..9d875f0ae 100644 --- a/src/search/dolphinfacetswidget.h +++ b/src/search/dolphinfacetswidget.h @@ -24,6 +24,7 @@ class QButtonGroup; class QDate; +class QEvent; class QRadioButton; /** @@ -50,6 +51,8 @@ public: explicit DolphinFacetsWidget(QWidget* parent = nullptr); ~DolphinFacetsWidget() override; + void resetOptions(); + QString ratingTerm() const; QString facetType() const; @@ -61,6 +64,9 @@ public: signals: void facetChanged(); +protected: + void changeEvent(QEvent* event) override; + private: void setRating(const int stars); void setTimespan(const QDate& date); diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 5bcd6be6a..1b791c60a 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -526,6 +526,8 @@ void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url) setSearchPath(QUrl::fromLocalFile(QDir::homePath())); } + m_facetsWidget->resetOptions(); + setText(query.searchString()); QStringList types = query.types(); |
