aboutsummaryrefslogtreecommitdiff
path: root/modules/system/quickshell/SliderBox.qml
blob: 1d84e72fee1c9ed46c3feed17e5c1f06e3ebcf69 (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
import QtQuick
import QtQuick.Layouts
import Quickshell

Squircle {
    id: root
    property string label: ""
    property string icon: ""
    property real value: 0
    property bool clickable: false
    signal moved(real val)
    signal clicked

    Layout.fillWidth: true
    height: 64
    cornerRadius: 16
    fillColor: hoverArea.containsMouse ? Theme.surfaceHover : Theme.surface

    MouseArea {
        id: hoverArea
        anchors.fill: parent
        hoverEnabled: true
        acceptedButtons: root.clickable ? Qt.LeftButton : Qt.NoButton
        cursorShape: root.clickable ? Qt.PointingHandCursor : Qt.ArrowCursor
        onClicked: root.clicked()
    }

    ColumnLayout {
        anchors.fill: parent
        anchors.margins: 12
        spacing: 4

        RowLayout {
            Layout.fillWidth: true
            Text {
                text: root.label
                color: Theme.textMuted
                font {
                    family: Theme.mainFont
                    pixelSize: 12
                    weight: Font.DemiBold
                }
                Layout.leftMargin: 2
            }
            Item {
                Layout.fillWidth: true
            }
        }

        PillSlider {
            id: slider
            Layout.fillWidth: true
            icon: root.icon
            value: root.value
            onMoved: root.moved(value)
        }
    }
}