feat: move dash open state to singleton

This commit is contained in:
Nydragon 2024-11-15 17:36:14 +01:00
parent c4b71fc0d4
commit 770b5aa968
Signed by: nydragon
SSH key fingerprint: SHA256:WcjW5NJPQ8Dx4uQDmoIlVPLWE27Od3fxoe0IUvuoPHE
5 changed files with 27 additions and 20 deletions

View file

@ -1,5 +1,4 @@
import Quickshell import Quickshell
import Quickshell.Services.Notifications
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import QtQml import QtQml
@ -11,11 +10,11 @@ import "provider"
PanelWindow { PanelWindow {
id: homeWindow id: homeWindow
required property var root
property bool animRunning: false property bool animRunning: false
color: "transparent" color: "transparent"
visible: animRunning || homeWindow.root.enabled visible: animRunning || NyshState.dashOpen
focusable: true focusable: true
anchors { anchors {
@ -30,7 +29,7 @@ PanelWindow {
anchors.fill: parent anchors.fill: parent
onClicked: homeWindow.root.enabled = false onClicked: NyshState.dashOpen = false
BRectangle { BRectangle {
id: home id: home
@ -41,7 +40,7 @@ PanelWindow {
topRightRadius: 10 topRightRadius: 10
border.color: "transparent" border.color: "transparent"
height: parent.height height: parent.height
width: homeWindow.root.enabled ? maxSize : 0 width: NyshState.dashOpen ? maxSize : 0
clip: true clip: true
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent

View file

@ -15,8 +15,6 @@ import QtQuick.Layouts
PanelWindow { PanelWindow {
id: lbar id: lbar
required property var root
anchors { anchors {
top: true top: true
left: Config.alignment === Config.BarAlignment.Left left: Config.alignment === Config.BarAlignment.Left
@ -74,7 +72,7 @@ PanelWindow {
MouseArea { MouseArea {
id: mouse id: mouse
onClicked: lbar.root.enabled = !lbar.root.enabled onClicked: NyshState.toggleDash()
height: width height: width
width: 30 width: 30
anchors.bottom: parent.bottom anchors.bottom: parent.bottom

View file

@ -1,4 +1,3 @@
import Quickshell.Io
import QtQuick import QtQuick
import Quickshell import Quickshell
@ -6,23 +5,12 @@ Item {
id: root id: root
required property ShellScreen screen required property ShellScreen screen
property bool enabled: false
property IpcHandler ipc: IpcHandler {
target: "dash"
function toggle() {
root.enabled = !root.enabled;
}
}
property MainBar mainBar: MainBar { property MainBar mainBar: MainBar {
screen: root.screen screen: root.screen
root: root
} }
property Dashboard dash: Dashboard { property Dashboard dash: Dashboard {
screen: root.screen screen: root.screen
root: root
} }
} }

View file

@ -0,0 +1,21 @@
pragma Singleton
import Quickshell
import Quickshell.Io
Singleton {
id: state
property bool dashOpen: false
property IpcHandler ipc: IpcHandler {
target: "dash"
function toggle() {
state.toggleDash;
}
}
function toggleDash() {
state.dashOpen = !state.dashOpen;
}
}

View file

@ -1,5 +1,6 @@
module Provider module Provider
singleton Config 0.1 Config.qml singleton Config 0.1 Config.qml
singleton NyshState 0.1 NyshState.qml
singleton Player 0.1 Player.qml singleton Player 0.1 Player.qml
singleton Inhibitor 0.1 Inhibitor.qml singleton Inhibitor 0.1 Inhibitor.qml
singleton Notifications 0.1 Notifications.qml singleton Notifications 0.1 Notifications.qml