import QtQuick 2.0 import "../com/neusoft/auto/widgets" //DEL 105303 2106/11/02 BAOJINFENG BEGIN //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: // { // //DEL #119567 2016/10/12 BAOJINFENG begin // //left_timer.start() // //DEL #119567 2016/10/12 BAOJINFENG END // } // 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: // { // //DEL #119567 2016/10/12 BAOJINFENG begin // //right_timer.start() // //DEL #119567 2016/10/12 BAOJINFENG begin // } // 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 // console.log("onReleased barPointX_backup" + barPointX_backup) // console.log("onReleased barPoint.x" + barPoint.x) // console.log("onReleased sliderMouseAreawidth" + sliderMouseAreawidth) // 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: // { // console.log("onMouseXChanged sliderMouseAreawidth" + sliderMouseAreawidth) // 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(); // } // } //} //} //DEL 105303 2106/11/02 BAOJINFENG END //ADD 105303 2106/11/02 BAOJINFENG BEGIN Item { id: rectdrag width: sliderMouseAreawidth + barPoint.width height: barPoint.height //property string bgImageStyle: systemCtrl.style//DEL #F0182 2017/02/03 baojinfeng begin 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 //add by y-xue for ST_Bug #151200 property int barPointX_onpressed_value: 0 //onPressed barPoint.x 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 property double barScale:0 property int enterValue property int exportValue : barPoint.x+barPoint.width/2 property bool pressflag: false property bool dragflag: true property bool dragflagpress: true signal dragingStart(); signal barClicked(); signal moveing(); signal dragingEnd(); signal sliderValue(); //ADD #F0197 2017/02/08 baojinfeng begin /*Slider Middle Image*/ Image { id:barBackground_Middle x:10 y:rectdrag.height/2 - 4 width:sliderMouseAreawidth height:20 source: "qrc:MATERIAL/MATERIAL_PROGRESS_BG_CENTRE"+bgImageStyle } Image { id:barBackground_left x:6 y:rectdrag.height/2 - 4 width:4//sliderMouseAreawidth height: 20 source: "qrc:MATERIAL/MATERIAL_PROGRESS_BG_LEFT"+bgImageStyle } Image { id:barBackground_down x:10+sliderMouseAreawidth y:rectdrag.height/2 - 4 width:4//sliderMouseAreawidth height: 20 source: "qrc:MATERIAL/MATERIAL_PROGRESS_BG_RIGHT"+bgImageStyle } /*Slider Middle Image Disable state*/ Image { id:barBlue_Middle x:10 y:rectdrag.height/2 - 4 width:barPoint.x height:20 //anchors.verticalCenter: parent.verticalCenter source: "qrc:MATERIAL/MATERIAL_PROGRESS_CENTRE"+bgImageStyle } Image { id:barBlue_left x:6 y:rectdrag.height/2 - 4 width:4 height:20 //anchors.verticalCenter: parent.verticalCenter source: "qrc:MATERIAL/MATERIAL_PROGRESS_LEFT"+bgImageStyle } Image { id:barBlue_right x:barPoint.x+10 y:rectdrag.height/2 - 4 width:4//barPoint.x height: 20 //anchors.verticalCenter: parent.verticalCenter source: "qrc:MATERIAL/MATERIAL_PROGRESS_RIGHT"+bgImageStyle } /*Slider barPoint Image */ Image { id:barPoint x:0//-barPoint.width/2+enterValue //y:10 anchors.verticalCenter: parent.verticalCenter width: 20 height: 20 source: "qrc:MATERIAL/MATERIAL_PROGRESS_BAR"+bgImageStyle } /* MouseArea是parent.width范围内有效的,但是滑块的有效位置是sliderMouseAreawidth范围有效的 */ HMIMouseArea { id:barBackground_Middlemouse x:0 width: rectdrag.width height: parent.height onClicked: { if (mouseX <= (barPoint.width/2)) { sliderMouseX = 0; } else if (mouseX >= (barPoint.width/2 + sliderMouseAreawidth)) { sliderMouseX = sliderMouseAreawidth; } else { sliderMouseX = mouseX - barPoint.width/2; } barPoint.x=add*((sliderMouseX-sliderMouseX%add)/add+((sliderMouseX%add)/add>0.5?1:0)); barPointX_backup = barPoint.x; clickSlider(); } // Rectangle // { // anchors.fill: parent // color: "yellow" // } } HMIMouseArea { anchors.fill: barPoint enabled: dragflagpress onReleased: { pressflag = false } onPressed: { pressflag = true } onCanceled: { pressflag = false } } HMIMouseArea { id:barPoint_mouseArea 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: 0//-barPoint.width/2 drag.maximumX: rectdrag.width//-barPoint.width/2 onMouseXChanged: { if((mouseX > 0) && (mouseX 0.5?1:0)); //only barPoint'position > unit of distance of half ,barPoint changed } else if(mouseX <= 0) { barPoint.x = 0//-barPoint.width/2 } else if(mouseX >= sliderMouseAreawidth) { barPoint.x = sliderMouseAreawidth// - barPoint.width/2 } else { //do nothing } enterValue = barPoint.x// +barPoint.width/2 sliderValue();//ADD #F0197 2017/02/08 baojinfeng begin } onReleased: { //DEL shanchulog 2017/1/9 baojinfeng begin // console.log("[barPoint_mouseArea] [onReleased]----------->mouseX:" + mouseX) // console.log("[barPoint_mouseArea] [onReleased]----------->barPointX_backup:" + barPointX_backup) // console.log("[barPoint_mouseArea] [onReleased]----------->barPoint.x:" + barPoint.x) //DEL shanchulog 2017/1/9 baojinfeng end //enterValue = mouseX if ((barPointX_backup != barPoint.x)&&((barPoint.x >= 0) && (barPoint.x <=sliderMouseAreawidth))) //barPoint have moved and in effective MouseArea { barPointX_backup = barPoint.x; clickSlider(); } else { //do nothing } dragingEnd(); pressflag = false } onPressed: { //add by y-xue for ST_Bug #151200 barPointX_onpressed_value = barPoint.x; dragingStart(); pressflag = true } onCanceled: { //add by y-xue for ST_Bug #151200 barPoint.x = barPointX_onpressed_value; barPointX_backup = barPointX_onpressed_value; sliderValue();//add by y-xue for ST_Bug #151200 dragingEnd(); pressflag = false } } } //ADD 105303 2106/11/02 BAOJINFENG END