left sidebar: put in loader

This commit is contained in:
end-4
2025-05-17 23:45:53 +02:00
parent 2b98b8dada
commit 8533310f29
@@ -17,17 +17,24 @@ Scope { // Scope
property int sidebarPadding: 15
property var tabButtonList: [{"icon": "neurology", "name": qsTr("Intelligence")}, {"icon": "bookmark_heart", "name": qsTr("Anime")}]
Loader {
id: sidebarLoader
active: false
onActiveChanged: {
GlobalStates.sidebarLeftOpenCount += active ? 1 : -1
}
PanelWindow { // Window
id: sidebarRoot
visible: false
visible: sidebarLoader.active
focusable: true
property int selectedTab: PersistentStates.sidebar.leftSide.selectedTab
property bool extend: false
property bool pin: false
property real sidebarWidth: sidebarRoot.extend ? Appearance.sizes.sidebarWidthExtended : Appearance.sizes.sidebarWidth
onVisibleChanged: {
GlobalStates.sidebarLeftOpenCount += visible ? 1 : -1
function hide() {
sidebarLoader.active = false
}
exclusiveZone: pin ? sidebarWidth : 0
@@ -52,7 +59,7 @@ Scope { // Scope
windows: [ sidebarRoot ]
active: false
onCleared: () => {
if (!active) sidebarRoot.visible = false
if (!active) sidebarRoot.hide()
}
}
@@ -101,7 +108,7 @@ Scope { // Scope
Keys.onPressed: (event) => {
// console.log("Key pressed: " + event.key)
if (event.key === Qt.Key_Escape) {
sidebarRoot.visible = false;
sidebarRoot.hide();
}
if (event.modifiers === Qt.ControlModifier) {
if (event.key === Qt.Key_PageDown) {
@@ -186,22 +193,23 @@ Scope { // Scope
}
}
}
IpcHandler {
target: "sidebarLeft"
function toggle(): void {
sidebarRoot.visible = !sidebarRoot.visible;
if(sidebarRoot.visible) Notifications.timeoutAll();
sidebarLoader.active = !sidebarLoader.active
if(sidebarLoader.active) Notifications.timeoutAll();
}
function close(): void {
sidebarRoot.visible = false;
sidebarLoader.active = false
}
function open(): void {
sidebarRoot.visible = true;
if(sidebarRoot.visible) Notifications.timeoutAll();
sidebarLoader.active = true
if(sidebarLoader.active) Notifications.timeoutAll();
}
}
@@ -210,8 +218,8 @@ Scope { // Scope
description: "Toggles left sidebar on press"
onPressed: {
sidebarRoot.visible = !sidebarRoot.visible;
if(sidebarRoot.visible) Notifications.timeoutAll();
sidebarLoader.active = !sidebarLoader.active;
if(sidebarLoader.active) Notifications.timeoutAll();
}
}
@@ -220,8 +228,8 @@ Scope { // Scope
description: "Opens left sidebar on press"
onPressed: {
sidebarRoot.visible = true;
if(sidebarRoot.visible) Notifications.timeoutAll();
sidebarLoader.active = true;
if(sidebarLoader.active) Notifications.timeoutAll();
}
}
@@ -230,7 +238,7 @@ Scope { // Scope
description: "Closes left sidebar on press"
onPressed: {
sidebarRoot.visible = false;
sidebarLoader.active = false;
}
}