diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-07-14 19:08:58 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-07-14 19:08:58 +0800 |
| commit | a521a82030cdf0a89a62250b429209992f948824 (patch) | |
| tree | 698e93af0cbe855737585b4bc0c48fec78175b9f /bar/Workspace.qml | |
| parent | 47c142bb3682a161c5f81bf0f9d0dece27ae924e (diff) | |
timedate: use 12hr
fuck u qt
Diffstat (limited to 'bar/Workspace.qml')
| -rw-r--r-- | bar/Workspace.qml | 94 |
1 files changed, 77 insertions, 17 deletions
diff --git a/bar/Workspace.qml b/bar/Workspace.qml index ccfcd57..e545b24 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -8,29 +8,45 @@ import qs.components Item { id: root - - // required property ShellScreen screen // multi monitor property var ws: Hyprland.workspaces - - // readonly property HyprlandMonitor monitor: Hyprland.monitorFor(screen) // multi monitor - // dont work no more for some reason - function getWorkspaceStats(index) { const w = ws.values.find(i => i.id === index + 1); return { - isOccupied: w?.toplevels?.values?.length, - isActive: w?.active, - isUrgent: w?.urgent + isOccupied: Boolean(w?.toplevels?.values?.length), + isActive: Boolean(w?.active), + isUrgent: Boolean(w?.urgent) }; } - implicitWidth: layout.implicitWidth + property int activeIndex: 0 + property int prevIndex: 0 + + Rectangle { + id: activeRect + anchors.verticalCenter: parent.verticalCenter + height: Bar.workspaceIconSize - Bar.workspaceHorizontalSpacing + width: Bar.workspaceIconSize + radius: Bar.workspaceRounding + color: Colors.alt + opacity: Bar.workspaceActiveOpacity + Behavior on x { + NumberAnimation { + duration: Bar.workspaceAnimationTransition + easing.type: Easing.OutQuad + } + } + Behavior on width { + NumberAnimation { + duration: Bar.workspaceAnimationExpand + easing.type: Easing.OutQuad + } + } + } RowLayout { id: layout implicitWidth: childrenRect.width anchors.verticalCenter: parent.verticalCenter - spacing: Bar.workspaceSpacing Repeater { @@ -39,21 +55,65 @@ Item { Rectangle { id: workspaceRect property var st: getWorkspaceStats(index) + property bool active: st.isActive + property bool shouldExpand: false - implicitWidth: !st.isActive ? Bar.workspaceIconSize : Bar.workspaceActiveIconSize + implicitWidth: shouldExpand ? Bar.workspaceActiveIconSize : Bar.workspaceIconSize implicitHeight: Bar.workspaceIconSize - Bar.workspaceHorizontalSpacing radius: Bar.workspaceRounding + + Behavior on implicitWidth { + NumberAnimation { + duration: shouldExpand ? Bar.workspaceAnimationExpand : Bar.workspaceAnimationShrink + easing.type: Easing.OutQuad + } + } + + SequentialAnimation { + id: activeRectAnimation + PauseAnimation { + duration: Bar.workspaceAnimationTransition + } + ScriptAction { + script: { + activeRect.x = workspaceRect.x; + activeRect.width = Bar.workspaceActiveIconSize; + workspaceRect.shouldExpand = true; + } + } + } + + Component.onCompleted: { + if (active) { + root.activeIndex = index; + root.prevIndex = index; + shouldExpand = true; + activeRect.x = x; + activeRect.width = Bar.workspaceActiveIconSize; + } + } + + onActiveChanged: { + if (active) { + root.prevIndex = root.activeIndex; + root.activeIndex = index; + activeRect.width = Bar.workspaceIconSize; + layout.children[root.prevIndex].shouldExpand = false; + activeRect.x = layout.children[root.prevIndex].x; + activeRectAnimation.start(); + } + } + Icon { anchors.centerIn: parent - text: !st.isUrgent ? Icons.ws[index + 1] : Icons.ws['urgent'] // TODO: urgent = red + text: !st.isUrgent ? Icons.ws[index + 1] : Icons.ws['urgent'] font.pixelSize: Bar.workspaceIconSize / 2 - color: Colors.foreground // TODO make IText w/ ts default color - opacity: !st.isOccupied ? 0 : 1 // less contrast - // opacity: isActive(index) ? Bar.workspaceActiveOpacity : isOccupied(index) ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity + color: Colors.foreground + opacity: st.isOccupied ? 1 : 0 } color: st.isOccupied ? Colors.alt : Colors.foreground - opacity: st.isActive && st.isOccupied ? Bar.workspaceActiveOpacity : st.isOccupied ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity + opacity: st.isOccupied ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity } } } |
