/* * ===================================================================================== * * Filename: App_HMIMapScale.qml * * Description: * * Version: 1.0 * Created: 2016-1-5 15:50 * Revision: none * Compiler: gcc * * Author: jliu.neu, jliu.neu@neusoft.com * Organization: www.neusoft.com * * ===================================================================================== */ import "../../windowsList.js" as WindowsList import "../../eventsList.js" as EventsList import "../../layoutList.js" as Layout import QtQuick 2.0 import Label 2.0 Item{ id:com_component property bool bVisible_dir : true property bool bVisible_scale : true property bool bVisible_curr : true property bool bLongPress: false property string sDestName:"" property int iFreeZoomScale: -1 property int iScale: 2 property int iDirType: 0 property int iCharNum:22 property alias currentX: current.x property alias currentImg: current.source property int iAngle:0 property bool bMapMove: false property bool bIsVisibleCurr: true property bool bIsTMCVisible: false property bool bTMCswitch:false property int iPreX:0 property int iPreY:0 onVisibleChanged:{ if(visible&&(iAngle==0)){ iAngle = applinkControl.QML_GetCarAngleForLocation(); } } Connections{ target:applinkControl onSignal_PickUpMapName:{ if(ScreenManager.getCurrentFormId()==WindowsList.APP_OPEN_MAP||ScreenManager.getCurrentFormId()==WindowsList.APP_OPEN_MAP_SEC){ if(bIsVisibleCurr===false){ sDestName = QPickUpName } }else if(visible && ScreenManager.getCurrentFormId()!=WindowsList.APP_LOCATION){ sDestName = QPickUpName } } onSignal_UpdateCarAngle:{ if(visible){ iAngle = angle } } onSignalHKEvent:{ if(true == windowPinch.visible){ windowPinch.visible = false windowPinch.visible = true } if(true == mapMouseArea.visible){ mapMouseArea.visible = false mapMouseArea.visible = true } } } PinchArea{ id: windowPinch x:0 y:0//-160 width: 960 height: 960//480*1.14 onPinchStarted: { applinkControl.QML_startPinchScale(); //console.log("=========================onPinchStarted") } onPinchUpdated: { //console.log("=========================onPinchUpdated====pinch.scale:"+pinch.scale) if(ScreenManager.getCurrentFormId()==WindowsList.APP_DEMO){return;} iFreeZoomScale = applinkControl.QML_NIF_Map_FreeZoom(pinch.scale) //console.log("========================pinch.scale====="+pinch.scale) if(iFreeZoomScale != -1){ iScale = iFreeZoomScale; } } onPinchFinished: { //console.log("=========================onPinchFinished") if(ScreenManager.getCurrentFormId()==WindowsList.APP_DEMO){return;} if(ScreenManager.getCurrentFormId()===WindowsList.APP_LOCATION){ applinkControl.QML_NIF_Map_GetCommonScaleStatus(iScale); } if(bMapMove){ applinkControl.QML_NIF_Map_EndDragMap(); bMapMove = false; if(ScreenManager.getCurrentFormId()==WindowsList.APP_LOCATION){ ScreenManager.forward(Layout.APPLINK,WindowsList.APP_LOCATION_MOVE); } if(ScreenManager.getCurrentFormId()==WindowsList.APP_OPEN_MAP||ScreenManager.getCurrentFormId()==WindowsList.APP_OPEN_MAP_SEC){ bIsVisibleCurr = false; } } } MouseArea { id: mapMouseArea anchors.fill: parent onPressed:{ //console.log("=========================mapMouseArea onPressed") if(ScreenManager.getCurrentFormId()==WindowsList.APP_DEMO){return;} //applinkControl.QML_NIF_Map_StartDragMap() iPreX = mouseX; iPreY = mouseY; } onPositionChanged: { //console.log("=========================mapMouseArea onPositionChanged") if(ScreenManager.getCurrentFormId()==WindowsList.APP_DEMO){return;} if(Math.abs(mouseX - iPreX)<5 && Math.abs(mouseY - iPreY)<5){ }else{ if(!bMapMove){ applinkControl.QML_NIF_Map_StartDragMap() } applinkControl.QML_NIF_Map_DragAndMoveMap(-(mouseX - iPreX),mouseY - iPreY) bMapMove = true; iPreX = mouseX; iPreY = mouseY; } } onReleased:{ //console.log("=========================mapMouseArea onReleased") if(ScreenManager.getCurrentFormId()==WindowsList.APP_DEMO){return;} if(bMapMove){ applinkControl.QML_NIF_Map_EndDragMap(); bMapMove = false; if(ScreenManager.getCurrentFormId()==WindowsList.APP_LOCATION){ ScreenManager.forward(Layout.APPLINK,WindowsList.APP_LOCATION_MOVE); } if(ScreenManager.getCurrentFormId()==WindowsList.APP_OPEN_MAP||ScreenManager.getCurrentFormId()==WindowsList.APP_OPEN_MAP_SEC){ bIsVisibleCurr = false; } } } } } //===========================direction===========================// Item{ id:direction_item x:0 y:797//4 width: 98 height: 80 visible: bLongPress?false:true MouseArea{ id: directionMouseArea anchors.fill: parent } HMIButton{ id: direction enabled: bVisible_dir btnImg: direction.pressed?imagePath_navi+"M8X_Location_Button_p.png":imagePath_navi+"M8X_Location_Button.png" Image{ id:direction_Ring anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source:applinkControl.QML_getDirectionRingImagePath(bVisible_dir, iDirType) } Image{ id:direction_icon anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source:applinkControl.QML_converAzimuthToImagePath(bVisible_dir, 0, iDirType) transform: Rotation { origin.x: direction_icon.width / 2; origin.y: direction_icon.height / 2; axis { x: 0; y: 0; z: 1 } angle: ((iDirType==0)?0:(360-iAngle)); } } onClicked: { if(ScreenManager.getCurrentFormId()===WindowsList.APP_LOCATION){ iDirType = applinkControl.QML_NIF_Map_ChangeAzimuth(true); }else{ iDirType = applinkControl.QML_NIF_Map_ChangeAzimuth(false); } } } } //===========================mapscale===========================// Image{ id: mapscale x:102//0 y:797//957-160//796 visible: bLongPress?false:bVisible_scale source:imagePath_navi+ "M8X_Scale_bg.png" MouseArea{ anchors.fill: parent } HMIButton{ id: scaleDown x:126-parent.x y:964-160-parent.y btnImg:scaleDown.pressed?imagePath_navi+"M8X_Scale_-_p.png":imagePath_navi+"M8X_Scale_-.png" //enabled: (iScale === 14)?false:true onClicked:{ if(iScale < 14){ if(ScreenManager.getCurrentFormId()===WindowsList.APP_LOCATION){ if(applinkControl.QML_NIF_Map_SetScale((iScale+1), true)==0){ iScale = iScale + 1; } }else{ if(applinkControl.QML_NIF_Map_SetScale((iScale+1), false)==0){ iScale = iScale + 1; } } } } } HMILabel{ id: scaleText x:199-parent.x - 10//10 for extend y:975-160-parent.y width:84 + 10*2 height:28 text: applinkControl.QML_converScaleLevelToString(iScale) font.pixelSize: 28 } Image{ id: scaleNumImg x:213-parent.x y:1002-160-parent.y source: imagePath_navi+"M8X_Scale_Bar.png" } HMIButton{ id: scaleUp x:295-parent.x y:964-160-parent.y btnImg:scaleUp.pressed?imagePath_navi+"M8X_Scale_+_p.png":imagePath_navi+"M8X_Scale_+.png" //enabled: (iScale===0)?false:true onClicked:{ if(iScale > 0){ if(ScreenManager.getCurrentFormId()===WindowsList.APP_LOCATION){ if(applinkControl.QML_NIF_Map_SetScale((iScale-1), true)==0){ iScale = iScale - 1; } }else{ if(applinkControl.QML_NIF_Map_SetScale((iScale-1), false)==0){ iScale = iScale - 1; } } } } } } //===========================current===========================// Image{ id:current x:384 y:797//957-160 visible: bLongPress?false:bVisible_curr source:bVisible_dir?(bIsTMCVisible?imagePath_navi+"Current-road-name_bg_w474.png":imagePath_navi+"M8X_Current-road-name_bg.png"):imagePath_navi+"M8X_Current-road-name_bg_w372.png" width:bVisible_dir?(bIsTMCVisible?474:576):372 HMILabel{ id:current_info x:48 y:25 width: parent.width - 60//580 height: 36 text:applinkControl.QML_cutStringForDisplay(sDestName, iCharNum) font.pixelSize: 30 horizontalAlignment: Text.AlignLeft elide:Text.ElideRight verticalAlignment: Text.AlignTop } MouseArea{ id: mouseArea anchors.fill: parent } } //===========================TMC===========================// HMIButton{ visible: bIsTMCVisible && !bLongPress x:862 y:797//796 width:98 height:80 btnImg:imagePath_navi+"M8X_Location_Button.png" btnImgOnPressed:imagePath_navi+"M8X_Location_Button_p.png" Image{ x:879-parent.x y:983-160-parent.y source:bTMCswitch?imagePath_navi+"M8X_icon_Live-traffic_Checked.png":imagePath_navi+"M8X_icon_Live-traffic.png" } onClicked: { if (bTMCswitch) { bTMCswitch = !bTMCswitch applinkControl.QML_NIF_Tmc_SetShowSwitch(bTMCswitch) } else { applinkControl.QML_NIF_Tmcpay_RequestAuthcode(applinkControl.QML_GetTmcPayGetStr()) } } } }