/*SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Layoutsimport QtQuick.Controls as QQC2import QtQuick.Shapesimport org.kde.kirigami as Kirigamiimport org.kde.plasma.tablet.kcm as KCMimport org.kde.kcmutilsimport org.kde.kquickcontrolsKirigami.FormLayout {id: rootrequired property KCM.InputDevice devicerequired property KCM.InputDevice padDevicerequired property KCM.TabletEvents tabletEventsRepeater {id: ringRepeatermodel: root.padDevice.tabletPadRingCount// TODO: we should make this generic enough for all bindings// TODO: this doesn't take into account mode groups the ring is indelegate: ColumnLayout {id: ringDelegatespacing: Kirigami.Units.smallSpacingrequired property int indexKirigami.FormData.label: i18ndc("kcm_tablet", "@label for graphics tablet ring config, % is number of ring", "Pad ring %1:", index + 1)Repeater {id: modesRepeatermodel: root.padDevice.numModes[0]delegate: RowLayout {id: modeLayoutrequired property int indexspacing: Kirigami.Units.largeSpacingQQC2.Label {text: modeLayout.index + 1color: Kirigami.Theme.disabledTextColorfont.bold: root.padDevice.currentModes[0] === modeLayout.indexvisible: modesRepeater.count > 1 // Don't show the mode number unless there's more than one mode to reduce clutter and confusion}ActionBinding {id: seqname: i18ndc("kcm_tablet", "@info Meant to be inserted into an existing sentence like 'configuring pad ring/dial 0'", "pad ring/dial %1", ringDelegate.index + 1)supportsPenButton: falsesupportsRelativeEvents: truefunction refreshInputSequence(): void {seq.inputSequence = kcm.padRingMapping(root.padDevice.name, ringDelegate.index, modeLayout.index)}inputSequence: kcm.padRingMapping(root.padDevice.name, ringDelegate.index, modeLayout.index)Connections {target: kcmfunction onSettingsRestored() {seq.refreshInputSequence();}}onGotInputSequence: sequence => {kcm.assignPadRingMapping(root.padDevice.name, ringDelegate.index, modeLayout.index, sequence)}SettingHighlighter {// Currently, application-defined is the defaulthighlight: seq.inputSequence.type !== KCM.InputSequence.ApplicationDefined}}}}}}Repeater {id: dialRepeatermodel: root.padDevice.tabletPadDialCountdelegate: ActionBinding {id: seqrequired property int indexKirigami.FormData.label: i18ndc("kcm_tablet", "@label for graphics tablet ring config, % is number of dial", "Pad dial %1:", index + 1)name: i18ndc("kcm_tablet", "@info Meant to be inserted into an existing sentence like 'configuring pad button 0'", "pad dial %1", index + 1)supportsPenButton: falsesupportsRelativeEvents: truefunction refreshInputSequence(): void {seq.inputSequence = kcm.padDialMapping(root.padDevice.name, index)}inputSequence: kcm.padDialMapping(root.padDevice.name, index)Connections {target: kcmfunction onSettingsRestored() {refreshInputSequence();}}onGotInputSequence: sequence => {kcm.assignPadDialMapping(root.padDevice.name, index, sequence)}SettingHighlighter {// Currently, application-defined is the defaulthighlight: seq.inputSequence.type !== KCM.InputSequence.ApplicationDefined}}}Repeater {id: buttonsRepeatermodel: root.padDevice.tabletPadButtonCountdelegate: ActionBinding {id: seqrequired property int indexKirigami.FormData.label: (buttonPressed ? "<b>" : "") + i18ndc("kcm_tablet", "@label for graphics tablet button config, % is number of button", "Pad button %1:", index + 1) + (buttonPressed ? "</b>" : "")property bool buttonPressed: falsename: i18ndc("kcm_tablet", "@info Meant to be inserted into an existing sentence like 'configuring pad button 0'", "pad button %1", index + 1)supportsPenButton: falseConnections {target: root.tabletEventsfunction onPadButtonReceived(path, button, pressed) {if (button !== index || !path.endsWith(root.padDevice.sysName)) {return;}seq.buttonPressed = pressed}}function refreshInputSequence(): void {seq.inputSequence = kcm.padButtonMapping(root.padDevice.name, index)}inputSequence: kcm.padButtonMapping(root.padDevice.name, index)Connections {target: kcmfunction onSettingsRestored() {refreshInputSequence();}}onGotInputSequence: sequence => {kcm.assignPadButtonMapping(root.padDevice.name, index, sequence)}SettingHighlighter {// Currently, application-defined is the defaulthighlight: seq.inputSequence.type !== KCM.InputSequence.ApplicationDefined}}}ActionDialog {id: actionDialogparent: root.QQC2.Overlay.overlay}}