forked from Shinonome/dots-hyprland
put session menu in loader
This commit is contained in:
@@ -17,178 +17,186 @@ Scope {
|
|||||||
id: sessionVariants
|
id: sessionVariants
|
||||||
model: Quickshell.screens
|
model: Quickshell.screens
|
||||||
|
|
||||||
PanelWindow { // Session menu
|
Loader {
|
||||||
id: sessionRoot
|
id: sessionLoader
|
||||||
visible: false
|
|
||||||
|
|
||||||
property var modelData
|
property var modelData
|
||||||
property string subtitle
|
active: false
|
||||||
|
|
||||||
screen: modelData
|
PanelWindow { // Session menu
|
||||||
exclusionMode: ExclusionMode.Ignore
|
id: sessionRoot
|
||||||
WlrLayershell.namespace: "quickshell:session"
|
visible: sessionLoader.active
|
||||||
WlrLayershell.layer: WlrLayer.Overlay
|
|
||||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
function hide() {
|
||||||
color: Appearance.transparentize(Appearance.m3colors.m3background, 0.3)
|
sessionLoader.active = false
|
||||||
|
|
||||||
anchors {
|
|
||||||
top: true
|
|
||||||
left: true
|
|
||||||
right: true
|
|
||||||
}
|
|
||||||
|
|
||||||
implicitWidth: modelData.width
|
|
||||||
implicitHeight: modelData.height
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: sessionMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
sessionRoot.visible = false
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout { // Content column
|
property string subtitle
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: 15
|
|
||||||
|
|
||||||
Keys.onPressed: (event) => {
|
screen: modelData
|
||||||
if (event.key === Qt.Key_Escape) {
|
exclusionMode: ExclusionMode.Ignore
|
||||||
sessionRoot.visible = false;
|
WlrLayershell.namespace: "quickshell:session"
|
||||||
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||||
|
color: Appearance.transparentize(Appearance.m3colors.m3background, 0.3)
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: true
|
||||||
|
left: true
|
||||||
|
right: true
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitWidth: modelData.width
|
||||||
|
implicitHeight: modelData.height
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: sessionMouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
sessionRoot.hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout { // Content column
|
||||||
Layout.alignment: Qt.AlignHCenter
|
anchors.centerIn: parent
|
||||||
spacing: 0
|
|
||||||
StyledText { // Title
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
font.family: Appearance.font.family.title
|
|
||||||
font.pixelSize: Appearance.font.pixelSize.title
|
|
||||||
font.weight: Font.DemiBold
|
|
||||||
text: qsTr("Session")
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText { // Small instruction
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
font.family: Appearance.font.family.title
|
|
||||||
font.pixelSize: Appearance.font.pixelSize.normal
|
|
||||||
text: qsTr("Arrow keys to navigate, Enter to select\nEsc or click anywhere to cancel")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout { // First row of buttons
|
|
||||||
spacing: 15
|
spacing: 15
|
||||||
SessionActionButton {
|
|
||||||
id: sessionLock
|
|
||||||
focus: sessionRoot.visible
|
|
||||||
buttonIcon: "lock"
|
|
||||||
buttonText: qsTr("Lock")
|
|
||||||
onClicked: { Hyprland.dispatch("exec loginctl lock-session"); sessionRoot.visible = false }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.right: sessionSleep
|
|
||||||
KeyNavigation.down: sessionHibernate
|
|
||||||
}
|
|
||||||
SessionActionButton {
|
|
||||||
id: sessionSleep
|
|
||||||
buttonIcon: "dark_mode"
|
|
||||||
buttonText: qsTr("Sleep")
|
|
||||||
onClicked: { Hyprland.dispatch("exec systemctl suspend || loginctl suspend"); sessionRoot.visible = false }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.left: sessionLock
|
|
||||||
KeyNavigation.right: sessionLogout
|
|
||||||
KeyNavigation.down: sessionShutdown
|
|
||||||
}
|
|
||||||
SessionActionButton {
|
|
||||||
id: sessionLogout
|
|
||||||
buttonIcon: "logout"
|
|
||||||
buttonText: qsTr("Logout")
|
|
||||||
onClicked: { Hyprland.dispatch("exec pkill Hyprland"); sessionRoot.visible = false }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.left: sessionSleep
|
|
||||||
KeyNavigation.right: sessionTaskManager
|
|
||||||
KeyNavigation.down: sessionReboot
|
|
||||||
}
|
|
||||||
SessionActionButton {
|
|
||||||
id: sessionTaskManager
|
|
||||||
buttonIcon: "browse_activity"
|
|
||||||
buttonText: qsTr("Task Manager")
|
|
||||||
onClicked: { Hyprland.dispatch("exec gnome-system-monitor & disown"); sessionRoot.visible = false }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.left: sessionLogout
|
|
||||||
KeyNavigation.down: sessionFirmwareReboot
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout { // Second row of buttons
|
Keys.onPressed: (event) => {
|
||||||
spacing: 15
|
if (event.key === Qt.Key_Escape) {
|
||||||
SessionActionButton {
|
sessionRoot.hide();
|
||||||
id: sessionHibernate
|
|
||||||
buttonIcon: "downloading"
|
|
||||||
buttonText: qsTr("Hibernate")
|
|
||||||
onClicked: { Hyprland.dispatch("exec systemctl hibernate || loginctl hibernate"); sessionRoot.visible = false }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.up: sessionLock
|
|
||||||
KeyNavigation.right: sessionShutdown
|
|
||||||
}
|
|
||||||
SessionActionButton {
|
|
||||||
id: sessionShutdown
|
|
||||||
buttonIcon: "power_settings_new"
|
|
||||||
buttonText: qsTr("Shutdown")
|
|
||||||
onClicked: { Hyprland.dispatch("exec systemctl poweroff || loginctl poweroff"); sessionRoot.visible = false }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.left: sessionHibernate
|
|
||||||
KeyNavigation.right: sessionReboot
|
|
||||||
KeyNavigation.up: sessionSleep
|
|
||||||
}
|
|
||||||
SessionActionButton {
|
|
||||||
id: sessionReboot
|
|
||||||
buttonIcon: "restart_alt"
|
|
||||||
buttonText: qsTr("Reboot")
|
|
||||||
onClicked: { Hyprland.dispatch("exec reboot || loginctl reboot"); sessionRoot.visible = false }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.left: sessionShutdown
|
|
||||||
KeyNavigation.right: sessionFirmwareReboot
|
|
||||||
KeyNavigation.up: sessionLogout
|
|
||||||
}
|
|
||||||
SessionActionButton {
|
|
||||||
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 }
|
|
||||||
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
|
||||||
KeyNavigation.up: sessionTaskManager
|
|
||||||
KeyNavigation.left: sessionReboot
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
radius: Appearance.rounding.normal
|
|
||||||
implicitHeight: sessionSubtitle.implicitHeight + 10 * 2
|
|
||||||
implicitWidth: sessionSubtitle.implicitWidth + 15 * 2
|
|
||||||
color: Appearance.colors.colTooltip
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
|
||||||
SmoothedAnimation {
|
|
||||||
velocity: Appearance.animation.elementMoveFast.velocity
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
ColumnLayout {
|
||||||
id: sessionSubtitle
|
Layout.alignment: Qt.AlignHCenter
|
||||||
anchors.centerIn: parent
|
spacing: 0
|
||||||
color: Appearance.colors.colOnTooltip
|
StyledText { // Title
|
||||||
text: sessionRoot.subtitle
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
font.family: Appearance.font.family.title
|
||||||
|
font.pixelSize: Appearance.font.pixelSize.title
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
text: qsTr("Session")
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText { // Small instruction
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
font.family: Appearance.font.family.title
|
||||||
|
font.pixelSize: Appearance.font.pixelSize.normal
|
||||||
|
text: qsTr("Arrow keys to navigate, Enter to select\nEsc or click anywhere to cancel")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout { // First row of buttons
|
||||||
|
spacing: 15
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionLock
|
||||||
|
focus: sessionRoot.visible
|
||||||
|
buttonIcon: "lock"
|
||||||
|
buttonText: qsTr("Lock")
|
||||||
|
onClicked: { Hyprland.dispatch("exec loginctl lock-session"); sessionRoot.hide() }
|
||||||
|
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||||
|
KeyNavigation.right: sessionSleep
|
||||||
|
KeyNavigation.down: sessionHibernate
|
||||||
|
}
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionSleep
|
||||||
|
buttonIcon: "dark_mode"
|
||||||
|
buttonText: qsTr("Sleep")
|
||||||
|
onClicked: { Hyprland.dispatch("exec systemctl suspend || loginctl suspend"); sessionRoot.hide() }
|
||||||
|
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||||
|
KeyNavigation.left: sessionLock
|
||||||
|
KeyNavigation.right: sessionLogout
|
||||||
|
KeyNavigation.down: sessionShutdown
|
||||||
|
}
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionLogout
|
||||||
|
buttonIcon: "logout"
|
||||||
|
buttonText: qsTr("Logout")
|
||||||
|
onClicked: { Hyprland.dispatch("exec pkill Hyprland"); sessionRoot.hide() }
|
||||||
|
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||||
|
KeyNavigation.left: sessionSleep
|
||||||
|
KeyNavigation.right: sessionTaskManager
|
||||||
|
KeyNavigation.down: sessionReboot
|
||||||
|
}
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionTaskManager
|
||||||
|
buttonIcon: "browse_activity"
|
||||||
|
buttonText: qsTr("Task Manager")
|
||||||
|
onClicked: { Hyprland.dispatch("exec gnome-system-monitor & disown"); sessionRoot.hide() }
|
||||||
|
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||||
|
KeyNavigation.left: sessionLogout
|
||||||
|
KeyNavigation.down: sessionFirmwareReboot
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout { // Second row of buttons
|
||||||
|
spacing: 15
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionHibernate
|
||||||
|
buttonIcon: "downloading"
|
||||||
|
buttonText: qsTr("Hibernate")
|
||||||
|
onClicked: { Hyprland.dispatch("exec systemctl hibernate || loginctl hibernate"); sessionRoot.hide() }
|
||||||
|
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||||
|
KeyNavigation.up: sessionLock
|
||||||
|
KeyNavigation.right: sessionShutdown
|
||||||
|
}
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionShutdown
|
||||||
|
buttonIcon: "power_settings_new"
|
||||||
|
buttonText: qsTr("Shutdown")
|
||||||
|
onClicked: { Hyprland.dispatch("exec systemctl poweroff || loginctl poweroff"); sessionRoot.hide() }
|
||||||
|
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||||
|
KeyNavigation.left: sessionHibernate
|
||||||
|
KeyNavigation.right: sessionReboot
|
||||||
|
KeyNavigation.up: sessionSleep
|
||||||
|
}
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionReboot
|
||||||
|
buttonIcon: "restart_alt"
|
||||||
|
buttonText: qsTr("Reboot")
|
||||||
|
onClicked: { Hyprland.dispatch("exec reboot || loginctl reboot"); sessionRoot.hide() }
|
||||||
|
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
|
||||||
|
KeyNavigation.left: sessionShutdown
|
||||||
|
KeyNavigation.right: sessionFirmwareReboot
|
||||||
|
KeyNavigation.up: sessionLogout
|
||||||
|
}
|
||||||
|
SessionActionButton {
|
||||||
|
id: sessionFirmwareReboot
|
||||||
|
buttonIcon: "settings_applications"
|
||||||
|
buttonText: qsTr("Reboot to firmware settings")
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
radius: Appearance.rounding.normal
|
||||||
|
implicitHeight: sessionSubtitle.implicitHeight + 10 * 2
|
||||||
|
implicitWidth: sessionSubtitle.implicitWidth + 15 * 2
|
||||||
|
color: Appearance.colors.colTooltip
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Behavior on implicitWidth {
|
||||||
|
SmoothedAnimation {
|
||||||
|
velocity: Appearance.animation.elementMoveFast.velocity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: sessionSubtitle
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color: Appearance.colors.colOnTooltip
|
||||||
|
text: sessionRoot.subtitle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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