summaryrefslogtreecommitdiff
path: root/modules/bar/components/workspaces/Workspace.qml
blob: 1c1ca74f60576a5df5b137884ee2d61a5af40d92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import qs.components
import qs.services
import qs.utils
import qs.config
import Quickshell
import QtQuick
import QtQuick.Layouts

ColumnLayout {
    id: root

    required property int index
    required property int activeWsId
    required property var ws

    readonly property bool isOccupied: ws?.lastIpcObject?.windows > 0
    readonly property bool isActive: ws?.id == activeWsId
    readonly property bool isVisible: isActive || isOccupied || true

    // Flag for finding workspace children
    readonly property bool isWorkspace: true

    Layout.alignment: Qt.AlignHCenter
    Layout.preferredHeight: isVisible ? implicitHeight : 0

    spacing: 0
    visible: isVisible

    StyledText {
        id: indicator

        Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
        Layout.preferredHeight: Config.bar.sizes.innerWidth - Appearance.padding.small * 2

        animate: true
        text: {
            let ws = root.ws;
            let wsName = !ws || ws.name == ws.id ? ws.id : ws.name[0];
            let displayName = wsName.toString();
            let label = Config.bar.workspaces.label || displayName;
            return label
        }
        color: root.isActive ? Colours.palette.m3onSurface : Colours.layer(Colours.palette.m3outlineVariant, 2)
        verticalAlignment: Qt.AlignVCenter
    }

    Behavior on Layout.preferredHeight {
        Anim {}
    }
}