From 9f34092aa9e1af50ed2e6f7b68aff8ecf2ef1eb1 Mon Sep 17 00:00:00 2001 From: Christoph Wolk Date: Fri, 2 Aug 2024 00:24:13 +0200 Subject: [PATCH] plugins/runcommand: make config dialog HIG-compliant The HIG recommend that buttons with an action label that require further user input end in an ellipsis, and that dialog buttons should clearly indicate what they do. Button labels typically do not match the given exceptions that license sentence case. Currently, the main "Add command" button in the configuration button does not end in an ellipsis even though it opens a dialog, is sentence case, and the dialog has a "Save" rather than the customary "Add" that is used for these kinds of actions, in particular in kcms. The dialog title is also not translatable. This change adds the ellipsis, converts the button to title case, makes the dialog title translatable, and adds an "Add" button as an action to the dialog. --- .../kdeconnect_runcommand_config.qml | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/plugins/runcommand/kdeconnect_runcommand_config.qml b/plugins/runcommand/kdeconnect_runcommand_config.qml index f77fc2baf..e6715375f 100644 --- a/plugins/runcommand/kdeconnect_runcommand_config.qml +++ b/plugins/runcommand/kdeconnect_runcommand_config.qml @@ -22,7 +22,7 @@ ListView { property var action: Kirigami.Action { icon.name: "list-add" - text: i18n("Add command") + text: i18n("Add Command…") onTriggered: addDialog.open() } @@ -58,11 +58,27 @@ ListView { Kirigami.Dialog { id: addDialog - title: "Add command" + title: i18nc("@title:window", "Add Command") - standardButtons: QQC2.Dialog.Save | QQC2.Dialog.Cancel padding: Kirigami.Units.largeSpacing + property Kirigami.Action addCommandAction: Kirigami.Action { + text: i18nc("@action:button", "Add") + icon.name: "list-add" + enabled: commandField.length > 0 + onTriggered: { + commandModel.addCommand(nameField.text, commandField.text) + addDialog.close(); + } + Component.onCompleted: { + // TODO: can be set directly once Qt 6.8 is required + Accessible.Name = i18nc("@action:button accessible", "Add command") + } + } + + standardButtons: Kirigami.Dialog.Cancel + customFooterActions: [addCommandAction] + Kirigami.FormLayout { QQC2.TextField { id: nameField @@ -115,7 +131,5 @@ ListView { } } } - - onAccepted: commandModel.addCommand(nameField.text, commandField.text) } }