From 8663b36ecbcb076895be60bf5a16c06aef180c40 Mon Sep 17 00:00:00 2001 From: quadbyte Date: Wed, 13 Aug 2025 09:03:09 -0400 Subject: [PATCH] PowerMenu wip --- Modules/Settings/SettingsPanel.qml | 10 +- Modules/SidePanel/Cards/ProfileCard.qml | 381 ++++++++++++++++++++++++ Services/Settings.qml | 2 +- 3 files changed, 386 insertions(+), 7 deletions(-) diff --git a/Modules/Settings/SettingsPanel.qml b/Modules/Settings/SettingsPanel.qml index 7625af4..e237c6a 100644 --- a/Modules/Settings/SettingsPanel.qml +++ b/Modules/Settings/SettingsPanel.qml @@ -20,8 +20,7 @@ NLoader { WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand - property var tabsModel: [ - { + property var tabsModel: [{ "label": "General", "icon": "tune", "source": "Tabs/General.qml" @@ -57,8 +56,7 @@ NLoader { "label": "Wallpaper Selector", "icon": "wallpaper_slideshow", "source": "Tabs/WallpaperSelector.qml" - }, - // { + }, // { // "label": "Misc", // "icon": "more_horiz", // "source": "Tabs/Misc.qml" @@ -112,7 +110,7 @@ NLoader { delegate: Rectangle { id: tabItem - + width: parent.width height: 32 * scaling // Back to original height radius: Style.radiusSmall * scaling @@ -120,7 +118,7 @@ NLoader { border.color: "transparent" border.width: 0 - readonly property bool selected: index === currentTabIndex + readonly property bool selected: index === currentTabIndex // Subtle hover effect: only icon/text color tint on hover property bool hovering: false diff --git a/Modules/SidePanel/Cards/ProfileCard.qml b/Modules/SidePanel/Cards/ProfileCard.qml index 90a23db..3fa605d 100644 --- a/Modules/SidePanel/Cards/ProfileCard.qml +++ b/Modules/SidePanel/Cards/ProfileCard.qml @@ -62,11 +62,18 @@ NBox { } } NIconButton { + id: powerButton icon: "power_settings_new" + onClicked: { + //settingsPanel.isLoaded = !settingsPanel.isLoaded + powerMenu.show() + } } } } + // ---------------------------------- + // Uptime Timer { interval: 60000 repeat: true @@ -99,4 +106,378 @@ NBox { } } } + + // ---------------------------------- + // Logout menu + function logout() { + if (WorkspaceManager.isNiri) { + logoutProcessNiri.running = true + } else if (WorkspaceManager.isHyprland) { + logoutProcessHyprland.running = true + } else { + console.warn("No supported compositor detected for logout") + } + } + + function suspend() { + suspendProcess.running = true + } + + function shutdown() { + shutdownProcess.running = true + } + + function reboot() { + rebootProcess.running = true + } + + function updateSystemInfo() { + uptimeProcess.running = true + } + + + Process { + id: shutdownProcess + + command: ["shutdown", "-h", "now"] + running: false + } + + Process { + id: rebootProcess + + command: ["reboot"] + running: false + } + + Process { + id: suspendProcess + + command: ["systemctl", "suspend"] + running: false + } + + Process { + id: logoutProcessNiri + + command: ["niri", "msg", "action", "quit", "--skip-confirmation"] + running: false + } + + Process { + id: logoutProcessHyprland + + command: ["hyprctl", "dispatch", "exit"] + running: false + } + + Process { + id: logoutProcess + + command: ["loginctl", "terminate-user", Quickshell.env("USER")] + running: false + } + + NPanel { + id: powerMenu + + anchors.top: powerButton.bottom + anchors.right: powerButton.right + + Rectangle { + width: 160 * scaling + height: 220 * scaling + color: Colors.surface + radius: 8 * scaling + border.color: Colors.outline + border.width: 1 * scaling + visible: true + z: 9999 + anchors.top: parent.top + anchors.right: parent.right + anchors.rightMargin: 32 * scaling + anchors.topMargin: powerButton.y + powerButton.height + 48 * scaling + + // Prevent closing when clicking in the panel bg + MouseArea { + anchors.fill: parent + } + + ColumnLayout { + anchors.fill: parent + anchors.margins: 8 * scaling + spacing: 4 * scaling + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 36 * scaling + radius: 6 * scaling + color: lockButtonArea.containsMouse ? Colors.accentPrimary : "transparent" + + Item { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 12 * scaling + anchors.rightMargin: 12 * scaling + + Row { + id: lockRow + spacing: 8 * scaling + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + Text { + text: "lock_outline" + font.family: "Material Symbols Outlined" + font.pixelSize: 16 * scaling + color: lockButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + + Text { + text: "Lock Screen" + font.pixelSize: 14 * scaling + color: lockButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + } + } + + MouseArea { + id: lockButtonArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: { + lockScreen.locked = true + systemMenu.visible = false + } + } + } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 36 * scaling + radius: 6 * scaling + color: suspendButtonArea.containsMouse ? Colors.accentPrimary : "transparent" + + Item { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 12 * scaling + anchors.rightMargin: 12 * scaling + + Row { + id: suspendRow + spacing: 8 * scaling + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + Text { + text: "bedtime" + font.family: "Material Symbols Outlined" + font.pixelSize: 16 * scaling + color: suspendButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + + Text { + text: "Suspend" + font.pixelSize: 14 * scaling + color: suspendButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + } + } + + MouseArea { + id: suspendButtonArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: { + suspend() + systemMenu.visible = false + } + } + } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 36 * scaling + radius: 6 * scaling + color: rebootButtonArea.containsMouse ? Colors.accentPrimary : "transparent" + + Item { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 12 * scaling + anchors.rightMargin: 12 * scaling + + Row { + id: rebootRow + spacing: 8 * scaling + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + Text { + text: "refresh" + font.family: "Material Symbols Outlined" + font.pixelSize: 16 * scaling + color: rebootButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + + Text { + text: "Reboot" + font.pixelSize: 14 * scaling + color: rebootButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + } + } + + MouseArea { + id: rebootButtonArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: { + reboot() + systemMenu.visible = false + } + } + } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 36 * scaling + radius: 6 * scaling + color: logoutButtonArea.containsMouse ? Colors.accentPrimary : "transparent" + + Item { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 12 * scaling + anchors.rightMargin: 12 * scaling + + Row { + id: logoutRow + spacing: 8 * scaling + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + Text { + text: "exit_to_app" + font.family: "Material Symbols Outlined" + font.pixelSize: 16 * scaling + color: logoutButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + + Text { + text: "Logout" + font.pixelSize: 14 * scaling + color: logoutButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + } + } + + MouseArea { + id: logoutButtonArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: { + logout() + systemMenu.visible = false + } + } + } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 36 * scaling + radius: 6 * scaling + color: shutdownButtonArea.containsMouse ? Colors.accentPrimary : "transparent" + + Item { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 12 * scaling + anchors.rightMargin: 12 * scaling + + Row { + id: shutdownRow + spacing: 8 * scaling + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + Text { + text: "power_settings_new" + font.family: "Material Symbols Outlined" + font.pixelSize: 16 * scaling + color: shutdownButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + + Text { + text: "Shutdown" + font.pixelSize: 14 * scaling + color: shutdownButtonArea.containsMouse ? Colors.onAccent : Colors.textPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 * scaling + } + } + } + + MouseArea { + id: shutdownButtonArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: { + shutdown() + systemMenu.visible = false + } + } + } + } + } + } } diff --git a/Services/Settings.qml b/Services/Settings.qml index 392f42e..301714a 100644 --- a/Services/Settings.qml +++ b/Services/Settings.qml @@ -53,7 +53,7 @@ Singleton { onLoaded: function () { Qt.callLater(function () { if (adapter.wallpaper.current !== "") { - console.log("Settings: Initializing wallpaper to:", adapter.wallpaper.current) + console.log("[Settings] Set current wallpaper") Wallpapers.setCurrentWallpaper(adapter.wallpaper.current, true) } })