summaryrefslogtreecommitdiff
path: root/bar/Workspace.qml
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-27 22:31:00 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-27 22:31:00 +0800
commit85b22b4c5ee923ea3db40a60e0b421a980375508 (patch)
treeb1e3cf5a468b37aca49b19046c0ed3494c94da4d /bar/Workspace.qml
parent60781d9d32e516694ef0d2246c620003d5db2d1f (diff)
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
Diffstat (limited to 'bar/Workspace.qml')
-rw-r--r--bar/Workspace.qml16
1 files changed, 8 insertions, 8 deletions
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 => {