/*SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>Work sponsored by Technische UniversitΓ€t Dresden:SPDX-FileCopyrightText: 2022 KlarΓ€lvdalens Datakonsult AB a KDAB Group company <info@kdab.com>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Layoutsimport QtQuick.Controls as QQC2import org.kde.kirigami as Kirigamiimport org.kde.kcmutils as KCMUtilsimport org.kde.plasma.touchscreen.kcm as TouchScreenKCMKCMUtils.SimpleKCM {id: rootproperty TouchScreenKCM.InputDevice deviceKCMUtils.ConfigModule.buttons: KCMUtils.ConfigModule.Default | KCMUtils.ConfigModule.ApplyimplicitWidth: Kirigami.Units.gridUnit * 38implicitHeight: Kirigami.Units.gridUnit * 35Kirigami.PlaceholderMessage {icon.name: "input-touchscreen"text: i18nc("@info:status placeholdermessage text", "No touchscreens found")explanation: i18nc("@info:usagetip placeholdermessage explanation", "Connect an external touchscreen")anchors.centerIn: parentvisible: combo.count === 0width: parent.width - (Kirigami.Units.largeSpacing * 4)}Kirigami.FormLayout {visible: combo.count > 0QQC2.ComboBox {id: combomodel: kcm.touchscreensModeltextRole: "display"enabled: count > 1 //It's only interesting when there's more than 1 touchscreenKirigami.FormData.label: i18nc("@label:listbox The device we are configuring", "Device:")onCountChanged: if (count > 0 && currentIndex < 0) {currentIndex = 0;}onCurrentIndexChanged: {root.device = kcm.touchscreensModel.deviceAt(currentIndex)}}QQC2.CheckBox {Kirigami.FormData.label: i18nc("@option:check prefix touchscreen device is enabled", "Enabled:")checked: root.device?.enabled ?? falseonToggled: root.device.enabled = checked}QQC2.ComboBox {id: outputsComboKirigami.FormData.label: i18nc("@label:listbox this is a compound noun", "Target display:")model: TouchScreenKCM.OutputsModel {id: outputsModel}enabled: count > 2 //It's only interesting when there's more than 1 screencurrentIndex: {if (!root.device || count === 0) {return -1;}return outputsModel.rowForOutputName(root.device.outputName);}textRole: "display"onActivated: {if (root.device) {root.device.outputName = outputsModel.outputNameAt(currentIndex);}}}}}