Krolyxon
Commit 84eb284

Branches

Refs →

aurora.configquickshellauroraKnob.qml

40 lines · 1.1 KB · QML

1import QtQuick
2import QtQuick.Layouts
3
4// label + slider + value, for an integer or real setting (settings app)
5RowLayout {
6 id: k
7 property string label: ""
8 property real value: 0
9 property real from: 0
10 property real to: 1
11 property int decimals: 0
12 property string unit: ""
13 signal moved(real v)
14 Layout.fillWidth: true
15 spacing: 8
16 Text {
17 Layout.preferredWidth: 150
18 text: k.label
19 color: Theme.fg
20 elide: Text.ElideRight
21 font.family: Theme.font
22 font.pixelSize: Theme.fontSize
23 }
24 BarSlider {
25 Layout.fillWidth: true
26 from: k.from
27 to: k.to
28 step: 1 / Math.max(1, (k.to - k.from) * (k.decimals ? 100 : 1))
29 value: k.value
30 onMoved: v => k.moved(k.decimals ? Math.round(v * 100) / 100 : Math.round(v))
31 }
32 Text {
33 Layout.preferredWidth: 56
34 horizontalAlignment: Text.AlignRight
35 text: (k.decimals ? k.value.toFixed(k.decimals) : String(Math.round(k.value))) + k.unit
36 color: Theme.fg
37 font.family: Theme.font
38 font.pixelSize: Theme.fontSize
39 }
40}