forked from Shinonome/dots-hyprland
111 lines
2.9 KiB
QML
111 lines
2.9 KiB
QML
import qs
|
|
import qs.services
|
|
import qs.modules.common
|
|
import QtQuick
|
|
import Quickshell.Io
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import Quickshell.Hyprland
|
|
|
|
Scope {
|
|
id: root
|
|
property int sidebarWidth: Appearance.sizes.sidebarWidth
|
|
|
|
PanelWindow {
|
|
id: panelWindow
|
|
visible: GlobalStates.sidebarRightOpen
|
|
|
|
function hide() {
|
|
GlobalStates.sidebarRightOpen = false;
|
|
}
|
|
|
|
exclusiveZone: 0
|
|
implicitWidth: sidebarWidth
|
|
WlrLayershell.namespace: "quickshell:sidebarRight"
|
|
WlrLayershell.keyboardFocus: GlobalStates.sidebarRightOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
|
color: "transparent"
|
|
|
|
anchors {
|
|
top: true
|
|
right: true
|
|
bottom: true
|
|
}
|
|
|
|
onVisibleChanged: {
|
|
if (visible) {
|
|
GlobalFocusGrab.addDismissable(panelWindow);
|
|
} else {
|
|
GlobalFocusGrab.removeDismissable(panelWindow);
|
|
}
|
|
}
|
|
Connections {
|
|
target: GlobalFocusGrab
|
|
function onDismissed() {
|
|
panelWindow.hide();
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: sidebarContentLoader
|
|
active: GlobalStates.sidebarRightOpen || Config?.options.sidebar.keepRightSidebarLoaded
|
|
anchors {
|
|
fill: parent
|
|
margins: Appearance.sizes.hyprlandGapsOut
|
|
leftMargin: Appearance.sizes.elevationMargin
|
|
}
|
|
width: sidebarWidth - Appearance.sizes.hyprlandGapsOut - Appearance.sizes.elevationMargin
|
|
height: parent.height - Appearance.sizes.hyprlandGapsOut * 2
|
|
|
|
focus: GlobalStates.sidebarRightOpen
|
|
Keys.onPressed: event => {
|
|
if (event.key === Qt.Key_Escape) {
|
|
panelWindow.hide();
|
|
}
|
|
}
|
|
|
|
sourceComponent: SidebarRightContent {}
|
|
}
|
|
}
|
|
|
|
IpcHandler {
|
|
target: "sidebarRight"
|
|
|
|
function toggle(): void {
|
|
GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen;
|
|
}
|
|
|
|
function close(): void {
|
|
GlobalStates.sidebarRightOpen = false;
|
|
}
|
|
|
|
function open(): void {
|
|
GlobalStates.sidebarRightOpen = true;
|
|
}
|
|
}
|
|
|
|
GlobalShortcut {
|
|
name: "sidebarRightToggle"
|
|
description: "Toggles right sidebar on press"
|
|
|
|
onPressed: {
|
|
GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen;
|
|
}
|
|
}
|
|
GlobalShortcut {
|
|
name: "sidebarRightOpen"
|
|
description: "Opens right sidebar on press"
|
|
|
|
onPressed: {
|
|
GlobalStates.sidebarRightOpen = true;
|
|
}
|
|
}
|
|
GlobalShortcut {
|
|
name: "sidebarRightClose"
|
|
description: "Closes right sidebar on press"
|
|
|
|
onPressed: {
|
|
GlobalStates.sidebarRightOpen = false;
|
|
}
|
|
}
|
|
}
|