aboutsummaryrefslogtreecommitdiff
path: root/modules/system/quickshell/PillSlider.qml
blob: e24663ddce23ad0f7c4de79be8f219bd44bc11bf (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
import QtQuick
import QtQuick.Controls
import QtQuick.Effects
import Quickshell

Slider {
    id: root

    property string icon: ""
    property color colorTrack: Theme.sliderTrack
    property color colorProgress: Theme.accent
    property color colorHandle: "#FFFFFF"
    property color iconColor: Theme.iconDefault

    implicitHeight: 24
    padding: 0

    background: Rectangle {
        width: root.width
        height: root.height
        radius: height / 2
        color: root.colorTrack

        clip: true

        Rectangle {
            width: root.handle.x + (root.handle.width / 2)
            height: parent.height
            color: root.colorProgress
        }

        Image {
            id: iconImage
            visible: root.icon !== ""
            anchors.left: parent.left
            anchors.leftMargin: 6
            anchors.verticalCenter: parent.verticalCenter
            source: root.icon !== "" ? Quickshell.iconPath(root.icon) : ""
            sourceSize: Qt.size(14, 14)
            width: 14
            height: 14
        }

        MultiEffect {
            source: iconImage
            anchors.fill: iconImage
            colorizationColor: root.iconColor
            colorization: 1.0
        }
    }

    handle: Item {
        x: root.visualPosition * (root.availableWidth - width)
        y: root.topPadding + root.availableHeight / 2 - height / 2

        width: root.height
        height: root.height

        Rectangle {
            id: handleCircle
            anchors.fill: parent
            radius: width / 2
            color: root.colorHandle
            border.width: 1
            border.color: "#1A000000"
        }

        MultiEffect {
            source: handleCircle
            anchors.fill: handleCircle
            shadowEnabled: true
            shadowBlur: 1.0
            shadowColor: "#4D000000"
            shadowVerticalOffset: 1
        }
    }
}