File: SettingsComponentSlider.qml

package info (click to toggle)
qt6-declarative 6.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 308,920 kB
  • sloc: cpp: 775,911; javascript: 514,247; xml: 10,855; python: 2,806; ansic: 2,253; java: 810; sh: 262; makefile: 41; php: 27
file content (88 lines) | stat: -rw-r--r-- 2,722 bytes parent folder | download
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
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Effects
import QtQuick.Controls.Basic

Column {
    id: rootItem

    property alias text: textItem.text
    property alias value: slider.value
    property alias from: slider.from
    property alias to: slider.to
    property alias stepSize: slider.stepSize

    signal moved

    spacing: -10 * dp

    Text {
        id: textItem
        anchors.horizontalCenter: parent.horizontalCenter
        color: "#e0e0e0"
        font.pixelSize: 16 * dp
    }

    Slider {
        id: slider
        property real sliderWidth: settings.settingsViewWidth
        property real handlePadding: (handleItem.width - handleVisualItem.width) * 0.5
        width: sliderWidth
        value: 50
        from: 0
        to: 800
        onMoved: {
            rootItem.moved();
        }

        background: Rectangle {
            x: slider.leftPadding + slider.handlePadding
            y: slider.topPadding + slider.availableHeight / 2 - height / 2
            implicitWidth: 200
            implicitHeight: 4
            width: slider.availableWidth - slider.handlePadding * 2
            height: implicitHeight
            radius: 2
            color: Qt.lighter(mainWindow.mainColor, 0.3)
            Rectangle {
                width: slider.visualPosition * parent.width
                height: parent.height
                color: mainWindow.mainColor
                radius: 2
                RectangularShadow {
                    anchors.fill: parent
                    z: -1
                    radius: height / 2
                    blur: slider.hovered || slider.pressed ? 12 : 8
                    color: Qt.lighter(mainWindow.mainColor, 1.2)
                }
            }
        }

        handle: Item {
            id: handleItem
            x: slider.leftPadding + slider.visualPosition * (slider.availableWidth - width)
            y: slider.topPadding + slider.availableHeight / 2 - height / 2
            implicitWidth: 26
            implicitHeight: 26
            Rectangle {
                id: handleVisualItem
                anchors.centerIn: parent
                width: 8
                height: 8
                radius: width / 2
                color: Qt.lighter(mainWindow.mainColor, 1.5)
                RectangularShadow {
                    anchors.fill: parent
                    anchors.margins: -2
                    z: -1
                    radius: width / 2
                    blur: slider.hovered || slider.pressed ? 16 : 8
                    color: Qt.lighter(mainWindow.mainColor, 1.2)
                }
            }
        }
    }
}