feat: power profile widget
This commit is contained in:
parent
32c9328684
commit
9528b10015
2 changed files with 58 additions and 1 deletions
|
|
@ -65,7 +65,7 @@ QtObject {
|
||||||
// This is where you should add your Modules/Bar/Widgets/
|
// This is where you should add your Modules/Bar/Widgets/
|
||||||
// so it gets registered in the BarTab
|
// so it gets registered in the BarTab
|
||||||
function discoverAvailableWidgets() {
|
function discoverAvailableWidgets() {
|
||||||
const widgetFiles = ["ActiveWindow", "Battery", "Bluetooth", "Brightness", "Clock", "MediaMini", "NotificationHistory", "ScreenRecorderIndicator", "SidePanelToggle", "SystemMonitor", "Tray", "Volume", "WiFi", "Workspace"]
|
const widgetFiles = ["ActiveWindow", "Battery", "Bluetooth", "Brightness", "Clock", "MediaMini", "NotificationHistory", "PowerProfile", "ScreenRecorderIndicator", "SidePanelToggle", "SystemMonitor", "Tray", "Volume", "WiFi", "Workspace"]
|
||||||
|
|
||||||
const availableWidgets = []
|
const availableWidgets = []
|
||||||
|
|
||||||
|
|
|
||||||
57
Modules/Bar/Widgets/PowerProfile.qml
Normal file
57
Modules/Bar/Widgets/PowerProfile.qml
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Services.UPower
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import qs.Commons
|
||||||
|
import qs.Services
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
|
NIconButton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property var powerProfiles: PowerProfiles
|
||||||
|
readonly property bool hasPP: powerProfiles.hasPerformanceProfile
|
||||||
|
|
||||||
|
sizeMultiplier: 0.8
|
||||||
|
visible: hasPP
|
||||||
|
|
||||||
|
function profileIcon() {
|
||||||
|
if (!hasPP)
|
||||||
|
return "balance"
|
||||||
|
if (powerProfiles.profile === PowerProfile.Performance)
|
||||||
|
return "speed"
|
||||||
|
if (powerProfiles.profile === PowerProfile.Balanced)
|
||||||
|
return "balance"
|
||||||
|
if (powerProfiles.profile === PowerProfile.PowerSaver)
|
||||||
|
return "eco"
|
||||||
|
}
|
||||||
|
|
||||||
|
function profileName() {
|
||||||
|
if (!hasPP)
|
||||||
|
return "Unknown"
|
||||||
|
if (powerProfiles.profile === PowerProfile.Performance)
|
||||||
|
return "Performance"
|
||||||
|
if (powerProfiles.profile === PowerProfile.Balanced)
|
||||||
|
return "Balanced"
|
||||||
|
if (powerProfiles.profile === PowerProfile.PowerSaver)
|
||||||
|
return "Power Saver"
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeProfile() {
|
||||||
|
if (!hasPP) return;
|
||||||
|
if (powerProfiles.profile === PowerProfile.Performance)
|
||||||
|
powerProfiles.profile = PowerProfile.Balanced
|
||||||
|
else if (powerProfiles.profile === PowerProfile.Balanced)
|
||||||
|
powerProfiles.profile = PowerProfile.PowerSaver
|
||||||
|
else if (powerProfiles.profile === PowerProfile.PowerSaver)
|
||||||
|
powerProfiles.profile = PowerProfile.Performance
|
||||||
|
}
|
||||||
|
|
||||||
|
icon: root.profileIcon()
|
||||||
|
tooltipText: root.profileName()
|
||||||
|
colorBg: Color.mSurfaceVariant
|
||||||
|
colorFg: Color.mOnSurface
|
||||||
|
colorBorder: Color.transparent
|
||||||
|
colorBorderHover: Color.transparent
|
||||||
|
onClicked: root.changeProfile()
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue