aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPropertySpinBox.qml
blob: 5815a030492758dfce241c94a2ff32d13a3ea56f (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0

import QtQuick 2.15
import QtQuick.Layouts 1.15
import StudioControls 1.0 as StudioControls

Item {
    id: wrapper

    property string propertyName

    property alias decimals: spinBox.decimals
    property alias value: spinBox.realValue
    property alias minimumValue: spinBox.realFrom
    property alias maximumValue: spinBox.realTo
    property alias stepSize: spinBox.realStepSize

    property alias pixelsPerUnit: spinBox.pixelsPerUnit

    width: 90
    implicitHeight: spinBox.height

    onFocusChanged: restoreCursor()

    function readValue() {
        spinBox.realValue = gradientLine.model.readGradientProperty(wrapper.propertyName)
    }

    StudioControls.RealSpinBox {
        id: spinBox

        __devicePixelRatio: devicePixelRatio()

        width: wrapper.width
        actionIndicatorVisible: false

        realFrom: -9999
        realTo: 9999
        realStepSize: 1
        decimals: 0

        Component.onCompleted: wrapper.readValue()
        onCompressedRealValueModified: {
            gradientLine.model.setGradientProperty(wrapper.propertyName, spinBox.realValue)
        }

        onDragStarted: hideCursor()
        onDragEnded: restoreCursor()
        onDragging: holdCursorInPlace()
    }
}