summaryrefstree
path: root/usr/bin/qml-aircondition/com/neusoft/auto/widgets/HMISlider.qml
blob: 5bd02a09c5217d2dad65ac7b0e69e4b75194fd54 (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
109
110
111
112
113
114
115
116
117
import QtQuick 2.0

Item {
    id: rectdrag
    property int xPosition : (barPoint.x) / (barBackground_Middle.width)*(sliderpartnum)
    property int enterValue
    onEnterValueChanged: {
            barPoint.x = enterValue         //quanshaoying
    }

    property int exportValue  : barPoint.x
    property alias barBackgroundMiddlewidth:barBackground_Middle.width
    property alias barBackgroundLeftSource: barBackground_Left.source
    property alias barBackgroundMiddleSource: barBackground_Middle.source
    property alias barBackgroundRightSource:  barBackground_Right.source
    property alias barBlueLeftSource: barBlue_Left.source
    property alias barBlueMiddleSource: barBlue_Middle.source
    property alias barBlueRightSource:  barBlue_Right.source
    property alias barPointSource:  barPoint.source

    property int sliderpartnum:100
    property double add :   barBackground_Middle.width/sliderpartnum
    property alias barPointmouseopacity:barPointmouse.opacity
    property alias barBackgroundMiddlemouse:barBackground_Middlemouse.opacity

    signal clickSlider();
    signal dragBarPoint();
    width: barBackground_Middle.width+barBackground_Left.width+barBackground_Right.width
    height: barPoint.height

    Image{
        id:barBackground_Left
        anchors.verticalCenter: parent.verticalCenter
        source: "../../../../images/Slider/Slider_Background_Left.png"
        HMIMouseArea{
                id:barBackground_Leftmouse
                anchors.fill: parent
                onClicked: {barPoint.x=0}}
    }
    Image{
        id:barBackground_Middle
        width:100
        anchors.left: barBackground_Left.right
        anchors.verticalCenter: parent.verticalCenter
        source: "../../../../images/Slider/Slider_Background_Middle.png"
        HMIMouseArea{
                id:barBackground_Middlemouse
                anchors.fill: parent
                onClicked: {
                    barPoint.x=add*((mouseX-mouseX%add)/add+((mouseX%add)/add>0.5?1:0))
                    clickSlider();
                }
        }
    }
    Image{
        id:barBackground_Right
        anchors.left:barBackground_Middle.right
        anchors.verticalCenter: parent.verticalCenter
        source: "../../../../images/Slider/Slider_Background_Right.png"
        HMIMouseArea{
                id:barBackground_Rightmouse
                anchors.fill: parent
                onClicked: {barPoint.x=rectdrag.width-barBlue_Right.width-barBlue_Left.width}}
    }
    Image{
        id:barBlue_Left
        anchors.left:barBackground_Left.left
        anchors.verticalCenter: parent.verticalCenter
        source: "../../../../images/Slider/Slider_Blue_Left.png"
    }
    Image{
        id:barBlue_Middle
        width: barPoint.x
        anchors.left:barBlue_Left.right
        anchors.verticalCenter: parent.verticalCenter
        source: "../../../../images/Slider/Slider_Blue_Middle.png"
    }
    Image{
        id:barBlue_Right
        anchors.left:barPoint.horizontalCenter
        anchors.verticalCenter: barBlue_Middle.verticalCenter
        source: "../../../../images/Slider/Slider_Blue_Right.png"
    }
    Image{
        id:barPoint
        x:enterValue
        anchors.verticalCenter: parent.verticalCenter
        source: "../../../../images/Slider/Slider_Pointer.png"
        onXChanged: {
            exportValue = barPoint.x
        }

        HMIMouseArea{
                   id:barPointmouse
                   x: 0
                   y: 0
                   anchors.rightMargin: 0
                   anchors.bottomMargin: 0
                   anchors.leftMargin: 0
                   anchors.topMargin: 0

                   anchors.fill: parent
                   drag.target: barPoint
                   drag.axis: "XAxis"
                   drag.minimumX: 0
                   drag.maximumX:rectdrag.width-barBlue_Right.width-barBlue_Left.width
                   onMouseXChanged: {
                       barPoint.x =add*((barPoint.x-barPoint.x%add)/add+((barPoint.x%add)/add>0.5?1:0));
                       enterValue = barPoint.x
//                       dragBarPoint();
                   }
                   onExited: {
                       dragBarPoint();      //by quanshaoying
                   }
        }
    }
}