diff --git a/dots/.config/quickshell/ii/modules/bar/Workspaces.qml b/dots/.config/quickshell/ii/modules/bar/Workspaces.qml index f1da2dab3..f0a61ef23 100644 --- a/dots/.config/quickshell/ii/modules/bar/Workspaces.qml +++ b/dots/.config/quickshell/ii/modules/bar/Workspaces.qml @@ -1,6 +1,7 @@ import qs import qs.services import qs.modules.common +import qs.modules.common.models import qs.modules.common.widgets import qs.modules.common.functions import QtQuick @@ -163,12 +164,12 @@ Item { horizontalCenter: vertical ? parent.horizontalCenter : undefined } - // idx1 is the "leading" indicator position, idx2 is the "following" one - // The former animates faster than the latter, see the NumberAnimations below - property real idx1: workspaceIndexInGroup - property real idx2: workspaceIndexInGroup - property real indicatorPosition: Math.min(idx1, idx2) * workspaceButtonWidth + root.activeWorkspaceMargin - property real indicatorLength: Math.abs(idx1 - idx2) * workspaceButtonWidth + workspaceButtonWidth - root.activeWorkspaceMargin * 2 + AnimatedTabIndexPair { + id: idxPair + index: root.workspaceIndexInGroup + } + property real indicatorPosition: Math.min(idxPair.idx1, idxPair.idx2) * workspaceButtonWidth + root.activeWorkspaceMargin + property real indicatorLength: Math.abs(idxPair.idx1 - idxPair.idx2) * workspaceButtonWidth + workspaceButtonWidth - root.activeWorkspaceMargin * 2 property real indicatorThickness: workspaceButtonWidth - root.activeWorkspaceMargin * 2 x: root.vertical ? null : indicatorPosition @@ -176,18 +177,6 @@ Item { y: root.vertical ? indicatorPosition : null implicitHeight: root.vertical ? indicatorLength : indicatorThickness - Behavior on idx1 { - NumberAnimation { - duration: 100 - easing.type: Easing.OutSine - } - } - Behavior on idx2 { - NumberAnimation { - duration: 300 - easing.type: Easing.OutSine - } - } } // Workspaces - numbers diff --git a/dots/.config/quickshell/ii/modules/common/models/AnimatedTabIndexPair.qml b/dots/.config/quickshell/ii/modules/common/models/AnimatedTabIndexPair.qml new file mode 100644 index 000000000..c18e9ccf2 --- /dev/null +++ b/dots/.config/quickshell/ii/modules/common/models/AnimatedTabIndexPair.qml @@ -0,0 +1,26 @@ +import QtQuick + +// idx1 is the "leading" indicator position, idx2 is the "following" one +// The former animates faster than the latter, see the NumberAnimations below +QtObject { + id: root + required property int index + + property real idx1: index + property real idx2: index + property int idx1Duration: 100 + property int idx2Duration: 300 + + Behavior on idx1 { + NumberAnimation { + duration: root.idx1Duration + easing.type: Easing.OutSine + } + } + Behavior on idx2 { + NumberAnimation { + duration: root.idx2Duration + easing.type: Easing.OutSine + } + } +}