Warning, /plasma/plasma-desktop/kcms/touchscreen/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 
0004     Work sponsored by Technische Universität Dresden:
0005     SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB a KDAB Group company <info@kdab.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 import QtQuick
0011 import QtQuick.Layouts
0012 import QtQuick.Controls as QQC2
0013 import org.kde.kirigami as Kirigami
0014 import org.kde.kcmutils as KCMUtils
0015 import org.kde.plasma.touchscreen.kcm as TouchScreenKCM
0016 
0017 KCMUtils.SimpleKCM {
0018     id: root
0019 
0020     property TouchScreenKCM.InputDevice device
0021 
0022     KCMUtils.ConfigModule.buttons: KCMUtils.ConfigModule.Default | KCMUtils.ConfigModule.Apply
0023 
0024     implicitWidth: Kirigami.Units.gridUnit * 38
0025     implicitHeight: Kirigami.Units.gridUnit * 35
0026 
0027     Kirigami.PlaceholderMessage {
0028         text: i18n("No touchscreens found")
0029         anchors.centerIn: parent
0030         visible: combo.count === 0
0031         width: parent.width - (Kirigami.Units.largeSpacing * 4)
0032     }
0033 
0034     Kirigami.FormLayout {
0035 
0036         visible: combo.count > 0
0037 
0038         QQC2.ComboBox {
0039             id: combo
0040             model: kcm.touchscreensModel
0041 
0042             enabled: count > 1 //It's only interesting when there's more than 1 touchscreen
0043 
0044             Kirigami.FormData.label: i18nc("@label:listbox The device we are configuring", "Device:")
0045 
0046             onCountChanged: if (count > 0 && currentIndex < 0) {
0047                 currentIndex = 0;
0048             }
0049 
0050             onCurrentIndexChanged: {
0051                 root.device = kcm.touchscreensModel.deviceAt(currentIndex)
0052             }
0053         }
0054 
0055 
0056         QQC2.CheckBox {
0057             Kirigami.FormData.label: i18n("Enabled:")
0058 
0059             checked: root.device?.enabled ?? false
0060             onToggled: root.device.enabled = checked
0061         }
0062 
0063         QQC2.ComboBox {
0064             id: outputsCombo
0065             Kirigami.FormData.label: i18n("Target display:")
0066             model: TouchScreenKCM.OutputsModel {
0067                 id: outputsModel
0068             }
0069             enabled: count > 2 //It's only interesting when there's more than 1 screen
0070             currentIndex: {
0071                 if (!root.device || count === 0) {
0072                     return -1;
0073                 }
0074 
0075                 return outputsModel.rowForOutputName(root.device.outputName);
0076             }
0077             textRole: "display"
0078             onActivated: {
0079                 if (root.device) {
0080                     root.device.outputName = outputsModel.outputNameAt(currentIndex);
0081                 }
0082             }
0083         }
0084     }
0085 }