5import QtQuick.Controls as QQC2
8import org.kde.kitemmodels
9import org.kde.kirigami as Kirigami
10import org.kde.kirigamiaddons.formcard as FormCard
11import org.kde.kirigamiaddons.delegates as Delegates
12import org.kde.kirigamiaddons.components as Components
14Kirigami.ScrollablePage {
17 property alias model: searchFilterProxyModel.sourceModel
19 title: i18ndc("kirigami-addons6",
"@title:window",
"Shortcuts")
23 placeholderText:
i18ndc(
"kirigami-addons6",
"@label:textbox",
"Filter…")
24 onTextChanged: searchFilterProxyModel.setFilterFixedString(text);
34 id: searchFilterProxyModel
36 filterRoleName:
'actionName'
37 filterCaseSensitivity:
Qt.CaseInsensitive
40 delegate: Delegates.RoundedItemDelegate {
43 required
property int index
44 required
property string actionName
46 required
property string shortcutDisplay
47 required
property string alternateShortcuts
49 text: actionName.replace(
'&',
'')
51 Accessible.description: shortcutDisplay
53 contentItem: RowLayout {
57 text: shortcutDelegate.text
58 Layout.fillWidth:
true
59 Accessible.ignored:
true
63 text: shortcutDelegate.shortcutDisplay
64 Accessible.ignored:
true
69 shortcutDialog.title =
i18ndc(
"kirigami-addons6",
"@title:window",
"Shortcut: %1", shortcutDelegate.text);
70 shortcutDialog.keySequence = shortcutDelegate.shortcut;
71 shortcutDialog.index = shortcutDelegate.index;
72 shortcutDialog.alternateShortcuts = shortcutDelegate.alternateShortcuts;
80 property alias
keySequence: keySequenceItem.keySequence
81 property var alternateShortcuts
82 property int index: -1
84 parent: root.QQC2.Overlay.overlay
89 label:
i18ndc(
"kirigami-addons6",
"@label",
"Shortcut:")
90 onKeySequenceModified: {
91 root.model.updateShortcut(shortcutDialog.index, 0, keySequence);
94 onErrorOccurred: (title, message) => {
95 root.QQC2.ApplicationWindow.showPassiveNotification(title +
'\n' + message);
98 onShowStealStandardShortcutDialog: (title, message, sequence) => {
99 stealStandardShortcutDialog.title = title
100 stealStandardShortcutDialog.message = message;
101 stealStandardShortcutDialog.sequence = sequence;
102 stealStandardShortcutDialog.parent = root.QQC2.Overlay.overlay;
103 stealStandardShortcutDialog.sequenceItem =
this;
104 stealStandardShortcutDialog.openDialog();
108 Components.MessageDialog {
109 id: stealStandardShortcutDialog
111 property string message
112 property var sequence
113 property KeySequenceItem sequenceItem
115 dialogType: Components.MessageDialog.Warning
116 dontShowAgainName:
"stealStandardShortcutDialog"
119 text: stealStandardShortcutDialog.message
120 Layout.fillWidth:
true
121 wrapMode:
Text.WordWrap
127 sequenceItem.stealStandardShortcut(sequence);
135 id: alternateRepeater
137 model: shortcutDialog.alternateShortcuts
139 id: alternateKeySequenceItem
141 required
property int index
142 required
property var modelData
144 label: index === 0 ?
i18ndc(
"kirigami-addons6",
"@label",
"Alternative:") :
''
147 onKeySequenceModified: {
148 const alternates = root.model.updateShortcut(shortcutDialog.index, index + 1, keySequence);
149 if (alternates !== shortcutDialog.alternateShortcuts) {
150 shortcutDialog.alternateShortcuts = alternates;
154 onErrorOccurred: (title, message) => {
155 root.QQC2.ApplicationWindow.showPassiveNotification(title +
'\n' + message);
158 onShowStealStandardShortcutDialog: (title, message, sequence) => {
159 stealStandardShortcutDialog.title = title
160 stealStandardShortcutDialog.message = message;
161 stealStandardShortcutDialog.sequence = sequence;
162 stealStandardShortcutDialog.parent = root.QQC2.Overlay.overlay;
163 stealStandardShortcutDialog.sequenceItem =
this;
164 stealStandardShortcutDialog.openDialog();
170 id: alternateKeySequenceItem
172 label: alternateRepeater.
count === 0 ?
i18ndc(
"kirigami-addons6",
"@label",
"Alternative:") :
''
174 onKeySequenceModified: {
175 shortcutDialog.alternateShortcuts = root.model.updateShortcut(shortcutDialog.index, alternateRepeater.count + 1, keySequence);
179 onErrorOccurred: (title, message) => {
180 root.QQC2.ApplicationWindow.showPassiveNotification(title +
'\n' + message);
183 onShowStealStandardShortcutDialog: (title, message, sequence) => {
184 stealStandardShortcutDialog.title = title
185 stealStandardShortcutDialog.message = message;
186 stealStandardShortcutDialog.sequence = sequence;
187 stealStandardShortcutDialog.parent = root.QQC2.Overlay.overlay;
188 stealStandardShortcutDialog.sequenceItem =
this;
189 stealStandardShortcutDialog.openDialog();
194 QQC2.DialogButtonBox {
195 Layout.fillWidth:
true
196 standardButtons: QQC2.DialogButtonBox.Close | QQC2.DialogButtonBox.Reset
197 onRejected: shortcutDialog.close();
198 onReset: shortcutDialog.alternateShortcuts = root.model.reset(shortcutDialog.index)
200 topPadding:
Kirigami.Units.smallSpacing
208 width: parent.width -
Kirigami.Units.gridUnit * 4
209 anchors.centerIn: parent
210 text:
i18ndc(
"kirigami-addons6",
"Placeholder message",
"No shortcuts found")
211 visible: listView.count === 0
218 contentItem: QQC2.DialogButtonBox {
219 padding:
Kirigami.Units.largeSpacing
220 standardButtons: QQC2.Dialog.Save | QQC2.Dialog.Reset
226 onReset: root.model.resetAll()
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)
qsizetype count() const const
void keySequence(QWidget *widget, const QKeySequence &keySequence)