right sidebar: unload only content not panelwindow

This commit is contained in:
end-4
2025-05-22 14:58:37 +02:00
parent fa8104480b
commit f366b9aca6
@@ -19,50 +19,48 @@ Scope {
property int sidebarWidth: Appearance.sizes.sidebarWidth property int sidebarWidth: Appearance.sizes.sidebarWidth
property int sidebarPadding: 15 property int sidebarPadding: 15
Loader { PanelWindow {
id: sidebarLoader id: sidebarRoot
active: false visible: GlobalStates.sidebarRightOpen
onActiveChanged: {
GlobalStates.sidebarRightOpen = sidebarLoader.active function hide() {
GlobalStates.sidebarRightOpen = false
} }
sourceComponent: PanelWindow { exclusiveZone: 0
id: sidebarRoot implicitWidth: sidebarWidth
visible: sidebarLoader.active WlrLayershell.namespace: "quickshell:sidebarRight"
// Hyprland 0.49: Focus is always exclusive and setting this breaks mouse focus grab
// WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
color: "transparent"
function hide() { anchors {
sidebarLoader.active = false top: true
right: true
bottom: true
}
HyprlandFocusGrab {
id: grab
windows: [ sidebarRoot ]
active: GlobalStates.sidebarRightOpen
onCleared: () => {
if (!active) sidebarRoot.hide()
} }
}
exclusiveZone: 0 Loader {
implicitWidth: sidebarWidth id: sidebarContentLoader
WlrLayershell.namespace: "quickshell:sidebarRight" active: GlobalStates.sidebarRightOpen
// Hyprland 0.49: Focus is always exclusive and setting this breaks mouse focus grab anchors.centerIn: parent
// WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive width: sidebarWidth - Appearance.sizes.hyprlandGapsOut * 2
color: "transparent" height: parent.height - Appearance.sizes.hyprlandGapsOut * 2
anchors {
top: true
right: true
bottom: true
}
HyprlandFocusGrab {
id: grab
windows: [ sidebarRoot ]
active: sidebarRoot.visible
onCleared: () => {
if (!active) sidebarRoot.hide()
}
}
// Background
Rectangle { Rectangle {
id: sidebarRightBackground id: sidebarRightBackground
anchors.centerIn: parent implicitHeight: parent.height - Appearance.sizes.hyprlandGapsOut * 2
width: parent.width - Appearance.sizes.hyprlandGapsOut * 2 implicitWidth: sidebarWidth - Appearance.sizes.hyprlandGapsOut * 2
height: parent.height - Appearance.sizes.hyprlandGapsOut * 2
color: Appearance.colors.colLayer0 color: Appearance.colors.colLayer0
radius: Appearance.rounding.screenRounding - Appearance.sizes.elevationMargin + 1 radius: Appearance.rounding.screenRounding - Appearance.sizes.elevationMargin + 1
@@ -82,11 +80,11 @@ Scope {
} }
} }
ColumnLayout { ColumnLayout {
spacing: sidebarPadding
anchors.fill: parent anchors.fill: parent
anchors.margins: sidebarPadding anchors.margins: sidebarPadding
spacing: sidebarPadding
RowLayout { RowLayout {
Layout.fillHeight: false Layout.fillHeight: false
@@ -174,24 +172,25 @@ Scope {
} }
} }
} }
} }
} }
IpcHandler { IpcHandler {
target: "sidebarRight" target: "sidebarRight"
function toggle(): void { function toggle(): void {
sidebarLoader.active = !sidebarLoader.active; GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen;
if(sidebarLoader.active) Notifications.timeoutAll(); if(GlobalStates.sidebarRightOpen) Notifications.timeoutAll();
} }
function close(): void { function close(): void {
sidebarLoader.active = false; GlobalStates.sidebarRightOpen = false;
} }
function open(): void { function open(): void {
sidebarLoader.active = true; GlobalStates.sidebarRightOpen = true;
Notifications.timeoutAll(); Notifications.timeoutAll();
} }
} }
@@ -201,8 +200,8 @@ Scope {
description: qsTr("Toggles right sidebar on press") description: qsTr("Toggles right sidebar on press")
onPressed: { onPressed: {
sidebarLoader.active = !sidebarLoader.active; GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen;
if(sidebarLoader.active) Notifications.timeoutAll(); if(GlobalStates.sidebarRightOpen) Notifications.timeoutAll();
} }
} }
GlobalShortcut { GlobalShortcut {
@@ -210,7 +209,7 @@ Scope {
description: qsTr("Opens right sidebar on press") description: qsTr("Opens right sidebar on press")
onPressed: { onPressed: {
sidebarLoader.active = true; GlobalStates.sidebarRightOpen = true;
Notifications.timeoutAll(); Notifications.timeoutAll();
} }
} }
@@ -219,7 +218,7 @@ Scope {
description: qsTr("Closes right sidebar on press") description: qsTr("Closes right sidebar on press")
onPressed: { onPressed: {
sidebarLoader.active = false; GlobalStates.sidebarRightOpen = false;
} }
} }