/* * ===================================================================================== * * Filename: ALCSlider.qml * * Description: * * Version: 1.0 * Created: 2014-05-08 * Revision: none * Compiler: gcc * * Author: zhou-hb@neusoft.com * Organization: www.neusoft.com * * ===================================================================================== */ import QtQuick 2.0 import "./" import "../com/neusoft/auto/widgets" Item { id: rectdrag property int value: 0 property int xPosition:(barPoint.x)/add - value//(org + ((barPoint.x-barPoint.x%add)/add+((barPoint.x%add)/add>0.5?1:0)) * 0.2) property int yPosition:(-((barPoint.y)/add_y - value))//(org + ((barPoint.x-barPoint.x%add)/add+((barPoint.x%add)/add>0.5?1:0)) * 0.2) property int enterValue property string bgImageStyle: systemCtrl.style onEnterValueChanged: { barPoint.x = enterValue } property int enterValue_y onEnterValue_yChanged: { barPoint.y = enterValue_y } property int exportValue: barPoint.x property int exportValue_Y: barPoint.y //property alias imagebarBackgroundMiddleSource: image_background_Middle.source property alias barBackgroundMiddle_X: barBackground_Middle.x property alias barBackgroundMiddle_Y: barBackground_Middle.y property alias barBackgroundMiddle_H: barBackground_Middle.height property alias barBackgroundMiddle_W: barBackground_Middle.width property alias barPoint_X: barPoint.x property alias barPoint_Y: barPoint.y property alias barPoint_H: barPoint.height property alias barPoint_W: barPoint.width property alias barPointSource: barPoint.source property int barBackgroundMiddle_space: 0 //grid space property double add : (maxDrag / sliderpartnum) //slider'unit of distance property double add_y : (maxDrag_y / sliderpartnum) //slider'unit of distance property int sliderpartnum: 14 property int minDrag: (0) property int minDrag_y: (0) property int maxDrag: image_background_Middle.width property int maxDrag_y: image_background_Middle.height property alias barBackgroundMiddlemouse:barBackground_Middlemouse.opacity property int barPointX_backup: 0 //backup barPointX property int barPointY_backup: 0 //backup barPointX //add by y-xue for ST_Bug #ST_Bug #153531 property int barPointX_onpressed_value: 0 //onPressed barPoint.x property int barPointY_onpressed_value: 0 //onPressed barPoint.y //add by y-xue for ST_Bug #ST_Bug #153531 signal clickSlider_x(); signal clickSlider_y(); signal dragBarPoint(); width: barBackground_Middle.width//+/*bar_left.width+bar_right.width + */barPoint.width height: barBackground_Middle.height//+/*bar_up.height+bar_down.height + */barPoint.height /*Up button*/ HMIButton { id:barPointUp_btn x:453// 456 //FOD F0056 2016/10/24 liuming begin //y: 316 y:311//326 //FOD F0056 2016/10/24 liuming end width: 54//48 height:52// 45 btnImg: pressed?"qrc:MATERIAL/MATERIAL_ARROW_U_P"+bgImageStyle:"qrc:MATERIAL/MATERIAL_ARROW_U"+bgImageStyle onClicked: { if(yPosition <7 ) { barPoint.y = barPoint.y - add_y barPointY_backup = barPoint.y clickSlider_y(); } } } /*Down button*/ HMIButton { id:barPointDown_btn x: 453//456 //FOD F0056 2016/10/24 liuming begin //y: 623 y: 617//633 //FOD F0056 2016/10/24 liuming end width: 54//48 height:52// 45 btnImg: pressed?"qrc:MATERIAL/MATERIAL_ARROW_D_P"+bgImageStyle:"qrc:MATERIAL/MATERIAL_ARROW_D"+bgImageStyle onClicked: { if(yPosition > -7 ) { barPoint.y = barPoint.y + add_y barPointY_backup = barPoint.y clickSlider_y(); } } } /*Left button*/ HMIButton { id:barPointLeft_btn x: 301//304 //FOD F0056 2016/10/24 liuming begin //y: 469 y:463//478 //FOD F0056 2016/10/24 liuming end width: 52//45 height: 54//48 btnImg: pressed?"qrc:MATERIAL/MATERIAL_ARROW_L_P"+bgImageStyle:"qrc:MATERIAL/MATERIAL_ARROW_L"+bgImageStyle onClicked: { if(xPosition > -7 ) { barPoint.x = barPoint.x - add barPointX_backup = barPoint.x; clickSlider_x(); } } } /*Right button*/ HMIButton { id:barPointRight_btn x: 607//611 //FOD F0056 2016/10/24 liuming begin //y: 469 y:463//478 //FOD F0056 2016/10/24 liuming end width: 52//45 height: 54//48 btnImg: pressed?"qrc:MATERIAL/MATERIAL_ARROW_R_P"+bgImageStyle:"qrc:MATERIAL/MATERIAL_ARROW_R"+bgImageStyle onClicked: { if(xPosition < 7 ) { barPoint.x = barPoint.x + add barPointX_backup = barPoint.x; //add by plc clickSlider_x(); } } } /*Frame*/ Item { id:barBackground_Middle x:351//298//-barPoint.width / 2 //FOD F0056 2016/10/24 liuming begin //y: 358//-barPoint.height / 2 y:358//368 //FOD F0056 2016/10/24 liuming begin //FOD #137680 2016/12/21 baojinfeng begin width:265//(image_background_Middle.width + barPoint.width) height:265//(image_background_Middle.height + barPoint.height) //FOD #137680 2016/12/21 baojinfeng end opacity: 1 Item { id:image_background_Middle //FOD #F0182 2017/02/03 baojinfeng begin x:44//41//barPoint.width / 2 y:44//41//barPoint.height / 2 width: 170//186//268-82 height:172//186//268-82 //FOD #F0182 2017/02/03 baojinfeng end //source: "qrc:MATERIAL/MATERIAL_M8X_SOUND-FRAME"+bgImageStyle //anchors.verticalCenter: parent.verticalCenter //anchors.horizontalCenter: parent.horizontalCenter HMIMouseArea { id:barBackground_Middlemouse anchors.fill: parent onClicked: { //FOD #137680 2016/12/21 baojinfeng begin if(mouseX<0) { barPoint.x=0 } else if(mouseX>image_background_Middle.width) { barPoint.x=image_background_Middle.width } else { barPoint.x=add*((mouseX-mouseX%add)/add+((mouseX%add)/add>0.5?1:0)) //- barPoint.width / 2// + barBackgroundMiddle_space/2 } if(mouseY<0) { barPoint.y=0 } else if(mouseY>image_background_Middle.height) { barPoint.y=image_background_Middle.height } else { barPoint.y=add_y*((mouseY-mouseY%add_y)/add_y+((mouseY%add_y)/add_y>0.5?1:0)) //- barPoint.height / 2// + barBackgroundMiddle_space/2 } //FOD #137680 2016/12/21 baojinfeng end barPointX_backup = barPoint.x; barPointY_backup = barPoint.y; clickSlider_x(); clickSlider_y(); } onReleased: { } } } /* barPoint Image*/ Image { id:barPoint x:84//436//439//93//439-346 //FOD F0056 2016/10/24 liuming begin //y:451//93//451-358 y:86//446//461 //FOD F0056 2016/10/24 liuming begin width: 88//82 height: 88//82 source: (barPoint_mouseArea.pressed||barPointUp_btn.pressed||barPointDown_btn.pressed||barPointRight_btn.pressed||barPointLeft_btn.pressed)?"qrc:MATERIAL/MATERIAL_SOUND-ICON_P"+bgImageStyle:"qrc:MATERIAL/MATERIAL_SOUND-ICON"+bgImageStyle//FOD H0017 2016/11/10 baojinfeng begin // anchors.horizontalCenter: parent.horizontalCenter // anchors.verticalCenter: parent.verticalCenter } //ADD #H0017 2016/11/02 baojinfeng Begin HMIMouseArea { id:barPoint_mouseArea //FOD F0056 2016/11/04 liuming begin //FOD #137680 2016/12/21 baojinfeng begin x: 0//barPoint.width / 2 y: 0//barPoint.height / 2 //FOD #137680 2016/12/21 baojinfeng end //FOD F0056 2016/11/04 liuming begin enabled: true anchors.rightMargin: 0 anchors.bottomMargin: 0 anchors.leftMargin: 0 anchors.topMargin: 0 //FOD #137680 2016/12/21 baojinfeng begin width:258//268//- barPoint.width / 2//FOD H0017 2016/11/10 baojinfeng begin height: 256//268// - barPoint.height / 2//FOD H0017 2016/11/10 baojinfeng begin //FOD #137680 2016/12/21 baojinfeng end //anchors.fill: image_background_Middle//parent drag.target: barPoint drag.axis: Drag.XAndYAxis drag.minimumX: 0//-barPoint.width/2 drag.maximumX: 170//227//image_background_Middle.width+41//-barPoint.width/2//FOD #F0182 2017/02/03 baojinfeng begin drag.minimumY: 0//ADD #147502 2017/2/14 baojinfeng End drag.maximumY: 172//227//ADD #147502 2017/2/14 baojinfeng End onMouseXChanged: { if((mouseX > 41) && (mouseX <(image_background_Middle.width+41)))//FOD #137680 2016/12/21 baojinfeng { barPoint.x=add*(((mouseX-41)-(mouseX-41)%add)/add+(((mouseX-41)%add)/add>0.5?1:0)) //- barPoint.width / 2// + barBackgroundMiddle_space/2 //FOD #137680 2016/12/21 baojinfeng } else if(mouseX <= 41)//FOD #137680 2016/12/21 baojinfeng { barPoint.x = 0//-barPoint.width/2 } else if(mouseX >= (image_background_Middle.width+41))//FOD #137680 2016/12/21 baojinfeng { barPoint.x = image_background_Middle.width// - barPoint.width/2 } else { //do nothing } } onMouseYChanged: { if((mouseY > 41) && (mouseY <(image_background_Middle.height+41)))//FOD #137680 2016/12/21 baojinfeng { barPoint.y=add_y*(((mouseY-41)-(mouseY-41)%add_y)/add_y+(((mouseY-41)%add_y)/add_y>0.5?1:0)) //- barPoint.height / 2// + barBackgroundMiddle_space/2 //FOD #137680 2016/12/21 baojinfeng } else if(mouseY <= 41) //FOD #137680 2016/12/21 baojinfeng begin { barPoint.y = 0//-barPoint.width/2 } else if(mouseY >= (image_background_Middle.height+41)) { barPoint.y = image_background_Middle.height// - barPoint.width/2 } else { //do nothing } } onReleased: { if (((barPoint.x >= 0) && (barPoint.x <=image_background_Middle.width))&&((barPoint.y >= 0) && (barPoint.y <=image_background_Middle.height))&&(barPointX_backup != barPoint.x||barPointY_backup != barPoint.y)) //fod #147502 2017/2/14 baojinfeng End { barPointX_backup = barPoint.x; barPointY_backup = barPoint.y; clickSlider_x(); clickSlider_y(); } else { //do nothing } } onPressed: { //add by y-xue for ST_Bug #ST_Bug #153531 barPointX_onpressed_value = barPoint.x; barPointY_onpressed_value = barPoint.y; //console.log("onPressed--->barPointX_onpressed_value-->" + barPoint.x) //console.log("onPressed--->barPointY_onpressed_value-->" + barPoint.y) //add by y-xue for ST_Bug #ST_Bug #153531 } onCanceled: { //add by y-xue for ST_Bug #ST_Bug #153531 if (((barPoint.x >= 0) && (barPoint.x <=image_background_Middle.width))&&((barPoint.y >= 0) && (barPoint.y <=image_background_Middle.height))&&(barPointX_backup != barPoint.x||barPointY_backup != barPoint.y)) //fod #147502 2017/2/14 baojinfeng End { barPoint.x = barPointX_onpressed_value; barPointX_backup = barPointX_onpressed_value; barPoint.y = barPointY_onpressed_value; barPointY_backup = barPointY_onpressed_value; clickSlider_x(); clickSlider_y(); } else { //do nothing } //add by y-xue for ST_Bug #ST_Bug #153531 } } //ADD #H0017 2016/11/02 baojinfeng End } }