From 85b22b4c5ee923ea3db40a60e0b421a980375508 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 27 Jul 2025 22:31:00 +0800 Subject: ws: automatically update root.activeOccupied instead of manually fixed a issue where if you close the last pinned window, the workspace activerect wouldn't react --- bar/Workspace.qml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'bar/Workspace.qml') diff --git a/bar/Workspace.qml b/bar/Workspace.qml index ee6810b..a72c664 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -98,18 +98,19 @@ Item { IRect { property var st: getWorkspaceStats(index) property bool active: st?.isActive || false + property bool occupied: st?.isOccupied || false implicitWidth: active ? Bar.wsActiveIconSize : Bar.wsIconSize implicitHeight: Bar.wsIconSize - Bar.wsHorizontalSpacing radius: Bar.wsRounding - color: st.isOccupied ? Colors.d2 : Colors.foreground1 - opacity: active && st.isOccupied ? Bar.wsActiveOpacity : st.isOccupied ? Bar.wsOpacity : Bar.wsEmptyOpacity + color: occupied ? Colors.d2 : Colors.foreground1 + opacity: active && occupied ? Bar.wsActiveOpacity : st.isOccupied ? Bar.wsOpacity : Bar.wsEmptyOpacity Icon { anchors.centerIn: parent text: !st.isUrgent ? Icons.ws[index + 1] : Icons.ws['urgent'] font.pixelSize: !active ? Bar.wsIconSize / 2 : Bar.wsActiveIconSize / 2.5 - opacity: !st.isOccupied ? 0 : 1 + opacity: !occupied ? 0 : 1 color: !st.isUrgent ? !st.isActive ? Colors.foreground2 : Colors.foreground1 : Colors.red Behavior on font.pixelSize { ISpringAnimation {} @@ -138,7 +139,6 @@ Item { } function moveActive() { activeRect.x = parent.x; - root.activeOccupied = st.isOccupied || false; activeRect.implicitWidth = active ? Bar.wsActiveIconSize : Bar.wsIconSize; } onEntered: { @@ -156,7 +156,7 @@ Item { // // just in case // activeRect.x = layout.x + previousActiveIndex * Bar.wsIconSize + previousActiveIndex * Bar.wsSpacing; // activeRect.implicitWidth = Bar.wsActiveIconSize; - // // root.activeOccupied = parent.st.isOccupied || false; + // // root.activeOccupied = parent.occupied || false; // root.activeOccupied = getWorkspaceStats(previousActiveIndex).isOccupied || false; // previousActiveIndex = -1; // } @@ -199,10 +199,12 @@ Item { onActiveChanged: if (active) { root.activeIndex = index; - root.activeOccupied = st.isOccupied; activeRect.implicitWidth = Bar.wsActiveIconSize; activeRect.x = activeRectX; } + onOccupiedChanged: { + root.activeOccupied = occupied; + } } } } @@ -218,7 +220,6 @@ Item { onPositionChanged: { const abovedItemIndex = Math.round((mouseX - layout.x) / (Bar.wsIconSize + Bar.wsSpacing)) - 1; // TODO: workspaceActiveIconSize might be before activeRect.x = mouseX - activeRect.width / 2; - root.activeOccupied = getWorkspaceStats(abovedItemIndex).isOccupied || false; activeRect.implicitWidth = root.activeIndex === abovedItemIndex ? Bar.wsActiveIconSize : Bar.wsIconSize; } onExited: { @@ -226,7 +227,6 @@ Item { // just in case activeRect.x = layout.x + root.activeIndex * Bar.wsIconSize + root.activeIndex * Bar.wsSpacing; activeRect.implicitWidth = Bar.wsActiveIconSize; - root.activeOccupied = getWorkspaceStats(root.activeIndex).isOccupied || false; } } onWheel: event => { -- cgit v1.2.3