[graphics/krita] plugins/extensions/resourcemanager: Ask user on adding a tag with the same url in WdgTagSel

Agata Cacko null at kde.org
Fri Aug 6 15:20:56 BST 2021


Git commit d898609078e53f34396fc49c3a8f1314691564ef by Agata Cacko.
Committed on 06/08/2021 at 14:17.
Pushed by tymond into branch 'master'.

Ask user on adding a tag with the same url in WdgTagSel

Before this commit, if the user tried to create a new tag
with the same url as an existing tag,
it would undelete the deleted tag, which means the assigned
resources would still be assigned.
This commit instead asks the user what they want to achieve,
and there are three options:
* Replace (overwrite) - this will reset assigned resources
* Undelete - this will cancel adding the tag and just
undelete the existing, deleted tag with all the assigned
resources it had before
* Cancel - no operation

Note that this will only happen if the tag is not active
(if it's deleted). If it's not, Krita will just use that
tag and tag the resource.

CCMAIL:kde-i18n-doc at kde.org

M  +15   -2    plugins/extensions/resourcemanager/wdgtagselection.cpp

https://invent.kde.org/graphics/krita/commit/d898609078e53f34396fc49c3a8f1314691564ef

diff --git a/plugins/extensions/resourcemanager/wdgtagselection.cpp b/plugins/extensions/resourcemanager/wdgtagselection.cpp
index 4666a55b04..de2f656a31 100644
--- a/plugins/extensions/resourcemanager/wdgtagselection.cpp
+++ b/plugins/extensions/resourcemanager/wdgtagselection.cpp
@@ -108,8 +108,21 @@ void KisWdgTagSelectionControllerOneResource::slotCreateNewTag(QString tag)
         QVector<KoResourceSP> vec;
         m_tagModel->addTag(tag, false, vec);
         tagsp = m_tagModel->tagForUrl(tag);
-    } else if (!tagsp->active()) {
-        m_tagModel->setTagActive(tagsp);
+    } else if (!tagsp->active()) { // if tag is active, simply use that tag
+        // if you use this simple cast, the order of buttons must match order of options in the enum
+        int response = QMessageBox::question(0, i18nc("Dialog title", "Overwrite tag?"), i18nc("Question to the user in a dialog about creating a tag",
+                                                                                          "A tag with this unique name already exists. Do you want to replace it?"),
+                                           i18nc("Option in a dialog to discard the previously existing tag and creating a new one in its place", "Replace (overwrite) tag"),
+                                           i18nc("Option in a dialog to undelete (reactivate) existing tag with its old assigned resources", "Restore previous tag"), i18n("Cancel"));
+        if (response == 0) { // Overwrite
+            m_tagModel->addTag(tag, true, QVector<KoResourceSP>()); // will overwrite the tag
+            tagsp = m_tagModel->tagForUrl(tag);
+        } else if (response == 1) { // Restore/use previously existing one
+            m_tagModel->setTagActive(tagsp);
+        } else {
+            updateView();
+            return;
+        }
     }
 
     KIS_ASSERT_RECOVER_RETURN(tagsp);



More information about the kde-i18n-doc mailing list