forked from Shinonome/dots-hyprland
left sidebar: pinning, single instance
This commit is contained in:
@@ -17,30 +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")}]
|
||||||
|
|
||||||
Variants { // Window repeater
|
|
||||||
id: sidebarVariants
|
|
||||||
model: Quickshell.screens
|
|
||||||
|
|
||||||
PanelWindow { // Window
|
PanelWindow { // Window
|
||||||
id: sidebarRoot
|
id: sidebarRoot
|
||||||
visible: false
|
visible: false
|
||||||
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 real sidebarWidth: sidebarRoot.extend ? Appearance.sizes.sidebarWidthExtended : Appearance.sizes.sidebarWidth
|
property real sidebarWidth: sidebarRoot.extend ? Appearance.sizes.sidebarWidthExtended : Appearance.sizes.sidebarWidth
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
GlobalStates.sidebarLeftOpenCount += visible ? 1 : -1
|
GlobalStates.sidebarLeftOpenCount += visible ? 1 : -1
|
||||||
}
|
}
|
||||||
|
|
||||||
property var modelData
|
exclusiveZone: pin ? sidebarWidth : 0
|
||||||
|
|
||||||
screen: modelData
|
|
||||||
exclusiveZone: 0
|
|
||||||
implicitWidth: Appearance.sizes.sidebarWidthExtended
|
implicitWidth: Appearance.sizes.sidebarWidthExtended
|
||||||
WlrLayershell.namespace: "quickshell:sidebarLeft"
|
WlrLayershell.namespace: "quickshell:sidebarLeft"
|
||||||
// Hyprland 0.49: Focus is always exclusive and setting this breaks mouse focus grab
|
// Hyprland 0.49: OnDemand is Exclusive, Exclusive just breaks click-outside-to-close
|
||||||
// WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
@@ -68,6 +62,9 @@ Scope { // Scope
|
|||||||
delayedGrabTimer.start()
|
delayedGrabTimer.start()
|
||||||
swipeView.children[0].children[0].children[sidebarRoot.selectedTab].forceActiveFocus()
|
swipeView.children[0].children[0].children[sidebarRoot.selectedTab].forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
function onPinChanged() {
|
||||||
|
grab.active = !sidebarRoot.pin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
@@ -75,7 +72,7 @@ Scope { // Scope
|
|||||||
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
|
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
grab.active = sidebarRoot.visible
|
grab.active = sidebarRoot.visible && !sidebarRoot.pin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +84,7 @@ Scope { // Scope
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.topMargin: Appearance.sizes.hyprlandGapsOut
|
anchors.topMargin: Appearance.sizes.hyprlandGapsOut
|
||||||
anchors.leftMargin: Appearance.sizes.hyprlandGapsOut
|
anchors.leftMargin: Appearance.sizes.hyprlandGapsOut
|
||||||
width: sidebarWidth - Appearance.sizes.hyprlandGapsOut * 2
|
width: sidebarRoot.sidebarWidth - Appearance.sizes.hyprlandGapsOut * 2
|
||||||
height: parent.height - 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
|
||||||
@@ -122,6 +119,9 @@ Scope { // Scope
|
|||||||
else if (event.key === Qt.Key_O) {
|
else if (event.key === Qt.Key_O) {
|
||||||
sidebarRoot.extend = !sidebarRoot.extend;
|
sidebarRoot.extend = !sidebarRoot.extend;
|
||||||
}
|
}
|
||||||
|
else if (event.key === Qt.Key_P) {
|
||||||
|
sidebarRoot.pin = !sidebarRoot.pin;
|
||||||
|
}
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,38 +187,21 @@ Scope { // Scope
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "sidebarLeft"
|
target: "sidebarLeft"
|
||||||
|
|
||||||
function toggle(): void {
|
function toggle(): void {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
sidebarRoot.visible = !sidebarRoot.visible;
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
if(sidebarRoot.visible) Notifications.timeoutAll();
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
||||||
panelWindow.visible = !panelWindow.visible;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function close(): void {
|
function close(): void {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
sidebarRoot.visible = false;
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
||||||
panelWindow.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(): void {
|
function open(): void {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
sidebarRoot.visible = true;
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
if(sidebarRoot.visible) Notifications.timeoutAll();
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
||||||
panelWindow.visible = true;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,13 +210,8 @@ Scope { // Scope
|
|||||||
description: "Toggles left sidebar on press"
|
description: "Toggles left sidebar on press"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
sidebarRoot.visible = !sidebarRoot.visible;
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
if(sidebarRoot.visible) Notifications.timeoutAll();
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
||||||
panelWindow.visible = !panelWindow.visible;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,13 +220,8 @@ Scope { // Scope
|
|||||||
description: "Opens left sidebar on press"
|
description: "Opens left sidebar on press"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
sidebarRoot.visible = true;
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
if(sidebarRoot.visible) Notifications.timeoutAll();
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
||||||
panelWindow.visible = true;
|
|
||||||
if(panelWindow.visible) Notifications.timeoutAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,12 +230,7 @@ Scope { // Scope
|
|||||||
description: "Closes left sidebar on press"
|
description: "Closes left sidebar on press"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
sidebarRoot.visible = false;
|
||||||
let panelWindow = sidebarVariants.instances[i];
|
|
||||||
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
||||||
panelWindow.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user