2018-11-12 05:05:46 +00:00
|
|
|
/*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2012-2013 Daniel Nicoletti <dantti12@gmail.com>
|
|
|
|
|
* SPDX-FileCopyrightText: 2013, 2015 Kai Uwe Broulik <kde@privat.broulik.de>
|
2021-12-22 23:29:00 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
2018-11-12 05:05:46 +00:00
|
|
|
*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
2018-11-12 05:05:46 +00:00
|
|
|
*/
|
|
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
import QtQuick 2.15
|
2018-11-12 05:05:46 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2026-03-07 03:08:07 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2018-11-12 05:05:46 +00:00
|
|
|
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2020-12-16 14:54:11 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2024-10-09 05:47:30 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.screenbrightnessplugin as ScreenBrightness
|
2025-06-23 00:16:16 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2018-11-12 05:05:46 +00:00
|
|
|
|
2021-04-09 20:59:05 +00:00
|
|
|
Item {
|
2021-12-22 23:29:00 +00:00
|
|
|
id: root
|
2021-04-09 20:59:05 +00:00
|
|
|
implicitHeight: brightnessRow.implicitHeight
|
2024-11-11 05:57:17 +00:00
|
|
|
visible: screenBrightness.brightnessAvailable
|
2023-03-19 03:05:44 +00:00
|
|
|
|
2024-11-14 03:34:01 +00:00
|
|
|
property double brightnessPressedValue: 1
|
|
|
|
|
Behavior on brightnessPressedValue {
|
|
|
|
|
NumberAnimation {
|
2025-03-22 20:36:31 +00:00
|
|
|
duration: Kirigami.Units.longDuration * 2
|
|
|
|
|
easing.type: Easing.InOutQuad
|
2024-11-14 03:34:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-09 05:47:30 +00:00
|
|
|
ScreenBrightness.ScreenBrightnessUtil {
|
|
|
|
|
id: screenBrightness
|
|
|
|
|
}
|
2023-03-19 03:05:44 +00:00
|
|
|
|
2025-06-23 00:16:16 +00:00
|
|
|
MobileShell.PanelBackground {
|
2024-11-14 03:34:01 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.leftMargin: -Kirigami.Units.smallSpacing
|
|
|
|
|
anchors.rightMargin: -Kirigami.Units.smallSpacing
|
|
|
|
|
anchors.topMargin: -Kirigami.Units.smallSpacing * 2
|
|
|
|
|
anchors.bottomMargin: -Kirigami.Units.smallSpacing * 2
|
|
|
|
|
|
2025-06-23 00:16:16 +00:00
|
|
|
panelType: MobileShell.PanelBackground.PanelType.Base
|
|
|
|
|
flatten: root.brightnessPressedValue
|
2025-09-18 13:29:53 +00:00
|
|
|
|
|
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
2024-11-14 03:34:01 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-09 20:59:05 +00:00
|
|
|
RowLayout {
|
|
|
|
|
id: brightnessRow
|
2023-07-25 01:13:52 +00:00
|
|
|
spacing: Kirigami.Units.smallSpacing * 2
|
2024-03-01 15:51:35 +00:00
|
|
|
|
2021-04-09 20:59:05 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: parent.top
|
2021-08-27 21:02:44 +00:00
|
|
|
|
2023-08-18 09:08:07 +00:00
|
|
|
Kirigami.Icon {
|
2021-04-09 20:59:05 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-07-25 01:13:52 +00:00
|
|
|
Layout.leftMargin: Kirigami.Units.smallSpacing
|
|
|
|
|
Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
|
2021-04-09 20:59:05 +00:00
|
|
|
Layout.preferredHeight: width
|
|
|
|
|
source: "low-brightness"
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
PC3.Slider {
|
2021-04-09 20:59:05 +00:00
|
|
|
id: brightnessSlider
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
from: 1
|
2024-10-09 05:47:30 +00:00
|
|
|
to: screenBrightness.maxBrightness
|
|
|
|
|
value: screenBrightness.brightness
|
|
|
|
|
onMoved: screenBrightness.brightness = value;
|
2023-03-19 03:05:44 +00:00
|
|
|
|
2024-11-14 03:34:01 +00:00
|
|
|
onPressedChanged: {
|
|
|
|
|
if (pressed) {
|
|
|
|
|
brightnessPressedTimer.restart();
|
|
|
|
|
} else{
|
|
|
|
|
brightnessPressedTimer.stop();
|
|
|
|
|
brightnessPressedValue = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
|
id: brightnessPressedTimer
|
2025-03-22 20:36:31 +00:00
|
|
|
interval: 100
|
2024-11-14 03:34:01 +00:00
|
|
|
repeat: false
|
|
|
|
|
onTriggered: {
|
|
|
|
|
if (brightnessSlider.pressed) {
|
|
|
|
|
brightnessPressedValue = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-09 05:47:30 +00:00
|
|
|
// HACK: for some reason, the slider initial value doesn't set without being done after the component completes loading
|
|
|
|
|
Timer {
|
|
|
|
|
interval: 0
|
|
|
|
|
running: true
|
|
|
|
|
repeat: false
|
|
|
|
|
onTriggered: brightnessSlider.value = Qt.binding(() => screenBrightness.brightness)
|
|
|
|
|
}
|
2021-04-09 20:59:05 +00:00
|
|
|
}
|
2024-03-01 15:51:35 +00:00
|
|
|
|
2023-08-18 09:08:07 +00:00
|
|
|
Kirigami.Icon {
|
2021-04-09 20:59:05 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-07-25 01:13:52 +00:00
|
|
|
Layout.rightMargin: Kirigami.Units.smallSpacing
|
|
|
|
|
Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
|
2021-04-09 20:59:05 +00:00
|
|
|
Layout.preferredHeight: width
|
|
|
|
|
source: "high-brightness"
|
|
|
|
|
}
|
2018-11-12 05:05:46 +00:00
|
|
|
}
|
|
|
|
|
}
|