1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
From 7327baf04bf9917fe11a1ffe407cf321b3d67cbd Mon Sep 17 00:00:00 2001
From: Ismael Asensio <isma.af@gmail.com>
Date: Fri, 21 Feb 2025 00:30:15 +0100
Subject: [PATCH] kcms/keyboard: Allow to edit the layout display name
The display name of the layouts can be customized, but in the UI it
was only possible to set it when adding a new one.
Expose the setting also in the layout list, in a non-intrussive way
by giving the appearance of a label, which can be edited when given
focus either by click or keyboard.
BUG: 500057
FIXED-IN: 6.4
---
kcms/keyboard/ui/LayoutDelegate.qml | 27 +++++++++++++++++++++++++++
kcms/keyboard/ui/main.qml | 2 ++
2 files changed, 29 insertions(+)
diff --git a/kcms/keyboard/ui/LayoutDelegate.qml b/kcms/keyboard/ui/LayoutDelegate.qml
index 2137ceaf6c..db7d8ae5ea 100644
--- a/kcms/keyboard/ui/LayoutDelegate.qml
+++ b/kcms/keyboard/ui/LayoutDelegate.qml
@@ -30,8 +30,10 @@ Item {
required property string variant
required property string variantName
required property string shortcut
+ required property string displayName
readonly property var view: ListView.view
+ readonly property int keySequenceItemWidth : keySequenceItem.implicitWidth
signal move(int oldIndex, int newIndex)
@@ -71,11 +73,36 @@ Item {
Layout.fillWidth: true
}
+ QQC2.TextField {
+ Layout.preferredWidth: Kirigami.Units.gridUnit * 3
+ maximumLength: 3
+ horizontalAlignment: Text.AlignHCenter
+ placeholderText: itemDelegate.layout
+ background.visible: activeFocus
+
+ text: itemDelegate.displayName
+ onTextEdited: {
+ // Immediate response except for "", which resets to default
+ if (text.length > 0) {
+ itemDelegate.model.displayName = text
+ }
+ }
+ onEditingFinished: itemDelegate.model.displayName = text
+ Keys.onEscapePressed: editingFinished()
+ }
+
+ // Spacer to align items to the left of the KeySequenceItem
+ Item {
+ Layout.preferredWidth: itemDelegate.view.maxKeySequenceItemWidth - keySequenceItem.implicitWidth
+ }
+
KQuickControls.KeySequenceItem {
+ id: keySequenceItem
showCancelButton: true
modifierlessAllowed: false
modifierOnlyAllowed: true
keySequence: itemDelegate.shortcut
+ onKeySequenceChanged: itemDelegate.view.maxKeySequenceItemWidthChanged()
onCaptureFinished: itemDelegate.model.shortcut = keySequence
}
diff --git a/kcms/keyboard/ui/main.qml b/kcms/keyboard/ui/main.qml
index 0b79610ca9..3230fe7d7c 100644
--- a/kcms/keyboard/ui/main.qml
+++ b/kcms/keyboard/ui/main.qml
@@ -257,6 +257,8 @@ KCM.ScrollViewKCM {
actions: [ configureLayoutsAction, addLayoutAction ]
}
+ readonly property int maxKeySequenceItemWidth: Math.max(...contentItem.children.map(item => item?.keySequenceItemWidth || 0))
+
delegate: LayoutDelegate {
id: delegate
onMove: (oldIndex, newIndex) => kcm.userLayoutModel.move(oldIndex, newIndex)
--
GitLab
|