IntEditor.qml 2.14 KB
Newer Older
1
import Qt 4.7
2 3 4
import Bauhaus 1.0

QWidget {
5
    id: intEditor;
6

7 8
    property variant backendValue;
    property variant baseStateFlag;
9

10
    property variant caption;
11

12 13
    property variant maximumValue: 1000
    property variant minimumValue: -1000
14
    property variant step: 1
15
    property bool slider: true
16
    property alias alignment: label.alignment
17

18
    layout: HorizontalLayout {
19 20
        Label {
            id: label
21
            text: caption
22
            toolTip: caption
23 24 25
        }

        SpinBox {
26
            backendValue: (intEditor.backendValue === undefined ||
27
            intEditor.backendValue === null)
28
            ? null : intEditor.backendValue;
29

30
            property variant backendValueValue: (intEditor.backendValue === undefined ||
31
            intEditor.backendValue === null)
32
            ? null : intEditor.backendValue.value;
33 34 35 36

            onBackendValueValueChanged: {
                intSlider.value = intEditor.backendValue.value;
            }
37

38 39
            minimum: minimumValue
            maximum: maximumValue
40
            baseStateFlag: intEditor.baseStateFlag
41 42 43
        }


44
        QWidget {
45
            visible: intEditor.slider
46 47
            id: sliderWidget
            QSlider {
48
                id: intSlider
49 50 51
                y: sliderWidget.height / 2 - 12
                width: sliderWidget.width
                height: 24
52
                property alias backendValue: intEditor.backendValue
53 54 55 56
                orientation: "Qt::Horizontal"
                minimum: minimumValue
                maximum: maximumValue
                singleStep: step
57 58 59 60 61 62


                value: (backendValue == undefined
                || backendValue == null
                || backendValue.value == undefined
                || backendValue.value == null) ? 0 : backendValue.value
63 64
                onValueChanged: {
                    if (backendValue != undefined && backendValue != null)
65
                    backendValue.value = value;
66
                }
67

68
                onSliderPressed: {
69
                    transaction.start();
70 71
                }
                onSliderReleased: {
72
                    transaction.end();
73
                }
74 75 76 77
            }
        }
    }
}