]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinfacetswidget.cpp
Fix i18n
[dolphin.git] / src / search / dolphinfacetswidget.cpp
index 34719730bee88866b2bcf621175f95434e4069a5..8bae8388789882b95044374b29d9aec1785a0bc1 100644 (file)
@@ -131,7 +131,11 @@ QStringList DolphinFacetsWidget::searchTerms() const
 
     if (!m_searchTags.isEmpty()) {
         for (auto const &tag : m_searchTags) {
-            terms << QStringLiteral("tag:%1").arg(tag);
+            if (tag.contains(QLatin1Char(' '))) {
+                terms << QStringLiteral("tag:\"%1\"").arg(tag);
+            } else {
+                terms << QStringLiteral("tag:%1").arg(tag);
+            }
         }
     }
 
@@ -268,18 +272,24 @@ void DolphinFacetsWidget::updateTagsMenuItems(const QUrl&, const KFileItemList&
     allTags.sort(Qt::CaseInsensitive);
     allTags.removeDuplicates();
 
+    const bool onlyOneTag = allTags.count() == 1;
+
     for (const QString& tagName : qAsConst(allTags)) {
         QAction* action = m_tagsSelector->menu()->addAction(QIcon::fromTheme(QStringLiteral("tag")), tagName);
         action->setCheckable(true);
         action->setChecked(m_searchTags.contains(tagName));
 
-        connect(action, &QAction::triggered, this, [this, tagName](bool isChecked) {
+        connect(action, &QAction::triggered, this, [this, tagName, onlyOneTag](bool isChecked) {
             if (isChecked) {
                 addSearchTag(tagName);
             } else {
                 removeSearchTag(tagName);
             }
             emit facetChanged();
+
+            if (!onlyOneTag) {
+                m_tagsSelector->menu()->show();
+            }
         });
     }