2025-12-26 00:37:39 +01:00
|
|
|
import QtQuick
|
|
|
|
|
import Quickshell.Services.UPower
|
2025-12-28 17:36:11 +01:00
|
|
|
import QtQuick.Layouts
|
2025-12-28 13:25:31 +01:00
|
|
|
import "../settings/"
|
|
|
|
|
import "../../"
|
2025-12-26 00:37:39 +01:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
2026-01-03 20:16:51 +01:00
|
|
|
width: powerLayout.implicitWidth
|
2025-12-28 17:36:11 +01:00
|
|
|
implicitHeight: 34
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
onClicked: mouse => {
|
|
|
|
|
const modes = [PowerProfile.PowerSaver, PowerProfile.Balanced, PowerProfile.Performance];
|
|
|
|
|
let current = PowerProfiles.profile;
|
|
|
|
|
let currentIndex = modes.indexOf(current);
|
|
|
|
|
let nextIndex = (currentIndex + 1) % modes.length;
|
|
|
|
|
let prevIndex = (currentIndex - 1) % modes.length;
|
|
|
|
|
if (mouse.button == Qt.LeftButton)
|
|
|
|
|
PowerProfiles.profile = modes[nextIndex];
|
|
|
|
|
if (mouse.button == Qt.RightButton)
|
|
|
|
|
PowerProfiles.profile = modes[prevIndex];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: powerLayout
|
2025-12-26 00:37:39 +01:00
|
|
|
anchors.centerIn: parent
|
2025-12-28 17:36:11 +01:00
|
|
|
spacing: 0
|
|
|
|
|
Text {
|
|
|
|
|
id: powerProfile
|
|
|
|
|
text: PowerProfile.toString(PowerProfiles.profile)
|
|
|
|
|
font.weight: 900
|
|
|
|
|
color: Colors.foreground
|
|
|
|
|
font.family: Settings.font
|
|
|
|
|
font.pixelSize: Settings.fontSize
|
|
|
|
|
}
|
|
|
|
|
Text {
|
|
|
|
|
text: "Profile"
|
|
|
|
|
font.weight: 900
|
|
|
|
|
color: Colors.foreground
|
|
|
|
|
font.family: Settings.font
|
|
|
|
|
font.pixelSize: Settings.fontSize - 2
|
|
|
|
|
opacity: 0.7
|
2025-12-26 00:37:39 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|