forked from Shinonome/dots-hyprland
put session menu in loader
This commit is contained in:
@@ -17,11 +17,19 @@ Scope {
|
||||
id: sessionVariants
|
||||
model: Quickshell.screens
|
||||
|
||||
Loader {
|
||||
id: sessionLoader
|
||||
property var modelData
|
||||
active: false
|
||||
|
||||
PanelWindow { // Session menu
|
||||
id: sessionRoot
|
||||
visible: false
|
||||
visible: sessionLoader.active
|
||||
|
||||
function hide() {
|
||||
sessionLoader.active = false
|
||||
}
|
||||
|
||||
property var modelData
|
||||
property string subtitle
|
||||
|
||||
screen: modelData
|
||||
@@ -44,7 +52,7 @@ Scope {
|
||||
id: sessionMouseArea
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
sessionRoot.visible = false
|
||||
sessionRoot.hide()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +62,7 @@ Scope {
|
||||
|
||||
Keys.onPressed: (event) => {
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
sessionRoot.visible = false;
|
||||
sessionRoot.hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +94,7 @@ Scope {
|
||||
focus: sessionRoot.visible
|
||||
buttonIcon: "lock"
|
||||
buttonText: qsTr("Lock")
|
||||
onClicked: { Hyprland.dispatch("exec loginctl lock-session"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec loginctl lock-session"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.right: sessionSleep
|
||||
KeyNavigation.down: sessionHibernate
|
||||
@@ -95,7 +103,7 @@ Scope {
|
||||
id: sessionSleep
|
||||
buttonIcon: "dark_mode"
|
||||
buttonText: qsTr("Sleep")
|
||||
onClicked: { Hyprland.dispatch("exec systemctl suspend || loginctl suspend"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec systemctl suspend || loginctl suspend"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.left: sessionLock
|
||||
KeyNavigation.right: sessionLogout
|
||||
@@ -105,7 +113,7 @@ Scope {
|
||||
id: sessionLogout
|
||||
buttonIcon: "logout"
|
||||
buttonText: qsTr("Logout")
|
||||
onClicked: { Hyprland.dispatch("exec pkill Hyprland"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec pkill Hyprland"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.left: sessionSleep
|
||||
KeyNavigation.right: sessionTaskManager
|
||||
@@ -115,7 +123,7 @@ Scope {
|
||||
id: sessionTaskManager
|
||||
buttonIcon: "browse_activity"
|
||||
buttonText: qsTr("Task Manager")
|
||||
onClicked: { Hyprland.dispatch("exec gnome-system-monitor & disown"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec gnome-system-monitor & disown"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.left: sessionLogout
|
||||
KeyNavigation.down: sessionFirmwareReboot
|
||||
@@ -128,7 +136,7 @@ Scope {
|
||||
id: sessionHibernate
|
||||
buttonIcon: "downloading"
|
||||
buttonText: qsTr("Hibernate")
|
||||
onClicked: { Hyprland.dispatch("exec systemctl hibernate || loginctl hibernate"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec systemctl hibernate || loginctl hibernate"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.up: sessionLock
|
||||
KeyNavigation.right: sessionShutdown
|
||||
@@ -137,7 +145,7 @@ Scope {
|
||||
id: sessionShutdown
|
||||
buttonIcon: "power_settings_new"
|
||||
buttonText: qsTr("Shutdown")
|
||||
onClicked: { Hyprland.dispatch("exec systemctl poweroff || loginctl poweroff"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec systemctl poweroff || loginctl poweroff"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.left: sessionHibernate
|
||||
KeyNavigation.right: sessionReboot
|
||||
@@ -147,7 +155,7 @@ Scope {
|
||||
id: sessionReboot
|
||||
buttonIcon: "restart_alt"
|
||||
buttonText: qsTr("Reboot")
|
||||
onClicked: { Hyprland.dispatch("exec reboot || loginctl reboot"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec reboot || loginctl reboot"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.left: sessionShutdown
|
||||
KeyNavigation.right: sessionFirmwareReboot
|
||||
@@ -157,7 +165,7 @@ Scope {
|
||||
id: sessionFirmwareReboot
|
||||
buttonIcon: "settings_applications"
|
||||
buttonText: qsTr("Reboot to firmware settings")
|
||||
onClicked: { Hyprland.dispatch("exec systemctl reboot --firmware-setup || loginctl reboot --firmware-setup"); sessionRoot.visible = false }
|
||||
onClicked: { Hyprland.dispatch("exec systemctl reboot --firmware-setup || loginctl reboot --firmware-setup"); sessionRoot.hide() }
|
||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||
KeyNavigation.up: sessionTaskManager
|
||||
KeyNavigation.left: sessionReboot
|
||||
@@ -188,7 +196,7 @@ Scope {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
@@ -196,28 +204,22 @@ Scope {
|
||||
|
||||
function toggle(): void {
|
||||
for (let i = 0; i < sessionVariants.instances.length; i++) {
|
||||
let panelWindow = sessionVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = !panelWindow.visible;
|
||||
}
|
||||
let loader = sessionVariants.instances[i];
|
||||
loader.active = !loader.active;
|
||||
}
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
for (let i = 0; i < sessionVariants.instances.length; i++) {
|
||||
let panelWindow = sessionVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = false;
|
||||
}
|
||||
let loader = sessionVariants.instances[i];
|
||||
loader.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
function open(): void {
|
||||
for (let i = 0; i < sessionVariants.instances.length; i++) {
|
||||
let panelWindow = sessionVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = true;
|
||||
}
|
||||
let loader = sessionVariants.instances[i];
|
||||
loader.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,23 +230,20 @@ Scope {
|
||||
|
||||
onPressed: {
|
||||
for (let i = 0; i < sessionVariants.instances.length; i++) {
|
||||
let panelWindow = sessionVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = !panelWindow.visible;
|
||||
}
|
||||
let loader = sessionVariants.instances[i];
|
||||
loader.active = !loader.active;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut {
|
||||
name: "sessionOpen"
|
||||
description: "Opens session screen on press"
|
||||
|
||||
onPressed: {
|
||||
for (let i = 0; i < sessionVariants.instances.length; i++) {
|
||||
let panelWindow = sessionVariants.instances[i];
|
||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||
panelWindow.visible = true
|
||||
}
|
||||
let loader = sessionVariants.instances[i];
|
||||
loader.active = !loader.active;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user