summaryrefstree
path: root/usr/bin/qml-aircondition/com/neusoft/auto/widgets/HMIProcessBarDrag.qml
blob: 5dfa1bc59f90008b42c7d91281a5dc9a59af2715 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import QtQuick 2.0

Item {
    id: rectdrag

    property string bgImageStyle: acCtrl.style

    property int xPosition : (barPoint.x+barPoint.width/2) / (barBackground_Middle.width / 100)
    property int enterValue
    property int exportValue  : barPoint.x+barPoint.width/2
    property alias barBackgroundMiddlewidth:barBackground_Middle.width
    property alias barBackgroundMiddleSource: barBackground_Middle.source
    property alias barBlueMiddleSource: barBlue_Middle.source
    property alias barPointSource:  barPoint.source
    property bool pressflag:  false
    property bool dragflag: false
    property bool dragflagpress: false

    property alias barBackgroundMiddleheight: barBackground_Middle.height
    property alias barPointwidth:  barPoint.width
    property alias barPointheight:  barPoint.height


    signal dragingEnd();

    property int totalValue : barBackground_Middle.width
    property int barScale:0
    signal dragingStart();
    signal barClicked();
    signal moveing();

    height: barPoint.height

    Image{
        id:barBackground_Middle
        x:0
        y:0
        width:rectdrag.width
        source:"qrc:MATERIAL/MATERIAL_M8X_VIDEO_PROGRESS_BG"+bgImageStyle
    }


    Image{
        id:barBlue_Middle
        x:0
        y:0
        width: barPoint.x+barPoint.width/2-2
        source:"qrc:MATERIAL/MATERIAL_M8X_VIDEO_PROGRESS"+bgImageStyle
    }

    Image{
        id:barPoint
        x:-barPoint.width/2+enterValue
        y:-4
        source:"qrc:MATERIAL/MATERIAL_M8X_VIDEO_PROGRESS_BAR"+bgImageStyle
    }

    HMIMouseArea{
        anchors.fill: barPoint
        enabled: dragflagpress
        onReleased: {
               pressflag = false
        }
        onPressed: {
            pressflag = true
        }
        onCanceled: {
            pressflag = false
        }

    }

    HMIMouseArea{
        x: 0
        y: 0
        enabled: dragflag
        anchors.rightMargin: 0
        anchors.bottomMargin: 0
        anchors.leftMargin: 0
        anchors.topMargin: 0

        anchors.fill: rectdrag//parent
        drag.target: barPoint
        drag.axis: Drag.XAxis
        drag.minimumX:  -barPoint.width/2
        drag.maximumX: rectdrag.width-barPoint.width/2
        onMouseXChanged: {
                enterValue = barPoint.x +barPoint.width/2
                barScale = (enterValue*100)/totalValue;
                moveing();
        }
        onReleased: {
               dragingEnd();
               pressflag = false
        }
        onPressed: {

            enterValue = mouseX
            barScale = (enterValue*100)/totalValue;
            dragingStart();
            pressflag = true
        }
        onCanceled: {
            dragingEnd();
            pressflag = false
        }
    }
}