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