From 4d39169eb83649a49e1e7018775aadffce583cf6 Mon Sep 17 00:00:00 2001 From: Pi Home Server Date: Sat, 6 Dec 2025 02:29:39 +0100 Subject: [PATCH] Feature/control center widget fix (#912) * Add a widget to display the power menu * Update power button widget * Upate based on new settings * Rollback to DisplaysTab.qml --- quickshell/Modules/DankBar/DankBarContent.qml | 86 ++++++++++++------- quickshell/Modules/DankBar/WidgetHost.qml | 3 +- .../DankBar/Widgets/PowerMenuButton.qml | 24 ++++++ quickshell/Modules/Settings/DisplaysTab.qml | 2 +- quickshell/Modules/Settings/WidgetsTab.qml | 9 +- 5 files changed, 89 insertions(+), 35 deletions(-) create mode 100644 quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml diff --git a/quickshell/Modules/DankBar/DankBarContent.qml b/quickshell/Modules/DankBar/DankBarContent.qml index 0688e7b4..79e3f1ee 100644 --- a/quickshell/Modules/DankBar/DankBarContent.qml +++ b/quickshell/Modules/DankBar/DankBarContent.qml @@ -302,7 +302,8 @@ Item { "vpn": vpnComponent, "notepadButton": notepadButtonComponent, "colorPicker": colorPickerComponent, - "systemUpdate": systemUpdateComponent + "systemUpdate": systemUpdateComponent, + "powerMenuButton": powerMenuButtonComponent }; let pluginMap = PluginService.getWidgetComponents(); @@ -314,36 +315,37 @@ Item { } readonly property var allComponents: ({ - "launcherButtonComponent": launcherButtonComponent, - "workspaceSwitcherComponent": workspaceSwitcherComponent, - "focusedWindowComponent": focusedWindowComponent, - "runningAppsComponent": runningAppsComponent, - "clockComponent": clockComponent, - "mediaComponent": mediaComponent, - "weatherComponent": weatherComponent, - "systemTrayComponent": systemTrayComponent, - "privacyIndicatorComponent": privacyIndicatorComponent, - "clipboardComponent": clipboardComponent, - "cpuUsageComponent": cpuUsageComponent, - "memUsageComponent": memUsageComponent, - "diskUsageComponent": diskUsageComponent, - "cpuTempComponent": cpuTempComponent, - "gpuTempComponent": gpuTempComponent, - "notificationButtonComponent": notificationButtonComponent, - "batteryComponent": batteryComponent, - "layoutComponent": layoutComponent, - "controlCenterButtonComponent": controlCenterButtonComponent, - "capsLockIndicatorComponent": capsLockIndicatorComponent, - "idleInhibitorComponent": idleInhibitorComponent, - "spacerComponent": spacerComponent, - "separatorComponent": separatorComponent, - "networkComponent": networkComponent, - "keyboardLayoutNameComponent": keyboardLayoutNameComponent, - "vpnComponent": vpnComponent, - "notepadButtonComponent": notepadButtonComponent, - "colorPickerComponent": colorPickerComponent, - "systemUpdateComponent": systemUpdateComponent - }) + "launcherButtonComponent": launcherButtonComponent, + "workspaceSwitcherComponent": workspaceSwitcherComponent, + "focusedWindowComponent": focusedWindowComponent, + "runningAppsComponent": runningAppsComponent, + "clockComponent": clockComponent, + "mediaComponent": mediaComponent, + "weatherComponent": weatherComponent, + "systemTrayComponent": systemTrayComponent, + "privacyIndicatorComponent": privacyIndicatorComponent, + "clipboardComponent": clipboardComponent, + "cpuUsageComponent": cpuUsageComponent, + "memUsageComponent": memUsageComponent, + "diskUsageComponent": diskUsageComponent, + "cpuTempComponent": cpuTempComponent, + "gpuTempComponent": gpuTempComponent, + "notificationButtonComponent": notificationButtonComponent, + "batteryComponent": batteryComponent, + "layoutComponent": layoutComponent, + "controlCenterButtonComponent": controlCenterButtonComponent, + "capsLockIndicatorComponent": capsLockIndicatorComponent, + "idleInhibitorComponent": idleInhibitorComponent, + "spacerComponent": spacerComponent, + "separatorComponent": separatorComponent, + "networkComponent": networkComponent, + "keyboardLayoutNameComponent": keyboardLayoutNameComponent, + "vpnComponent": vpnComponent, + "notepadButtonComponent": notepadButtonComponent, + "colorPickerComponent": colorPickerComponent, + "systemUpdateComponent": systemUpdateComponent, + "powerMenuButtonComponent": powerMenuButtonComponent + }) Item { id: stackContainer @@ -532,7 +534,27 @@ Item { section: topBarContent.getWidgetSection(parent) parentScreen: barWindow.screen onClicked: { - clipboardHistoryModalPopup.toggle(); + clipboardHistoryModalPopup.toggle() + } + } + } + + Component { + id: powerMenuButtonComponent + + PowerMenuButton { + widgetThickness: barWindow.widgetThickness + barThickness: barWindow.effectiveBarThickness + axis: barWindow.axis + section: topBarContent.getWidgetSection(parent) + parentScreen: barWindow.screen + onClicked: { + if (powerMenuModalLoader) { + powerMenuModalLoader.active = true + if (powerMenuModalLoader.item) { + powerMenuModalLoader.item.openCentered() + } + } } } } diff --git a/quickshell/Modules/DankBar/WidgetHost.qml b/quickshell/Modules/DankBar/WidgetHost.qml index dc0ae991..9f729592 100644 --- a/quickshell/Modules/DankBar/WidgetHost.qml +++ b/quickshell/Modules/DankBar/WidgetHost.qml @@ -237,7 +237,8 @@ Loader { "notepadButton": components.notepadButtonComponent, "colorPicker": components.colorPickerComponent, "systemUpdate": components.systemUpdateComponent, - "layout": components.layoutComponent + "layout": components.layoutComponent, + "powerMenuButton": components.powerMenuButtonComponent }; if (componentMap[widgetId]) { diff --git a/quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml b/quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml new file mode 100644 index 00000000..f2068c06 --- /dev/null +++ b/quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml @@ -0,0 +1,24 @@ +import QtQuick +import qs.Common +import qs.Modules.Plugins +import qs.Widgets + +BasePill { + id: root + + property bool isActive: false + + content: Component { + Item { + implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitHeight: root.widgetThickness - root.horizontalPadding * 2 + + DankIcon { + anchors.centerIn: parent + name: "power_settings_new" + size: Theme.barIconSize(root.barThickness) + color: Theme.widgetIconColor + } + } + } +} \ No newline at end of file diff --git a/quickshell/Modules/Settings/DisplaysTab.qml b/quickshell/Modules/Settings/DisplaysTab.qml index 9dfb7004..064de8b0 100644 --- a/quickshell/Modules/Settings/DisplaysTab.qml +++ b/quickshell/Modules/Settings/DisplaysTab.qml @@ -905,4 +905,4 @@ Item { } } } -} +} \ No newline at end of file diff --git a/quickshell/Modules/Settings/WidgetsTab.qml b/quickshell/Modules/Settings/WidgetsTab.qml index b279c036..cc2a6e97 100644 --- a/quickshell/Modules/Settings/WidgetsTab.qml +++ b/quickshell/Modules/Settings/WidgetsTab.qml @@ -239,7 +239,14 @@ Item { "description": I18n.tr("Check for system updates"), "icon": "update", "enabled": SystemUpdateService.distributionSupported - } + }, + { + "id": "powerMenuButton", + "text": I18n.tr("Power"), + "description": I18n.tr("Display the power system menu"), + "icon": "power_settings_new", + "enabled": true + }, ]; var allPluginVariants = PluginService.getAllPluginVariants();