]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[search] Close tags menu after click when there is only one tag
authorIsmael Asensio <isma.af@gmail.com>
Fri, 31 Jul 2020 21:59:21 +0000 (23:59 +0200)
committerIsmael Asensio <isma.af@gmail.com>
Tue, 4 Aug 2020 20:34:05 +0000 (22:34 +0200)
It stays open otherwise to allow checking/unchecking several tags at a time

BUG: 424873
FIXED-IN: 20.08

src/search/dolphinfacetswidget.cpp

index d9943abcd4867ea425629fc6b9bb74710b4f2a49..8bae8388789882b95044374b29d9aec1785a0bc1 100644 (file)
@@ -272,12 +272,14 @@ void DolphinFacetsWidget::updateTagsMenuItems(const QUrl&, const KFileItemList&
     allTags.sort(Qt::CaseInsensitive);
     allTags.removeDuplicates();
 
     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));
 
     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 {
             if (isChecked) {
                 addSearchTag(tagName);
             } else {
@@ -285,7 +287,9 @@ void DolphinFacetsWidget::updateTagsMenuItems(const QUrl&, const KFileItemList&
             }
             emit facetChanged();
 
             }
             emit facetChanged();
 
-            m_tagsSelector->menu()->show();
+            if (!onlyOneTag) {
+                m_tagsSelector->menu()->show();
+            }
         });
     }
 
         });
     }