[utilities/kdebugsettings] src/quickapps/qml: Allow to add rules

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 416f7850bf375e5e301f78f98dc9a2f8bda6a1c2 by Laurent Montel.
Committed on 22/07/2026 at 17:49.
Pushed by mlaurent into branch 'master'.

Allow to add rules

M  +7    -4    src/quickapps/qml/CustomRulesPage.qml
M  +10   -2    src/quickapps/qml/EditCustomRuleDialog.qml

https://invent.kde.org/utilities/kdebugsettings/-/commit/416f7850bf375e5e301f78f98dc9a2f8bda6a1c2

diff --git a/src/quickapps/qml/CustomRulesPage.qml b/src/quickapps/qml/CustomRulesPage.qml
index f3aa0871..045f4b72 100644
--- a/src/quickapps/qml/CustomRulesPage.qml
+++ b/src/quickapps/qml/CustomRulesPage.qml
@@ -32,6 +32,7 @@ Kirigami.ScrollablePage {
         model: LoggingManager.customLoggingCategoryProxyModel
         delegate: Delegates.RoundedItemDelegate {
             required property string displayRule
+            required property string categoryName
             required property int index
 
             text: displayRule
@@ -49,9 +50,10 @@ Kirigami.ScrollablePage {
                 icon.name: "list-add"
                 text: i18nc("@action add custom rule", "Add Rule…")
                 onTriggered: {
-                    console.debug("Not implemented yet");
+                    editCustomRuleDialog.editMode = false;
+                    editCustomRuleDialog.categoryName = "";
+
                     editCustomRuleDialog.open();
-                    // TODO
                 }
             }
             QQC2.MenuItem {
@@ -59,9 +61,10 @@ Kirigami.ScrollablePage {
                 icon.name: "document-edit"
                 text: i18nc("@action edit custom rule", "Edit Rule…")
                 onTriggered: {
-                    console.debug("Not implemented yet");
+                    const categoryName = listviewRules.currentItem ? listviewRules.currentItem.categoryName : "";
+                    editCustomRuleDialog.editMode = true;
+                    editCustomRuleDialog.categoryName = categoryName;
                     editCustomRuleDialog.open();
-                    // TODO
                 }
             }
             QQC2.MenuSeparator {
diff --git a/src/quickapps/qml/EditCustomRuleDialog.qml b/src/quickapps/qml/EditCustomRuleDialog.qml
index 790476ab..4c69e3ca 100644
--- a/src/quickapps/qml/EditCustomRuleDialog.qml
+++ b/src/quickapps/qml/EditCustomRuleDialog.qml
@@ -11,6 +11,10 @@ Kirigami.Dialog {
     title: i18n("Edit Custom Rule")
     clip: true
     showCloseButton: false
+    property alias categoryName: categoryNameField.text
+    property alias categoryEnabled: categoryEnabled.checked
+    property bool editMode: false
+
 
     standardButtons: QQC2.Dialog.Ok | QQC2.Dialog.Cancel
     RowLayout {
@@ -24,7 +28,7 @@ Kirigami.Dialog {
             text: i18n("Category:")
         }
         QQC2.TextField {
-            id: categoryName
+            id: categoryNameField
         }
         QQC2.Label {
             Layout.leftMargin: 4
@@ -43,6 +47,10 @@ Kirigami.Dialog {
         }
     }
     onAccepted: {
-        console.debug("Edit custom Not implemented yet");
+        if (!editMode) {
+            LoggingManager.customCategoryModel.addCategory(categoryNameField.text, categoryEnabled.checked, categoryType.currentValue);
+        } else {
+            console.debug("Edit custom Not implemented yet");
+        }
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.