summaryrefslogtreecommitdiff
path: root/modules/controlcenter/ControlCenter.qml
blob: 9a34861e34d50892dcf541cfc0506323b6a50c9e (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
pragma ComponentBehavior: Bound

import qs.components
import qs.components.controls
import qs.services
import qs.config
import Quickshell
import QtQuick
import QtQuick.Layouts

Item {
    id: root

    required property ShellScreen screen
    property bool floating
    readonly property int rounding: floating ? 0 : Appearance.rounding.normal

    property alias active: session.active
    property alias navExpanded: session.navExpanded

    readonly property Session session: Session {
        id: session

        root: root
    }

    function close(): void {
    }

    implicitWidth: implicitHeight * Config.controlCenter.sizes.ratio
    implicitHeight: screen.height * Config.controlCenter.sizes.heightMult

    GridLayout {
        anchors.fill: parent

        rowSpacing: 0
        columnSpacing: 0
        rows: root.floating ? 2 : 1
        columns: 2

        Loader {
            Layout.fillWidth: true
            Layout.columnSpan: 2

            asynchronous: true
            active: root.floating
            visible: active

            sourceComponent: WindowTitle {
                screen: root.screen
                session: root.session
            }
        }

        StyledRect {
            Layout.fillHeight: true

            topLeftRadius: root.rounding
            bottomLeftRadius: root.rounding
            implicitWidth: navRail.implicitWidth
            color: Colours.palette.m3surfaceContainer

            CustomMouseArea {
                anchors.fill: parent

                function onWheel(event: WheelEvent): void {
                    if (event.angleDelta.y < 0)
                        root.session.activeIndex = Math.min(root.session.activeIndex + 1, root.session.panes.length - 1);
                    else if (event.angleDelta.y > 0)
                        root.session.activeIndex = Math.max(root.session.activeIndex - 1, 0);
                }
            }

            NavRail {
                id: navRail

                screen: root.screen
                session: root.session
            }
        }

        Panes {
            Layout.fillWidth: true
            Layout.fillHeight: true

            topRightRadius: root.rounding
            bottomRightRadius: root.rounding
            session: root.session
        }
    }
}