Warning, /plasma/plasma-desktop/kcms/touchpad/applet/qml/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 // -*- coding: iso-8859-1 -*-
0002 /*
0003 * SPDX-FileCopyrightText: 2013 Alexander Mezin <mezin.alexander@gmail.com>
0004 * SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
0005 *
0006 * SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008
0009 import QtQuick 2.0
0010 import QtQuick.Layouts 1.1
0011
0012 import org.kde.plasma.core as PlasmaCore
0013 import org.kde.plasma.extras 2.0 as PlasmaExtras
0014 import org.kde.plasma.plasma5support 2.0 as P5Support
0015 import org.kde.kirigami 2.20 as Kirigami
0016
0017 import org.kde.plasma.plasmoid 2.0
0018
0019 PlasmoidItem {
0020 id: root
0021
0022 // Don't de-duplicate `touchpadEnabled` expression using `hasTouchpad`
0023 // property, QML doesn't work that way. Order of signals propagation is
0024 // not specified, so if/when data source disconnects, touchpadEnabled
0025 // might get re-evaluated while hasTouchpad is still true.
0026 readonly property bool hasTouchpad: typeof dataSource.data.touchpad !== "undefined" && dataSource.data.touchpad.workingTouchpadFound
0027 readonly property bool touchpadEnabled: typeof dataSource.data.touchpad !== "undefined" && dataSource.data.touchpad.workingTouchpadFound
0028 && dataSource.data.touchpad.enabled
0029
0030 Plasmoid.icon: touchpadEnabled ? "input-touchpad-on" : "input-touchpad-off"
0031 // Touchpad being enabled is normal; only show the applet when it's disabled
0032 Plasmoid.status: {
0033 if (!hasTouchpad) {
0034 return PlasmaCore.Types.HiddenStatus;
0035 } else if (touchpadEnabled) {
0036 return PlasmaCore.Types.PassiveStatus;
0037 } else {
0038 return PlasmaCore.Types.ActiveStatus;
0039 }
0040 }
0041
0042 toolTipSubText: {
0043 if (!hasTouchpad) {
0044 return i18n("No touchpad was found");
0045 } else if (touchpadEnabled) {
0046 return i18n("Touchpad is enabled");
0047 } else {
0048 return i18n("Touchpad is disabled");
0049 }
0050 }
0051
0052 P5Support.DataSource {
0053 id: dataSource
0054 engine: "touchpad"
0055 connectedSources: dataSource.sources
0056 }
0057
0058 // This is only accessible from System Tray, when hidden in the popup
0059 // and you click the list item text instead of the icon
0060 fullRepresentation: Item {
0061
0062 PlasmaExtras.PlaceholderMessage {
0063 anchors.centerIn: parent
0064 width: parent.width - (Kirigami.Units.gridUnit * 8)
0065 text: root.toolTipSubText
0066 iconName: Plasmoid.icon
0067 }
0068 }
0069 }