Warning, /multimedia/haruna/src/qml/Settings/CustomCommandsSettings.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2021 George Florea Bănuș <georgefb899@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import QtQuick.Controls 0010 0011 import org.kde.kirigami as Kirigami 0012 import org.kde.kquickcontrols 0013 import org.kde.haruna 0014 0015 SettingsBasePage { 0016 id: root 0017 0018 property string settingsPath: "qrc:/qt/qml/org/kde/haruna/qml/Settings" 0019 0020 hasHelp: true 0021 helpFile: ":/CustomCommandsSettings.html" 0022 docPage: "help:/haruna/CustomCommandsSettings.html" 0023 0024 ListView { 0025 id: customCommandsView 0026 0027 reuseItems: true 0028 model: customCommandsModel 0029 delegate: Loader { 0030 required property var model 0031 required property int index 0032 width: customCommandsView.width 0033 sourceComponent: customCommandDelegate 0034 } 0035 0036 0037 Kirigami.PlaceholderMessage { 0038 anchors.centerIn: parent 0039 visible: customCommandsView.count === 0 0040 text: i18nc("@label:textbox", "No custom commands yet") 0041 helpfulAction: Action { 0042 text: i18nc("@action:button", "&Add command") 0043 onTriggered: applicationWindow().pageStack.replace(`${root.settingsPath}/EditCustomCommand.qml`) 0044 } 0045 } 0046 } 0047 0048 Component { 0049 id: customCommandDelegate 0050 0051 ItemDelegate { 0052 id: customCommandItem 0053 0054 height: Kirigami.Units.gridUnit * 3 0055 padding: 0 0056 0057 contentItem: RowLayout { 0058 anchors.fill: parent 0059 spacing: 0 0060 0061 Kirigami.ListItemDragHandle { 0062 listItem: customCommandItem 0063 listView: customCommandsView 0064 onMoveRequested: customCommandsModel.moveRows(oldIndex, newIndex) 0065 } 0066 0067 CheckBox { 0068 visible: model.type === "startup" 0069 checked: model.setOnStartup 0070 onCheckStateChanged: { 0071 customCommandsModel.toggleCustomCommand(model.commandId, model.index, checked) 0072 } 0073 0074 ToolTip { 0075 text: i18nc("@info:tooltip", "Don't set on next startup") 0076 delay: 0 0077 } 0078 } 0079 0080 Kirigami.Icon { 0081 source: model.type === "shortcut" ? "configure-shortcuts" : "code-context" 0082 width: Kirigami.Units.iconSizes.small 0083 height: Kirigami.Units.iconSizes.small 0084 enabled: model.setOnStartup 0085 } 0086 0087 LabelWithTooltip { 0088 text: model.command 0089 elide: Text.ElideRight 0090 enabled: model.setOnStartup 0091 opacity: enabled ? 1.0 : 0.7 0092 0093 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter 0094 Layout.fillWidth: true 0095 Layout.margins: Kirigami.Units.largeSpacing 0096 } 0097 0098 Loader { 0099 active: model.type === "shortcut" 0100 sourceComponent: KeySequenceItem { 0101 checkForConflictsAgainst: ShortcutType.None 0102 modifierlessAllowed: true 0103 keySequence: model.shortcut 0104 0105 onKeySequenceChanged: { 0106 if (keySequence !== model.shortcut) { 0107 // use action name (commandId) since this changes the actionsModel 0108 if (!actionsModel.saveShortcut(model.commandId, keySequence)) { 0109 keySequence = model.shortcut 0110 } 0111 } 0112 } 0113 } 0114 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter 0115 } 0116 0117 0118 0119 Item { width: Kirigami.Units.smallSpacing } 0120 0121 Button { 0122 icon.name: "edit-entry" 0123 Layout.rightMargin: Kirigami.Units.largeSpacing 0124 onClicked: { 0125 const properties = { 0126 command: model.command, 0127 osdMessage: model.osdMessage, 0128 type: model.type, 0129 commandId: model.commandId, 0130 index: model.index, 0131 mode: EditCustomCommand.Mode.Edit 0132 } 0133 applicationWindow().pageStack.replace(`${root.settingsPath}/EditCustomCommand.qml`, properties) 0134 } 0135 } 0136 } 0137 } 0138 } 0139 0140 footer: ToolBar { 0141 visible: customCommandsView.count > 0 0142 0143 RowLayout { 0144 anchors.fill: parent 0145 0146 ToolButton { 0147 id: addButton 0148 0149 text: i18nc("@action:intoolbar", "&Add") 0150 icon.name: "list-add" 0151 onClicked: applicationWindow().pageStack.replace(`${root.settingsPath}/EditCustomCommand.qml`) 0152 Layout.alignment: Qt.AlignRight 0153 } 0154 } 0155 } 0156 0157 }