Wip Powermenu
This commit is contained in:
parent
fc9a53fb0d
commit
a91c0978c0
3 changed files with 53 additions and 31 deletions
|
|
@ -71,14 +71,22 @@ NBox {
|
||||||
tooltipText: "Power Menu"
|
tooltipText: "Power Menu"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
powerMenu.open(screen)
|
powerMenu.open(screen)
|
||||||
|
sidePanel.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NIconButton {
|
||||||
|
id: closeButton
|
||||||
|
icon: "close"
|
||||||
|
tooltipText: "Close Side Panel"
|
||||||
|
onClicked: {
|
||||||
|
sidePanel.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerMenu {
|
|
||||||
id: powerMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// Uptime
|
// Uptime
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ import qs.Modules.LockScreen
|
||||||
|
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
id: root
|
id: root
|
||||||
|
readonly property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
|
|
||||||
anchors.top: true
|
anchors.top: true
|
||||||
anchors.left: true
|
anchors.left: true
|
||||||
anchors.right: true
|
anchors.right: true
|
||||||
|
|
@ -21,13 +24,12 @@ PanelWindow {
|
||||||
screen: screen
|
screen: screen
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
|
if (visible) {
|
||||||
if (visible) {
|
console.log("Oh Yeah")
|
||||||
console.log("Oh Yeah")
|
// Focus the menu rectangle instead of root
|
||||||
Qt.callLater(() => forceActiveFocus())
|
menuRect.forceActiveFocus()
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
visible = true
|
visible = true
|
||||||
|
|
@ -37,11 +39,14 @@ PanelWindow {
|
||||||
visible = false
|
visible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clicking outside of the rectangle to close
|
// // Clicking outside of the rectangle to close
|
||||||
MouseArea {
|
// MouseArea {
|
||||||
anchors.fill: parent
|
// anchors.fill: parent
|
||||||
onClicked: root.close()
|
// onClicked: root.close()
|
||||||
}
|
// // Prevent this MouseArea from interfering with child elements
|
||||||
|
// propagateComposedEvents: true
|
||||||
|
// z: -1 // Put it behind the menu
|
||||||
|
// }
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// System functions
|
// System functions
|
||||||
|
|
@ -63,28 +68,24 @@ PanelWindow {
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: shutdownProcess
|
id: shutdownProcess
|
||||||
|
|
||||||
command: ["shutdown", "-h", "now"]
|
command: ["shutdown", "-h", "now"]
|
||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: rebootProcess
|
id: rebootProcess
|
||||||
|
|
||||||
command: ["reboot"]
|
command: ["reboot"]
|
||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: suspendProcess
|
id: suspendProcess
|
||||||
|
|
||||||
command: ["systemctl", "suspend"]
|
command: ["systemctl", "suspend"]
|
||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: logoutProcess
|
id: logoutProcess
|
||||||
|
|
||||||
command: ["loginctl", "terminate-user", Quickshell.env("USER")]
|
command: ["loginctl", "terminate-user", Quickshell.env("USER")]
|
||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
|
|
@ -92,27 +93,30 @@ PanelWindow {
|
||||||
property var entriesCount: 5
|
property var entriesCount: 5
|
||||||
property var entryHeight: Style.baseWidgetSize * scaling
|
property var entryHeight: Style.baseWidgetSize * scaling
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: menuRect
|
||||||
width: 160 * scaling
|
width: 160 * scaling
|
||||||
height: (entryHeight * entriesCount) + (Style.marginS * entriesCount * scaling)
|
height: (entryHeight * entriesCount) + (Style.marginS * entriesCount * scaling)
|
||||||
radius: Style.radiusM * scaling
|
radius: Style.radiusM * scaling
|
||||||
border.color: Color.mOutline
|
border.color: Color.mOutline
|
||||||
border.width: Math.max(1, Style.borderS * scaling)
|
border.width: Math.max(1, Style.borderS * scaling)
|
||||||
color: Color.mSurface
|
color: Color.mSurface
|
||||||
|
|
||||||
visible: true
|
visible: true
|
||||||
z: 9999
|
z: 9999
|
||||||
|
|
||||||
|
// Add focus properties
|
||||||
|
focus: true
|
||||||
|
activeFocusOnTab: true
|
||||||
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: Style.marginL * scaling
|
anchors.rightMargin: Style.marginL * scaling
|
||||||
anchors.topMargin: 86 * scaling
|
anchors.topMargin: 86 * scaling
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
console.log("oncompleted")
|
console.log("oncompleted")
|
||||||
Qt.callLater(() => forceActiveFocus())
|
forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -161,15 +165,17 @@ PanelWindow {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: lockButtonArea
|
id: lockButtonArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
// Add acceptedButtons to ensure proper click handling
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Logger.log("PowerMenu", "Lock screen requested")
|
Logger.log("PowerMenu", "Lock screen requested")
|
||||||
// // Lock the screen
|
// // Lock the screen
|
||||||
// lockScreen.isLoaded = true
|
// lockScreen.isLoaded = true
|
||||||
// root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -216,10 +222,11 @@ PanelWindow {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: suspendButtonArea
|
id: suspendButtonArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
suspend()
|
suspend()
|
||||||
root.close()
|
root.close()
|
||||||
|
|
@ -269,10 +276,11 @@ PanelWindow {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: rebootButtonArea
|
id: rebootButtonArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
reboot()
|
reboot()
|
||||||
root.close()
|
root.close()
|
||||||
|
|
@ -322,10 +330,11 @@ PanelWindow {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: logoutButtonArea
|
id: logoutButtonArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
logout()
|
logout()
|
||||||
root.close()
|
root.close()
|
||||||
|
|
@ -375,10 +384,11 @@ PanelWindow {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: shutdownButtonArea
|
id: shutdownButtonArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
shutdown()
|
shutdown()
|
||||||
root.close()
|
root.close()
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ ShellRoot {
|
||||||
id: lockScreen
|
id: lockScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PowerMenu {
|
||||||
|
id: powerMenu
|
||||||
|
}
|
||||||
|
|
||||||
ToastManager {}
|
ToastManager {}
|
||||||
|
|
||||||
IPCManager {}
|
IPCManager {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue