diff --git a/plugins/itemtags/itemtags.cpp b/plugins/itemtags/itemtags.cpp index c809ea910..fe2a2f4c7 100644 --- a/plugins/itemtags/itemtags.cpp +++ b/plugins/itemtags/itemtags.cpp @@ -168,16 +168,10 @@ void addTagCommands(const QString &tagName, const QString &match, QVectorappend(c); - - c = dummyTagCommand(); - c.internalId = QStringLiteral("copyq_tags_untag:") + name; - c.name = ItemTagsLoader::tr("Remove tag %1").arg(quotedTag); - c.matchCmd = "copyq: plugins.itemtags.hasTag(" + tagString + ") || fail()"; - c.cmd = "copyq: plugins.itemtags.untag(" + tagString + ")"; + c.name = ItemTagsLoader::tr("Toggle Tag %1").arg(quotedTag); + c.cmd = QStringLiteral( + "copyq: (plugins.itemtags.hasTag(%1) ? plugins.itemtags.untag : plugins.itemtags.tag)(%1)" + ).arg(tagString); commands->append(c); } @@ -747,8 +741,14 @@ QVector ItemTagsLoader::commands() const if (m_tags.isEmpty()) { addTagCommands(tr("Important", "Tag name for example command"), QString(), &commands); } else { - for (const auto &tag : m_tags) + const QRegularExpression reCapture(R"(\(.*\))"); + const QRegularExpression reGroup(R"(\\\d)"); + for (const auto &tag : m_tags) { + if ( reCapture.match(tag.match).hasMatch() && reGroup.match(tag.name).hasMatch() ) + continue; + addTagCommands(tag.name, tag.match, &commands); + } } Command c;