/*SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Controls as QQC2import QtQuick.Layoutsimport org.kde.kcmutils as KCMKCM.SimpleKCM {id: rootsignal configurationChangedproperty var prettyStrings: {"LeftButton": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Left-Button"),"RightButton": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Right-Button"),"MiddleButton": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Middle-Button"),"BackButton": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Back-Button"),"ForwardButton": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Forward-Button"),"wheel:Vertical": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Vertical-Scroll"),"wheel:Horizontal": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Horizontal-Scroll"),"ShiftModifier": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Shift"),"ControlModifier": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Ctrl"),"AltModifier": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Alt"),"MetaModifier": i18ndc("plasma_shell_org.kde.plasma.desktop", "@label for shortcuts", "Meta")}function saveConfig() {configDialog.currentContainmentActionsModel.save();}Connections {target: configDialog.currentContainmentActionsModelfunction onConfigurationChanged() {root.configurationChanged()}}GridLayout {id: mainColumnflow: GridLayout.TopToBottomwidth: parent.widthRepeater {id: actionsRepeatermodel: configDialog.currentContainmentActionsModelMouseEventInputButton {Layout.column: 0Layout.row: indexLayout.fillWidth: trueLayout.minimumWidth: implicitWidthdefaultText: {var splitAction = model.action.split(';');var button = splitAction[0];var modifiers = (splitAction[1] || "").split('|').filter(function (item) {return item !== "NoModifier";});var parts = modifiers;modifiers.push(button);return parts.map(function (item) {return root.prettyStrings[item] || item;}).join(i18ndc("plasma_shell_org.kde.plasma.desktop", "Concatenation sign for shortcuts, e.g. Ctrl+Shift", "+"));}eventString: model.actiononEventStringChanged: {configDialog.currentContainmentActionsModel.update(index, eventString, model.pluginName);}}}Repeater {model: configDialog.currentContainmentActionsModelQQC2.ComboBox {id: pluginsCombo// "index" argument of onActivated shadows the model indexreadonly property int pluginIndex: indexLayout.fillWidth: trueLayout.column: 1Layout.row: index// both MouseEventInputButton and this ComboBox have fillWidth for a uniform layout// however, their implicit sizes is taken into account and they compete against// each other for available space. By setting an insane preferredWidth we give// ComboBox a greater share of the available spaceLayout.preferredWidth: 9000model: configDialog.containmentActionConfigModeltextRole: "name"valueRole: "pluginName"property bool initialized: falseComponent.onCompleted: {currentIndex = indexOfValue(pluginName)pluginsCombo.initialized = true;}onActivated: {if (initialized) {var newPluginName = currentValue;if (newPluginName !== pluginName) {configDialog.currentContainmentActionsModel.update(pluginIndex, action, newPluginName);}}}}}Repeater {model: configDialog.currentContainmentActionsModelRowLayout {Layout.column: 2Layout.row: indexQQC2.Button {icon.name: "configure"enabled: model.hasConfigurationInterfaceonClicked: {configDialog.currentContainmentActionsModel.showConfiguration(index, this);}}QQC2.Button {icon.name: "list-remove"onClicked: {configDialog.currentContainmentActionsModel.remove(index);}}}}MouseEventInputButton {defaultText: i18ndc("plasma_shell_org.kde.plasma.desktop", "@action:button", "Add Action");icon.name: checked ? "input-mouse-symbolic" : "list-add"onEventStringChanged: {configDialog.currentContainmentActionsModel.append(eventString, "org.kde.contextmenu");}}}}