┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/search')
-rw-r--r--src/search/selectors/dateselector.cpp7
-rw-r--r--src/search/selectors/filetypeselector.cpp5
-rw-r--r--src/search/selectors/minimumratingselector.cpp5
-rw-r--r--src/search/selectors/tagsselector.cpp12
4 files changed, 26 insertions, 3 deletions
diff --git a/src/search/selectors/dateselector.cpp b/src/search/selectors/dateselector.cpp
index 70e563614..a7f4463e5 100644
--- a/src/search/selectors/dateselector.cpp
+++ b/src/search/selectors/dateselector.cpp
@@ -6,6 +6,7 @@
#include "dateselector.h"
+#include "../chip.h"
#include "../dolphinquery.h"
#include <KDatePicker>
@@ -19,7 +20,11 @@ Search::DateSelector::DateSelector(std::shared_ptr<const DolphinQuery> dolphinQu
: QToolButton{parent}
, UpdatableStateInterface{dolphinQuery}
, m_datePickerPopup{
- new KDatePickerPopup{KDatePickerPopup::NoDate | KDatePickerPopup::DatePicker | KDatePickerPopup::Words, dolphinQuery->modifiedSinceDate(), this}}
+ new KDatePickerPopup{/* When in a Chip, we don't add the KDatePickerPopup::NoDate option because it would allow removing the Chip unexpectedly. */
+ qobject_cast<ChipBase *>(parent) ? KDatePickerPopup::DatePicker | KDatePickerPopup::Words
+ : KDatePickerPopup::NoDate | KDatePickerPopup::DatePicker | KDatePickerPopup::Words,
+ dolphinQuery->modifiedSinceDate(),
+ this}}
{
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
setPopupMode(QToolButton::InstantPopup);
diff --git a/src/search/selectors/filetypeselector.cpp b/src/search/selectors/filetypeselector.cpp
index acf5680e2..6c5bbc5d7 100644
--- a/src/search/selectors/filetypeselector.cpp
+++ b/src/search/selectors/filetypeselector.cpp
@@ -6,6 +6,7 @@
#include "filetypeselector.h"
+#include "../chip.h"
#include "../dolphinquery.h"
#include <KFileMetaData/TypeInfo>
@@ -20,7 +21,9 @@ FileTypeSelector::FileTypeSelector(std::shared_ptr<const DolphinQuery> dolphinQu
for (KFileMetaData::Type::Type type = KFileMetaData::Type::FirstType; type <= KFileMetaData::Type::LastType; type = KFileMetaData::Type::Type(type + 1)) {
switch (type) {
case KFileMetaData::Type::Empty:
- addItem(/** No icon for the empty state */ i18nc("@item:inlistbox", "Any Type"), type);
+ if (!qobject_cast<ChipBase *>(parent)) { // When in a Chip, we don't add the "Any Type" option because it would unexpectedly remove the Chip.
+ addItem(/* No icon for the empty state */ i18nc("@item:inlistbox", "Any Type"), type);
+ }
continue;
case KFileMetaData::Type::Archive:
addItem(QIcon::fromTheme(QStringLiteral("package-x-generic")), KFileMetaData::TypeInfo{type}.displayName(), type);
diff --git a/src/search/selectors/minimumratingselector.cpp b/src/search/selectors/minimumratingselector.cpp
index 386f525db..b41561f6a 100644
--- a/src/search/selectors/minimumratingselector.cpp
+++ b/src/search/selectors/minimumratingselector.cpp
@@ -7,6 +7,7 @@
#include "minimumratingselector.h"
+#include "../chip.h"
#include "../dolphinquery.h"
#include <KLocalizedString>
@@ -17,7 +18,9 @@ MinimumRatingSelector::MinimumRatingSelector(std::shared_ptr<const DolphinQuery>
: QComboBox{parent}
, UpdatableStateInterface{dolphinQuery}
{
- addItem(/** No icon for the empty state */ i18nc("@item:inlistbox", "Any Rating"), 0);
+ if (!qobject_cast<ChipBase *>(parent)) { // When in a Chip, we don't add the "Any Rating" option because it would unexpectedly remove the Chip.
+ addItem(/* No icon for the empty state */ i18nc("@item:inlistbox", "Any Rating"), 0);
+ }
addItem(QIcon::fromTheme(QStringLiteral("starred-symbolic")), i18nc("@item:inlistbox", "1 or more"), 2);
addItem(QIcon::fromTheme(QStringLiteral("starred-symbolic")), i18nc("@item:inlistbox", "2 or more"), 4);
addItem(QIcon::fromTheme(QStringLiteral("starred-symbolic")), i18nc("@item:inlistbox", "3 or more"), 6);
diff --git a/src/search/selectors/tagsselector.cpp b/src/search/selectors/tagsselector.cpp
index 6ad74af91..57ce02e2f 100644
--- a/src/search/selectors/tagsselector.cpp
+++ b/src/search/selectors/tagsselector.cpp
@@ -7,6 +7,7 @@
#include "tagsselector.h"
+#include "../chip.h"
#include "../dolphinquery.h"
#include <KCoreDirLister>
@@ -146,6 +147,9 @@ void TagsSelector::updateMenu(const std::shared_ptr<const DolphinQuery> &dolphin
QAction *tagAction = new QAction{QIcon::fromTheme(QStringLiteral("tag")), tag, menu()};
tagAction->setCheckable(true);
tagAction->setChecked(dolphinQuery->requiredTags().contains(tag));
+ tagAction->setEnabled(/* When in a Chip, at least one tags needs to stay checked or the Chip will unexepectedly remove itself. */
+ !tagAction->isChecked() || dolphinQuery->requiredTags().size() != 1 || !qobject_cast<ChipBase *>(parent()));
+
connect(tagAction, &QAction::triggered, this, [this, tag, onlyOneTagExists](bool checked) {
QStringList requiredTags = m_searchConfiguration->requiredTags();
if (checked == requiredTags.contains(tag)) {
@@ -160,11 +164,19 @@ void TagsSelector::updateMenu(const std::shared_ptr<const DolphinQuery> &dolphin
searchConfigurationCopy.setRequiredTags(requiredTags);
Q_EMIT configurationChanged(searchConfigurationCopy);
+ if (qobject_cast<ChipBase *>(parent())) {
+ auto tagActions = menu()->actions();
+ for (auto tagAction : tagActions) {
+ tagAction->setEnabled(/* When in a Chip, at least one tags needs to stay checked or the Chip will unexepectedly remove itself. */
+ !tagAction->isChecked() || searchConfigurationCopy.requiredTags().size() != 1);
+ }
+ }
if (!onlyOneTagExists) {
// Keep the menu open to allow easier tag multi-selection.
menu()->show();
}
});
+
menu()->addAction(tagAction);
}
if (menuWasVisible) {