import QtQuick 2.0 import "../com/neusoft/auto/widgets" Item { id: rectdrag width: sliderMouseAreawidth + barPoint.width height: barPoint.height property string bgImageStyle: systemCtrl.style property int xPosition : (barPoint.x) / (add) // property alias barPointTXT:barPointText.text property alias barBackgroundMiddleSource: barBackground_Middle.source property alias barBlueMiddleSource: barBlue_Middle.source property alias barPointSource: barPoint.source property alias barPointWidth: barPoint.width property alias barPointHeight: barPoint.height property alias barPoint_X: barPoint.x property alias barPoint_Y: barPoint.y property int sliderMouseAreawidth : 100 //slider effective move MouseAreawidth property int sliderpartnum: 100 //Slider interval count property double add : (sliderMouseAreawidth / sliderpartnum) //slider'unit of distance property int sliderMouseX: 0 //effective MouseX property int sliderbarPointX: 0 //effective barPointX property int barPointX_backup: 0 //backup barPointX property int pressedPos : 0 //backup barPointX property bool sliderIsDisable: false //slider Invalid flag: true-->Invalid;false-->effective signal clickSlider(); // drag signal signal addClicked(); // add signal signal subClicked(); // subtract signal /*Slider Middle Image*/ Image { id:barBackground_Middle x:0 y:rectdrag.height/2 - 4 width:sliderMouseAreawidth //anchors.verticalCenter: parent.verticalCenter source: "qrc:MATERIAL/MATERIAL_M8X_PROGRESS_BG"+bgImageStyle } /* click sliderbar Lift Step - 1 */ HMIMouseArea { id:left2barPointmouse_MouseArea x:0 //y:0 height: parent.height/2 anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.right: barPoint.left onClicked: { if (barPoint.x > pressedPos) { barPoint.x = barPoint.x - add; barPointX_backup = barPoint.x subClicked(); } else { //do nothing } } onPressed: { pressedPos = mouseX; } onLongPress: { left_timer.start() } onReleased: { left_timer.stop(); } onCanceled: { left_timer.stop(); } } /* click sliderbar Right Step +1*/ HMIMouseArea { id:right2barPointmouse_MouseArea x:0 //y:0 height: parent.height/2 anchors.verticalCenter: parent.verticalCenter anchors.left: barPoint.right anchors.right: parent.right onClicked: { if ((barPoint.x) < pressedPos) { barPoint.x = barPoint.x + add; barPointX_backup = barPoint.x addClicked(); } } onPressed: { pressedPos = right2barPointmouse_MouseArea.x + mouseX; } onLongPress: { right_timer.start() } onReleased: { right_timer.stop(); } onCanceled: { right_timer.stop(); } } /*Slider Middle Image Disable state*/ Image { id:barBlue_Middle x:0 y:rectdrag.height/2 - 4 width:barPoint.x //anchors.verticalCenter: parent.verticalCenter source: "qrc:MATERIAL/MATERIAL_M8X_PROGRESS"+bgImageStyle } /*Slider barPoint Image */ Image { id:barPoint x:0 //y:10 anchors.verticalCenter: parent.verticalCenter width: 20 height: 20 source: "qrc:MATERIAL/MATERIAL_M8X_PROGRESS_BAR"+bgImageStyle onXChanged: { } HMIMouseArea { id:barPointmouse x: 0 y: -((rectdrag.height - barPoint.height)/2) anchors.rightMargin: 0 anchors.bottomMargin: 0 anchors.leftMargin: 0 anchors.topMargin: 0 width: 20 height: rectdrag.height //anchors.fill: parent drag.target: barPoint drag.axis: "XAxis" drag.minimumX: 0 drag.maximumX: sliderMouseAreawidth onPressed: { } onReleased: { barPoint.x =add*((barPoint.x-barPoint.x%add)/add+((barPoint.x%add)/add>0.5?1:0)); //only barPoint'position > unit of distance of half ,barPoint changed if ((barPointX_backup != barPoint.x)&&(0 < barPoint.x < sliderMouseAreawidth)) //barPoint have moved and in effective MouseArea { barPointX_backup = barPoint.x; clickSlider(); } else { //do nothing } } onMouseXChanged: { barPoint.x =add*((barPoint.x-barPoint.x%add)/add+((barPoint.x%add)/add>0.5?1:0)) //only barPoint'position > unit of distance of half ,barPoint changed } } } /* click sliderbar left Step timer*/ Timer { id:left_timer interval: 200 running: false repeat: true onTriggered: { if (barPoint.x > pressedPos) { barPoint.x = barPoint.x - add; subClicked(); } else { left_timer.stop(); } } } /* click sliderbar right timer*/ Timer { id:right_timer interval: 200 running: false repeat: true onTriggered: { if (((barPoint.x) < pressedPos)&&(0>=pressedPos<=sliderMouseAreawidth)) { barPoint.x = barPoint.x + add; addClicked(); } else { right_timer.stop(); } } } }