summaryrefslogtreecommitdiff
path: root/modules/controlcenter/dashboard/GeneralSection.qml
blob: bf54e976020f3d58196c7b087da0dcb18819a281 (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
import ".."
import "../components"
import qs.components
import qs.components.controls
import qs.services
import qs.config
import QtQuick
import QtQuick.Layouts

SectionContainer {
    id: root

    required property var rootItem

    Layout.fillWidth: true
    alignTop: true

    StyledText {
        text: qsTr("General Settings")
        font.pointSize: Appearance.font.size.normal
    }

    SwitchRow {
        label: qsTr("Enabled")
        checked: root.rootItem.enabled
        onToggled: checked => {
            root.rootItem.enabled = checked;
            root.rootItem.saveConfig();
        }
    }

    SwitchRow {
        label: qsTr("Show on hover")
        checked: root.rootItem.showOnHover
        onToggled: checked => {
            root.rootItem.showOnHover = checked;
            root.rootItem.saveConfig();
        }
    }

    SectionContainer {
        contentSpacing: Appearance.spacing.normal

        SliderInput {
            Layout.fillWidth: true
            
            label: qsTr("Update interval")
            value: root.rootItem.updateInterval
            from: 100
            to: 10000
            stepSize: 100
            suffix: "ms"
            validator: IntValidator { bottom: 100; top: 10000 }
            formatValueFunction: (val) => Math.round(val).toString()
            parseValueFunction: (text) => parseInt(text)
            
            onValueModified: (newValue) => {
                root.rootItem.updateInterval = Math.round(newValue);
                root.rootItem.saveConfig();
            }
        }

        SliderInput {
            Layout.fillWidth: true
            
            label: qsTr("Drag threshold")
            value: root.rootItem.dragThreshold
            from: 0
            to: 100
            suffix: "px"
            validator: IntValidator { bottom: 0; top: 100 }
            formatValueFunction: (val) => Math.round(val).toString()
            parseValueFunction: (text) => parseInt(text)
            
            onValueModified: (newValue) => {
                root.rootItem.dragThreshold = Math.round(newValue);
                root.rootItem.saveConfig();
            }
        }
    }
}