forked from Shinonome/dots-hyprland
left sidebar: put in loader
This commit is contained in:
@@ -17,17 +17,24 @@ Scope { // Scope
|
|||||||
property int sidebarPadding: 15
|
property int sidebarPadding: 15
|
||||||
property var tabButtonList: [{"icon": "neurology", "name": qsTr("Intelligence")}, {"icon": "bookmark_heart", "name": qsTr("Anime")}]
|
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
|
PanelWindow { // Window
|
||||||
id: sidebarRoot
|
id: sidebarRoot
|
||||||
visible: false
|
visible: sidebarLoader.active
|
||||||
focusable: true
|
focusable: true
|
||||||
property int selectedTab: PersistentStates.sidebar.leftSide.selectedTab
|
property int selectedTab: PersistentStates.sidebar.leftSide.selectedTab
|
||||||
property bool extend: false
|
property bool extend: false
|
||||||
property bool pin: false
|
property bool pin: false
|
||||||
property real sidebarWidth: sidebarRoot.extend ? Appearance.sizes.sidebarWidthExtended : Appearance.sizes.sidebarWidth
|
property real sidebarWidth: sidebarRoot.extend ? Appearance.sizes.sidebarWidthExtended : Appearance.sizes.sidebarWidth
|
||||||
|
|
||||||
onVisibleChanged: {
|
function hide() {
|
||||||
GlobalStates.sidebarLeftOpenCount += visible ? 1 : -1
|
sidebarLoader.active = false
|
||||||
}
|
}
|
||||||
|
|
||||||
exclusiveZone: pin ? sidebarWidth : 0
|
exclusiveZone: pin ? sidebarWidth : 0
|
||||||
@@ -52,7 +59,7 @@ Scope { // Scope
|
|||||||
windows: [ sidebarRoot ]
|
windows: [ sidebarRoot ]
|
||||||
active: false
|
active: false
|
||||||
onCleared: () => {
|
onCleared: () => {
|
||||||
if (!active) sidebarRoot.visible = false
|
if (!active) sidebarRoot.hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +108,7 @@ Scope { // Scope
|
|||||||
Keys.onPressed: (event) => {
|
Keys.onPressed: (event) => {
|
||||||
// console.log("Key pressed: " + event.key)
|
// console.log("Key pressed: " + event.key)
|
||||||
if (event.key === Qt.Key_Escape) {
|
if (event.key === Qt.Key_Escape) {
|
||||||
sidebarRoot.visible = false;
|
sidebarRoot.hide();
|
||||||
}
|
}
|
||||||
if (event.modifiers === Qt.ControlModifier) {
|
if (event.modifiers === Qt.ControlModifier) {
|
||||||
if (event.key === Qt.Key_PageDown) {
|
if (event.key === Qt.Key_PageDown) {
|
||||||
@@ -186,22 +193,23 @@ Scope { // Scope
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "sidebarLeft"
|
target: "sidebarLeft"
|
||||||
|
|
||||||
function toggle(): void {
|
function toggle(): void {
|
||||||
sidebarRoot.visible = !sidebarRoot.visible;
|
sidebarLoader.active = !sidebarLoader.active
|
||||||
if(sidebarRoot.visible) Notifications.timeoutAll();
|
if(sidebarLoader.active) Notifications.timeoutAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
function close(): void {
|
function close(): void {
|
||||||
sidebarRoot.visible = false;
|
sidebarLoader.active = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(): void {
|
function open(): void {
|
||||||
sidebarRoot.visible = true;
|
sidebarLoader.active = true
|
||||||
if(sidebarRoot.visible) Notifications.timeoutAll();
|
if(sidebarLoader.active) Notifications.timeoutAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,8 +218,8 @@ Scope { // Scope
|
|||||||
description: "Toggles left sidebar on press"
|
description: "Toggles left sidebar on press"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
sidebarRoot.visible = !sidebarRoot.visible;
|
sidebarLoader.active = !sidebarLoader.active;
|
||||||
if(sidebarRoot.visible) Notifications.timeoutAll();
|
if(sidebarLoader.active) Notifications.timeoutAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,8 +228,8 @@ Scope { // Scope
|
|||||||
description: "Opens left sidebar on press"
|
description: "Opens left sidebar on press"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
sidebarRoot.visible = true;
|
sidebarLoader.active = true;
|
||||||
if(sidebarRoot.visible) Notifications.timeoutAll();
|
if(sidebarLoader.active) Notifications.timeoutAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +238,7 @@ Scope { // Scope
|
|||||||
description: "Closes left sidebar on press"
|
description: "Closes left sidebar on press"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
sidebarRoot.visible = false;
|
sidebarLoader.active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user