blob: 971ec4d95f12a98fb14e21722af6e27ea69f9b81 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
import qs.widgets
import qs.services
import qs.utils
import qs.config
import Quickshell
import Quickshell.Bluetooth
import Quickshell.Services.UPower
import QtQuick
Item {
id: root
property color colour: Colours.palette.m3secondary
readonly property Item network: network
readonly property real bs: bluetooth.y
readonly property real be: repeater.count > 0 ? devices.y + devices.implicitHeight : bluetooth.y + bluetooth.implicitHeight
readonly property Item battery: battery
clip: true
implicitWidth: Math.max(network.implicitWidth, bluetooth.implicitWidth, devices.implicitWidth, battery.implicitWidth)
implicitHeight: network.implicitHeight + bluetooth.implicitHeight + bluetooth.anchors.topMargin + (repeater.count > 0 ? devices.implicitHeight + devices.anchors.topMargin : 0) + battery.implicitHeight + battery.anchors.topMargin
MaterialIcon {
id: network
animate: true
text: Network.active ? Icons.getNetworkIcon(Network.active.strength ?? 0) : "wifi_off"
color: root.colour
anchors.horizontalCenter: parent.horizontalCenter
}
MaterialIcon {
id: bluetooth
anchors.horizontalCenter: network.horizontalCenter
anchors.top: network.bottom
anchors.topMargin: Appearance.spacing.smaller / 2
animate: true
text: Bluetooth.defaultAdapter?.enabled ? "bluetooth" : "bluetooth_disabled"
color: root.colour
}
Column {
id: devices
anchors.horizontalCenter: bluetooth.horizontalCenter
anchors.top: bluetooth.bottom
anchors.topMargin: Appearance.spacing.smaller / 2
spacing: Appearance.spacing.smaller / 2
Repeater {
id: repeater
model: ScriptModel {
values: Bluetooth.devices.values.filter(d => d.state !== BluetoothDeviceState.Disconnected)
}
MaterialIcon {
id: device
required property BluetoothDevice modelData
animate: true
text: Icons.getBluetoothIcon(modelData.icon)
color: root.colour
fill: 1
SequentialAnimation on opacity {
running: device.modelData.state !== BluetoothDeviceState.Connected
alwaysRunToEnd: true
loops: Animation.Infinite
Anim {
from: 1
to: 0
easing.bezierCurve: Appearance.anim.curves.standardAccel
}
Anim {
from: 0
to: 1
easing.bezierCurve: Appearance.anim.curves.standardDecel
}
}
}
}
}
MaterialIcon {
id: battery
anchors.horizontalCenter: devices.horizontalCenter
anchors.top: repeater.count > 0 ? devices.bottom : bluetooth.bottom
anchors.topMargin: Appearance.spacing.smaller / 2
animate: true
text: {
if (!UPower.displayDevice.isLaptopBattery) {
if (PowerProfiles.profile === PowerProfile.PowerSaver)
return "energy_savings_leaf";
if (PowerProfiles.profile === PowerProfile.Performance)
return "rocket_launch";
return "balance";
}
const perc = UPower.displayDevice.percentage;
const charging = !UPower.onBattery;
if (perc === 1)
return charging ? "battery_charging_full" : "battery_full";
let level = Math.floor(perc * 7);
if (charging && (level === 4 || level === 1))
level--;
return charging ? `battery_charging_${(level + 3) * 10}` : `battery_${level}_bar`;
}
color: !UPower.onBattery || UPower.displayDevice.percentage > 0.2 ? root.colour : Colours.palette.m3error
fill: 1
}
Behavior on implicitHeight {
Anim {}
}
component Anim: NumberAnimation {
duration: Appearance.anim.durations.large
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.emphasized
}
}
|