blob: bab3517ae2aba5e66f1a3039a26e7ceb4cb5108a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Services.UPower
Singleton {
id: root
property int currentProfile: -1
property int previousProfile: -1
signal profileChanged(int profile)
Connections {
target: typeof PowerProfiles !== "undefined" ? PowerProfiles : null
function onProfileChanged() {
if (typeof PowerProfiles !== "undefined") {
root.previousProfile = root.currentProfile;
root.currentProfile = PowerProfiles.profile;
if (root.previousProfile !== -1) {
root.profileChanged(root.currentProfile);
}
}
}
}
Component.onCompleted: {
if (typeof PowerProfiles !== "undefined") {
root.currentProfile = PowerProfiles.profile;
root.previousProfile = PowerProfiles.profile;
}
}
}
|