me like nix
1import QtQuick
2import QtQuick.Layouts
3import Quickshell
4import "../../../config" as Config
5import "../../../components"
6import "../../../services" as Services
7
8PopupWindow {
9 id: profilePopout
10
11 property bool show: false
12 property var parentWindow
13 property real anchorY: 0
14 signal close()
15
16 visible: show || contentRect.opacity > 0
17 anchor.window: parentWindow
18 anchor.onAnchoring: {
19 anchor.rect.x = parentWindow.width + 8
20 anchor.rect.y = Math.max(0, anchorY - implicitHeight / 2)
21 }
22
23 implicitWidth: 240
24 implicitHeight: profileContent.implicitHeight + 32
25 color: "transparent"
26
27 onShowChanged: {
28 if (show) { contentRect._opening = true; fadeIn.start() }
29 else { fadeIn.stop(); contentRect._opening = false; contentRect.opacity = 0 }
30 }
31 Timer { id: fadeIn; interval: 16; onTriggered: contentRect.opacity = 1 }
32
33 Rectangle {
34 id: contentRect
35 anchors.fill: parent
36 color: Config.Colours.base
37 radius: Config.Appearance.rounding.large
38 border.width: 1
39 border.color: Config.Colours.surface0
40 opacity: 0
41 property bool _opening: false
42 Behavior on opacity {
43 Anim {
44 duration: contentRect._opening ? Config.Appearance.anim.durations.normal : Config.Appearance.anim.durations.small
45 easing.bezierCurve: contentRect._opening ? Config.Appearance.anim.curves.standardDecel : Config.Appearance.anim.curves.standardAccel
46 }
47 }
48
49 ColumnLayout {
50 id: profileContent
51 anchors.fill: parent
52 anchors.margins: 16
53 spacing: 12
54
55 // Battery info
56 RowLayout {
57 Layout.fillWidth: true
58 spacing: 8
59
60 Text {
61 color: {
62 if (Services.Battery.percent <= 20) return Config.Colours.red
63 if (Services.Battery.status === "Charging") return Config.Colours.green
64 return Config.Colours.green
65 }
66 font.family: Config.Appearance.font.family
67 font.pixelSize: 20
68 text: {
69 if (Services.Battery.status === "Charging") return "\uf0e7"
70 if (Services.Battery.percent > 75) return "\uf240"
71 if (Services.Battery.percent > 50) return "\uf241"
72 if (Services.Battery.percent > 25) return "\uf242"
73 if (Services.Battery.percent > 10) return "\uf243"
74 return "\uf244"
75 }
76 }
77
78 ColumnLayout {
79 spacing: 2
80 Text {
81 color: Config.Colours.text
82 font.family: Config.Appearance.font.family
83 font.pixelSize: Config.Appearance.font.size.normal
84 text: Services.Battery.percent > 0 ? Services.Battery.percent + "%" : "No battery detected"
85 }
86 Text {
87 color: Config.Colours.subtext0
88 font.family: Config.Appearance.font.family
89 font.pixelSize: Config.Appearance.font.size.small
90 text: {
91 if (Services.PowerProfile.profile === "power-saver") return "Power profile: Power Saver"
92 if (Services.PowerProfile.profile === "performance") return "Power profile: Performance"
93 if (Services.PowerProfile.profile === "balanced") return "Power profile: Balanced"
94 return "Power profile: " + Services.PowerProfile.profile
95 }
96 }
97 }
98 }
99
100 Rectangle { Layout.fillWidth: true; height: 1; color: Config.Colours.surface1 }
101
102 // Profile buttons
103 RowLayout {
104 Layout.fillWidth: true
105 Layout.alignment: Qt.AlignHCenter
106 spacing: 12
107
108 Repeater {
109 model: [
110 { id: "performance", icon: "\uf0e7", label: "Perf", color: Config.Colours.peach },
111 { id: "balanced", icon: "\uf24e", label: "Bal", color: Config.Colours.blue },
112 { id: "power-saver", icon: "\uf06c", label: "Saver", color: Config.Colours.green }
113 ]
114
115 delegate: Rectangle {
116 required property var modelData
117 width: 56; height: 56
118 radius: Config.Appearance.rounding.full
119 color: {
120 if (Services.PowerProfile.profile === modelData.id)
121 return Qt.rgba(modelData.color.r, modelData.color.g, modelData.color.b, 0.25)
122 return profileMouse.containsMouse ? Config.Colours.surface1 : Config.Colours.surface0
123 }
124 border.width: Services.PowerProfile.profile === modelData.id ? 2 : 0
125 border.color: modelData.color
126 Behavior on color { CAnim {} }
127
128 ColumnLayout {
129 anchors.centerIn: parent
130 spacing: 2
131 Text {
132 Layout.alignment: Qt.AlignHCenter
133 color: modelData.color
134 font.family: Config.Appearance.font.family
135 font.pixelSize: 18
136 text: modelData.icon
137 }
138 Text {
139 Layout.alignment: Qt.AlignHCenter
140 color: Config.Colours.subtext0
141 font.family: Config.Appearance.font.family
142 font.pixelSize: 9
143 text: modelData.label
144 }
145 }
146
147 MouseArea {
148 id: profileMouse
149 anchors.fill: parent
150 hoverEnabled: true
151 cursorShape: Qt.PointingHandCursor
152 onClicked: Services.PowerProfile.setProfile(modelData.id)
153 }
154 }
155 }
156 }
157 }
158
159 Keys.onEscapePressed: profilePopout.close()
160 }
161
162 MouseArea { anchors.fill: parent; z: -1; onClicked: profilePopout.close() }
163}