5import QtQuick.Controls as QQC2
8import org.kde.kirigami as Kirigami
9import org.kde.kirigamiaddons.formcard as FormCard
10import org.kde.kirigamiaddons.delegates as Delegates
11import org.kde.kirigamiaddons.components as Components
13Kirigami.ScrollablePage {
16 property alias model: listView.model
18 title: i18ndc("kirigami-addons6",
"@title:window",
"Shortcuts")
22 placeholderText:
i18ndc(
"kirigami-addons6",
"@label:textbox",
"Filter…")
32 required property int index
33 required property string actionName
35 required property string shortcutDisplay
36 required property string alternateShortcuts
38 text: actionName.
replace(
'&',
'')
40 contentItem: RowLayout {
42 text: shortcutDelegate.text
43 Layout.fillWidth: true
47 text: shortcutDelegate.shortcutDisplay
52 shortcutDialog.title =
i18ndc(
"krigiami-addons6",
"@title:window",
"Shortcut: %1", shortcutDelegate.text);
53 shortcutDialog.keySequence = shortcutDelegate.shortcut;
54 shortcutDialog.index = shortcutDelegate.index;
55 shortcutDialog.alternateShortcuts = shortcutDelegate.alternateShortcuts;
63 property alias
keySequence: keySequenceItem.keySequence
64 property var alternateShortcuts
65 property int index: -1
67 parent: root.QQC2.Overlay.overlay
72 label:
i18ndc(
"krigiami-addons6",
"@label",
"Shortcut:")
73 onKeySequenceModified: {
74 root.model.updateShortcut(shortcutDialog.index, 0, keySequence);
77 onErrorOccurred: (title, message) => {
78 root.QQC2.ApplicationWindow.showPassiveNotification(title +
'\n' + message);
81 onShowStealStandardShortcutDialog: (title, message, sequence) => {
82 stealStandardShortcutDialog.title = title
83 stealStandardShortcutDialog.message = message;
84 stealStandardShortcutDialog.sequence = sequence;
85 stealStandardShortcutDialog.parent = root.QQC2.Overlay.overlay;
86 stealStandardShortcutDialog.sequenceItem =
this;
87 stealStandardShortcutDialog.openDialog();
91 Components.MessageDialog {
92 id: stealStandardShortcutDialog
94 property string message
96 property KeySequenceItem sequenceItem
98 dialogType: Components.MessageDialog.Warning
99 dontShowAgainName:
"stealStandardShortcutDialog"
102 text: stealStandardShortcutDialog.message
103 Layout.fillWidth:
true
104 wrapMode:
Text.WordWrap
110 sequenceItem.stealStandardShortcut(sequence);
118 id: alternateRepeater
120 model: shortcutDialog.alternateShortcuts
122 id: alternateKeySequenceItem
124 required
property int index
125 required
property var modelData
127 label: index === 0 ?
i18ndc(
"krigiami-addons6",
"@label",
"Alternative:") :
''
130 onKeySequenceModified: {
131 const alternates = root.model.updateShortcut(shortcutDialog.index, index + 1, keySequence);
132 if (alternates !== shortcutDialog.alternateShortcuts) {
133 shortcutDialog.alternateShortcuts = alternates;
137 onErrorOccurred: (title, message) => {
138 root.QQC2.ApplicationWindow.showPassiveNotification(title +
'\n' + message);
141 onShowStealStandardShortcutDialog: (title, message, sequence) => {
142 stealStandardShortcutDialog.title = title
143 stealStandardShortcutDialog.message = message;
144 stealStandardShortcutDialog.sequence = sequence;
145 stealStandardShortcutDialog.parent = root.QQC2.Overlay.overlay;
146 stealStandardShortcutDialog.sequenceItem =
this;
147 stealStandardShortcutDialog.openDialog();
153 id: alternateKeySequenceItem
155 label: alternateRepeater.
count === 0 ?
i18ndc(
"krigiami-addons6",
"@label",
"Alternative:") :
''
157 onKeySequenceModified: {
158 shortcutDialog.alternateShortcuts = root.model.updateShortcut(shortcutDialog.index, alternateRepeater.count + 1, keySequence);
162 onErrorOccurred: (title, message) => {
163 root.QQC2.ApplicationWindow.showPassiveNotification(title +
'\n' + message);
166 onShowStealStandardShortcutDialog: (title, message, sequence) => {
167 stealStandardShortcutDialog.title = title
168 stealStandardShortcutDialog.message = message;
169 stealStandardShortcutDialog.sequence = sequence;
170 stealStandardShortcutDialog.parent = root.QQC2.Overlay.overlay;
171 stealStandardShortcutDialog.sequenceItem =
this;
172 stealStandardShortcutDialog.openDialog();
177 QQC2.DialogButtonBox {
178 Layout.fillWidth:
true
179 standardButtons: QQC2.DialogButtonBox.Close | QQC2.DialogButtonBox.Reset
180 onRejected: shortcutDialog.close();
181 onReset: shortcutDialog.alternateShortcuts = root.model.reset(shortcutDialog.index)
183 topPadding:
Kirigami.Units.smallSpacing
191 width: parent.width -
Kirigami.Units.gridUnit * 4
192 anchors.centerIn: parent
193 text:
i18ndc(
"kirigami-addons6",
"Placeholder message",
"No shortcuts found")
194 visible: listView.count === 0
201 contentItem: QQC2.DialogButtonBox {
202 padding:
Kirigami.Units.largeSpacing
203 standardButtons: QQC2.Dialog.Save | QQC2.Dialog.Reset
209 onReset: root.model.resetAll()
An item delegate providing a modern look and feel.
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
const QList< QKeySequence > & close()
QString label(StandardShortcut id)
const QList< QKeySequence > & shortcut(StandardShortcut id)
const QList< QKeySequence > & replace()
qsizetype count() const const
void keySequence(QWidget *widget, const QKeySequence &keySequence)