34 lines
1.1 KiB
QML
34 lines
1.1 KiB
QML
|
|
import QtQuick
|
||
|
|
import Quickshell.Services.UPower
|
||
|
|
import qs
|
||
|
|
|
||
|
|
Item {
|
||
|
|
id: root
|
||
|
|
implicitWidth: 80
|
||
|
|
Text {
|
||
|
|
id: powerProfile
|
||
|
|
text: PowerProfile.toString(PowerProfiles.profile)
|
||
|
|
font.weight: 900
|
||
|
|
color: Colors.foreground
|
||
|
|
font.family: Appearance.font
|
||
|
|
font.pixelSize: Appearance.fontSize
|
||
|
|
anchors.centerIn: parent
|
||
|
|
MouseArea {
|
||
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||
|
|
cursorShape: Qt.OpenHandCursor
|
||
|
|
anchors.fill: parent
|
||
|
|
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];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|