Warning, /plasma/plasma-workspace/applets/brightness/package/contents/ui/BrightnessItem.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2012-2013 Daniel Nicoletti <dantti12@gmail.com>
0003     SPDX-FileCopyrightText: 2013, 2015 Kai Uwe Broulik <kde@privat.broulik.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 import QtQuick
0009 import QtQuick.Layouts
0010 
0011 import org.kde.plasma.components as PlasmaComponents3
0012 import org.kde.kirigami as Kirigami
0013 
0014 PlasmaComponents3.ItemDelegate {
0015     id: root
0016 
0017     enum Type {
0018         Screen,
0019         Keyboard
0020     }
0021 
0022     property alias slider: control
0023     property alias value: control.value
0024     property alias maximumValue: control.to
0025     property alias stepSize: control.stepSize
0026     property alias showPercentage: percent.visible
0027     required property /*BrightnessItem.Type*/ int type
0028 
0029     readonly property real percentage: Math.round(100 * value / maximumValue)
0030 
0031     signal moved()
0032 
0033     background.visible: highlighted
0034     highlighted: activeFocus
0035     hoverEnabled: false
0036 
0037     Accessible.description: percent.text
0038     Accessible.role: Accessible.Slider
0039     Keys.forwardTo: [slider]
0040 
0041     contentItem: RowLayout {
0042         spacing: Kirigami.Units.gridUnit
0043 
0044         Kirigami.Icon {
0045             id: image
0046             Layout.alignment: Qt.AlignTop
0047             Layout.preferredWidth: Kirigami.Units.iconSizes.medium
0048             Layout.preferredHeight: Kirigami.Units.iconSizes.medium
0049             source: root.icon.name
0050         }
0051 
0052         ColumnLayout {
0053             Layout.fillWidth: true
0054             Layout.alignment: Qt.AlignTop
0055             spacing: 0
0056 
0057             RowLayout {
0058                 Layout.fillWidth: true
0059                 spacing: Kirigami.Units.smallSpacing
0060 
0061                 PlasmaComponents3.Label {
0062                     id: title
0063                     Layout.fillWidth: true
0064                     text: root.text
0065                     textFormat: Text.PlainText
0066                 }
0067 
0068                 PlasmaComponents3.Label {
0069                     id: percent
0070                     Layout.alignment: Qt.AlignRight
0071                     text: i18nc("Placeholder is brightness percentage", "%1%", root.percentage)
0072                     textFormat: Text.PlainText
0073                 }
0074             }
0075 
0076             PlasmaComponents3.Slider {
0077                 id: control
0078                 Layout.fillWidth: true
0079 
0080                 activeFocusOnTab: false
0081                 // Don't allow the slider to turn off the screen
0082                 // Please see https://git.reviewboard.kde.org/r/122505/ for more information
0083                 from: root.type == BrightnessItem.Type.Screen ? 1 : 0
0084                 stepSize: 1
0085 
0086                 Accessible.name: root.text
0087                 Accessible.description: percent.text
0088 
0089                 onMoved: root.moved()
0090             }
0091         }
0092     }
0093 }