/** SPDX-FileCopyrightText: 2026 Sebastian Sauer <dipesh@gmx.de>* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL*/pragma ComponentBehavior: Boundimport QtQuickimport QtQuick.Layoutsimport org.kde.plasma.components as PlasmaComponents3import org.kde.plasma.core as PlasmaCoreimport org.kde.plasma.extras as PlasmaExtrasimport org.kde.plasma.plasmoidimport org.kde.plasma.workspace.dbus as DBusimport org.kde.kirigami as KirigamiPlasmoidItem {id: rootproperty int selectedButtonId: 0DBus.DBusServiceWatcher {id: dbusServiceWatcherbusType: DBus.BusType.SessionwatchedService: "org.kde.KWin.DwellClicker"onRegisteredChanged: {root.selectedButtonId = dbusServiceWatcher.registered ? dbusProperties.button : 0}}DBus.Properties {id: dbusPropertiesbusType: DBus.BusType.Sessionservice: "org.kde.KWin.DwellClicker"iface: "org.kde.KWin.DwellClicker"// Proper call DBusProperties::(connectToPropertiesChangedSignal|disconnectFromPropertiesChangedSignal)// depending on the dbusServiceWatcher.registered state since DBusProperties has no enabled property.path: dbusServiceWatcher.registered ? "/org/kde/KWin/DwellClicker" : ""property int button: Number(properties.button)onButtonChanged: {root.selectedButtonId = button}}Plasmoid.status: dbusServiceWatcher.registered ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.HiddenStatusPlasmoid.icon: "input-mouse-click-left"toolTipMainText: Plasmoid.titlefullRepresentation: PlasmaExtras.Representation {id: dialogItemLayout.minimumWidth: Kirigami.Units.gridUnit * 12Layout.minimumHeight: Kirigami.Units.gridUnit * 10collapseMarginsHint: trueheader: PlasmaExtras.PlasmoidHeading {contentItem: PlasmaComponents3.Label {text: i18nc("@info:usagetip", "Choose the next type of click:")wrapMode: Text.Wrappadding: Kirigami.Units.smallSpacing}}contentItem: ColumnLayout {spacing: 0PlasmaComponents3.ScrollView {Layout.fillWidth: trueLayout.fillHeight: trueclip: trueListView {id: listViewwidth: parent.widthenabled: dbusServiceWatcher.registeredComponent.onCompleted: {currentIndex = getIndexForActionId(root.selectedButtonId)}Connections {target: rootfunction onSelectedButtonIdChanged() {listView.currentIndex = listView.getIndexForActionId(root.selectedButtonId)}}function getIndexForActionId(id) {return id - 10;}readonly property var mouseActionModel: [{ name: i18nc("mouse button action", "Left-click"), actionIcon: "input-mouse-click-left", actionId: 10 },{ name: i18nc("mouse button action", "Double-click"), actionIcon: "input-mouse-click-left-double", actionId: 11 },{ name: i18nc("mouse button action", "Click-and-drag"), actionIcon: "input-mouse", actionId: 12 },{ name: i18nc("mouse button action", "Middle-click"), actionIcon: "input-mouse-click-middle", actionId: 13 },{ name: i18nc("mouse button action", "Right-click"), actionIcon: "input-mouse-click-right", actionId: 14 }]model: listView.mouseActionModeldelegate: PlasmaComponents3.ItemDelegate {required property int indexrequired property var modelDataicon.name: modelData.actionIcontext: modelData.namewidth: ListView.view.widthheight: Kirigami.Units.gridUnit * 2highlighted: ListView.isCurrentItemonClicked: {// If the item is already selected, unselect it by mapping to actionId 0 what// equals NoButton. Otherwise select the clicked item and use its actionId.const targetId = (listView.currentIndex === index) ? 0 : modelData.actionIdif (root.hideOnWindowDeactivate) {root.expanded = false}dbusProperties.properties.button = targetId}}}}}}}