diff options
author | Viktor Verebelyi <vviktor2@gmail.com> | 2021-06-17 23:16:57 +0100 |
---|---|---|
committer | Viktor Verebelyi <vviktor2@gmail.com> | 2021-06-17 23:16:57 +0100 |
commit | b25eb92ff66b579027f4d6cd9da0310fce32e457 (patch) | |
tree | 093e53fcfaed0f72e29df79ea61d020f271951c5 | |
parent | 9ba2a903d9931bc385fa518fa080b854050c7ce5 (diff) | |
download | navit-b25eb92ff66b579027f4d6cd9da0310fce32e457.tar.gz |
fix:graphics:qt5 various fixes
-rw-r--r-- | navit/gui/qt5_qml/navitroute.cpp | 58 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/MainLayout.qml | 228 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/MapControls.qml | 6 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/MenuDrawer.qml | 70 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/SearchDrawerRecentsList.qml | 2 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml | 2 |
6 files changed, 152 insertions, 214 deletions
diff --git a/navit/gui/qt5_qml/navitroute.cpp b/navit/gui/qt5_qml/navitroute.cpp index b7c8febe0..d1d025355 100644 --- a/navit/gui/qt5_qml/navitroute.cpp +++ b/navit/gui/qt5_qml/navitroute.cpp @@ -139,41 +139,43 @@ void NavitRoute::routeUpdate(){ if (navit_get_attr(m_navitInstance->getNavit(), attr_route, &route, nullptr)) { struct attr destination_length, destination_time; - char *distance=nullptr,*timeLeft=nullptr; if (route_get_attr(route.u.route, attr_destination_length, &destination_length, nullptr)){ - distance=attr_to_text_ext(&destination_length, nullptr, attr_format_with_units, attr_format_default, nullptr); + m_distance = attr_to_text_ext(&destination_length, nullptr, attr_format_with_units, attr_format_default, nullptr); } if (route_get_attr(route.u.route, attr_destination_time, &destination_time, nullptr)){ - timeLeft=attr_to_text_ext(&destination_time, nullptr, attr_format_with_units, attr_format_default, nullptr); - } - - QStringList timeLeftArr = QString(timeLeft).split(":"); - QDateTime dt = QDateTime::currentDateTime(); - QTime time; - - switch (timeLeftArr.size()) { - case 4: - dt = dt.addDays(timeLeftArr[0].toInt()); - time.setHMS(timeLeftArr[1].toInt(),timeLeftArr[2].toInt(),timeLeftArr[3].toInt()); - break; - case 3: - time.setHMS(timeLeftArr[0].toInt(),timeLeftArr[1].toInt(),timeLeftArr[2].toInt()); - break; - case 2: - time.setHMS(0,timeLeftArr[0].toInt(),timeLeftArr[1].toInt()); - break; - case 1: - time.setHMS(0,0,timeLeftArr[0].toInt()); - break; - } + char test[] = ": ads :"; + + QStringList timeLeft = QString(attr_to_text_ext(&destination_time, test, attr_format_with_units, attr_format_default, nullptr)).split(":"); + QDateTime dt = QDateTime::currentDateTime(); + QTime time; + + switch (timeLeft.size()) { + case 4: + // m_timeLeft = QString("%1 days %2 hours %3%4").arg(""); + dt = dt.addDays(timeLeft[0].toInt()); + time.setHMS(timeLeft[1].toInt(),timeLeft[2].toInt(),timeLeft[3].toInt()); + m_timeLeft = QString("%1 day %2 h %3 min").arg(timeLeft[0].toInt()).arg(timeLeft[1].toInt()).arg(timeLeft[2].toInt()); + break; + case 3: + time.setHMS(timeLeft[0].toInt(),timeLeft[1].toInt(),timeLeft[2].toInt()); + m_timeLeft = QString("%1 h %2 min").arg(timeLeft[0].toInt()).arg(timeLeft[1].toInt()); + break; + case 2: + time.setHMS(0,timeLeft[0].toInt(),timeLeft[1].toInt()); + m_timeLeft = QString("%1 min").arg(timeLeft[0].toInt()); + break; + case 1: + time.setHMS(0,0,timeLeft[0].toInt()); + m_timeLeft = QString("%1 seconds").arg(timeLeft[0].toInt()); + break; + } - dt = dt.addMSecs(time.msecsSinceStartOfDay()); + dt = dt.addMSecs(time.msecsSinceStartOfDay()); - m_distance = distance; - m_timeLeft = timeLeft; - m_arrivalTime = dt.toString("hh:mm"); + m_arrivalTime = dt.toString("hh:mm"); + } } struct attr vehicle,speed_attr; diff --git a/navit/gui/qt5_qml/themes/Levy/MainLayout.qml b/navit/gui/qt5_qml/themes/Levy/MainLayout.qml index 478b111ef..08e64a18a 100644 --- a/navit/gui/qt5_qml/themes/Levy/MainLayout.qml +++ b/navit/gui/qt5_qml/themes/Levy/MainLayout.qml @@ -11,6 +11,13 @@ Item { property string prevState: "" height: parent.height + onStateChanged: { + if(state != "mapControlsVisible") { + mapControlsTimer.stop() + } + console.log(state) + } + QtObject { id:navigation @@ -20,7 +27,7 @@ Item { previous_pitch = navit1.pitch; __root.state = "routeOverview" navit1.pitch = 0; - navit1.followVehicle = 0; + navit1.followVehicle = false; navit1.zoomToRoute(); navit1.zoomOut(2); } @@ -30,8 +37,9 @@ Item { __root.prevState = "" mapNavigationBar.setNavigationState() -// navit1.pitch = 45; - navit1.followVehicle = 1 + navit1.pitch = 45; + navit1.orientation = -1 + navit1.followVehicle = true navit1.autoZoom = true navit1.centerOnPosition() } @@ -39,7 +47,8 @@ Item { function cancelNavigation() { __root.state = __root.prevState __root.prevState = "" - navit1.followVehicle = 1; + navit1.followVehicle = true; + navit1.pitch = 0; } } @@ -67,94 +76,77 @@ Item { NavitMap { id: navit1 anchors.leftMargin: 0 + anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom + anchors.right: parent.right width: parent.width navit:Navit - } - - Text { - x: 25 - y: 25 - text: "Zoom Level : " + navit1.zoomLevel - } - onStateChanged: { - if(state != "mapControlsVisible") { - mapControlsTimer.stop() - } - } - - MouseArea { - id: mouseArea4 - enabled: true - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - - property int originX: 0 - property int originY: 0 property bool hasMoved : false - onClicked: { - switch(mouse.button){ - case Qt.LeftButton : - if(__root.state == ""){ - mapControls.showControls() - } - break; - case Qt.RightButton : - navit1.followVehicle = 0 - pinpointPopup.mouseY = mouse.y - pinpointPopup.mouseX = mouse.x - pinpointPopup.address = navit1.getAddress(mouse.x, mouse.y) - pinpointPopup.open() - break; + onLeftButtonClicked: { + if(__root.state == ""){ + mapControls.showControls() } } - onPressed: { - originX = mouse.x - originY = mouse.y - hasMoved = false + onRightButtonClicked: { + navit1.followVehicle = false + pinpointPopup.mouseY = position.y + pinpointPopup.mouseX = position.x + pinpointPopup.address = navit1.getAddress(position.x, position.y) + pinpointPopup.open() } onPositionChanged: { mapControls.restartTimer() hasMoved = true - if(mouse.modifiers === Qt.ShiftModifier){ - var pitch = Math.floor((originY - mouse.y) / 10); - var orientation = navit1.orientation + ( Math.floor((mouse.x - originX)) / 10 ); - - if(navit1.pitch + pitch < 0 ) { - navit1.pitch = 0 - } else if(navit1.pitch + pitch > 60 ) { - navit1.pitch = 60 - } else { - navit1.pitch += pitch; - } - - navit1.orientation = orientation % 360 + } + } - } else { - navit1.followVehicle = 0 - navit1.mapMove(originX, originY, mouse.x, mouse.y); - originX = mouse.x - originY = mouse.y - } + Text { + id:zoomLevel + text: "Zoom Level : " + navit1.zoomLevel + } + Text { + id: pitch + text: "Pitch : " + navit1.pitch + anchors.top: zoomLevel.bottom + } + Text { + id: orientation + text: "Orientation : " + navit1.orientation + anchors.top: pitch.bottom + MouseArea { + anchors.fill:parent + onClicked: navit1.orientation = !navit1.orientation } - onWheel: { - if (wheel.angleDelta.y > 0) - navit1.zoomInToPoint(2, wheel.x, wheel.y) - else - navit1.zoomOutFromPoint(2, wheel.x, wheel.y) + } + Text { + id: followVehcile + text: "Follow Vehicle : " + navit1.followVehicle + anchors.top: orientation.bottom + MouseArea { + anchors.fill:parent + onClicked: navit1.followVehicle = !navit1.followVehicle } - onPressAndHold: { - if(!hasMoved){ - navit1.followVehicle = 0 - pinpointPopup.mouseY = mouse.y - pinpointPopup.mouseX = mouse.x - pinpointPopup.address = navit1.getAddress(mouse.x, mouse.y) - pinpointPopup.open() - } + } + Text { + id: tracking + text: "Tracking : " + navit1.tracking + anchors.top: followVehcile.bottom + MouseArea { + anchors.fill:parent + onClicked: navit1.tracking = !navit1.tracking + } + } + Text { + id: autozoom + text: "Auto Zoom : " + navit1.autoZoom + anchors.top: tracking.bottom + MouseArea { + anchors.fill:parent + onClicked: navit1.autoZoom = !navit1.autoZoom } } @@ -199,7 +191,7 @@ Item { navit1.autoZoom = !navit1.autoZoom } onCompassClicked: { - navit1.orientation = 0 + navit1.orientation = -1 } function showControls () { @@ -295,7 +287,6 @@ Item { id: destinationDetailsBar height: parent.width > parent.height ? parent.height * 0.15 : parent.width * 0.25 anchors.topMargin: parent.height * 0.05 - // visible: false clip: true anchors.top: routeCalculating.bottom anchors.horizontalCenter: parent.horizontalCenter @@ -364,8 +355,9 @@ Item { width: 71 anchors.fill: parent onClicked: { - navit1.followVehicle = 1 + navit1.followVehicle = true navit1.autoZoom = true + navit1.orientation = -1 navit1.centerOnPosition() } } @@ -497,7 +489,6 @@ Item { }, State { name: "searchDrawerOpen" - when: mapNavigationBar.searchButtonClicked PropertyChanges { target: searchDrawer x: 0 @@ -506,23 +497,9 @@ Item { PropertyChanges { target: overlay - // color: parent.width > parent.height ? "#00000000" : "#a6000000" - // visible: parent.width < parent.height color: "#a6000000" visible: true } - - PropertyChanges { - target: mouseArea4 - // enabled: true - enabled: false - } - - PropertyChanges { - target: navit1 - //width: parent.width > parent.height ? parent.width - searchDrawer.width : parent.width - - } }, State { name: "searchDrawerSearchActive" @@ -538,21 +515,9 @@ Item { color: "#a6000000" visible: true } - - PropertyChanges { - target: mouseArea4 - enabled: false - } }, State { name: "routeOverview" - // PropertyChanges { - // target: searchDrawer - // x: 0 - // y: -height - // width: parent.width - // visible: true - // } PropertyChanges { target: overlay @@ -597,10 +562,6 @@ Item { visible: true } - PropertyChanges { - target: mouseArea4 - enabled: false - } }, State { name: "routeOverviewPOIs" @@ -706,34 +667,6 @@ Item { NumberAnimation { property: "x"; easing.type: Easing.InOutQuad; } }, - // Transition { - // from: "searchDrawerOpen" - // to: "routeOverview" - // SequentialAnimation { - // PropertyAction { - // target: destinationBar - // property: "visible" - // value: true - // } - // ParallelAnimation { - // ColorAnimation { } - // NumberAnimation { - // property: "width"; - // easing.type: Easing.InOutQuad; - // } - // NumberAnimation { - // property: "x"; - // easing.type: Easing.InOutQuad; - // } - // } - - // PropertyAction { - // property: "visible" - // value: false - // } - // } - // }, - Transition { to: "routeOverview" reversible: true @@ -763,17 +696,12 @@ Item { ] } -/*##^## Designer { - D{i:0;height:720;width:1280}D{i:27;anchors_height:200;anchors_width:200}D{i:26;anchors_height:200;anchors_width:200} -D{i:29;anchors_height:200;anchors_width:200}D{i:30;anchors_height:200;anchors_width:200} -D{i:31;anchors_height:200;anchors_width:200}D{i:32;anchors_height:200;anchors_width:200} -D{i:28;anchors_height:200;anchors_width:200}D{i:34;anchors_height:200;anchors_width:200} -D{i:35;anchors_height:200;anchors_width:200}D{i:33;anchors_height:200;anchors_width:200} -D{i:4;anchors_x:196}D{i:5;anchors_width:200;anchors_x:196}D{i:6;anchors_height:100;anchors_width:100} -D{i:7;anchors_height:100;anchors_width:100}D{i:8;anchors_y:109}D{i:10;anchors_height:100;anchors_width:100;anchors_y:109} -D{i:9;anchors_height:100;anchors_width:100;anchors_y:109}D{i:11;anchors_height:100;anchors_width:100;anchors_y:109} -D{i:12;anchors_y:109}D{i:15;anchors_height:100;anchors_width:100}D{i:14;anchors_height:200;anchors_width:200} -D{i:17;anchors_y:109}D{i:18;anchors_y:10}D{i:19;anchors_y:10}D{i:16;anchors_height:100;anchors_width:100;anchors_y:109} -D{i:25;anchors_height:200;anchors_width:200} + +/*##^## +Designer { + D{i:0;formeditorZoom:0.33000001311302185;height:720;width:1280}D{i:4}D{i:5}D{i:7} +D{i:6}D{i:9}D{i:8}D{i:11}D{i:10}D{i:12}D{i:14}D{i:15}D{i:16}D{i:18}D{i:17}D{i:19} +D{i:25}D{i:26}D{i:27}D{i:28}D{i:30}D{i:29}D{i:31}D{i:32}D{i:33}D{i:35}D{i:34}D{i:37} +D{i:38}D{i:39}D{i:36}D{i:41}D{i:40} } - ##^##*/ +##^##*/ diff --git a/navit/gui/qt5_qml/themes/Levy/MapControls.qml b/navit/gui/qt5_qml/themes/Levy/MapControls.qml index 04a618a80..4ed381f89 100644 --- a/navit/gui/qt5_qml/themes/Levy/MapControls.qml +++ b/navit/gui/qt5_qml/themes/Levy/MapControls.qml @@ -37,7 +37,7 @@ ColumnLayout { anchors.fill: parent Text { id: element5 - text: __root.autoZoom ? "M" : "A" + text: __root.autoZoom ? "A" : "M" font.pixelSize: parent.height * 0.4 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter @@ -68,7 +68,7 @@ ColumnLayout { id: element6 Text { id: element7 - text: __root.pitch === 0 ? "3D" : "2D" + text: __root.pitch === 0 ? "2D" : "3D" font.pixelSize: parent.height * 0.4 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter @@ -182,7 +182,7 @@ ColumnLayout { transform: Rotation{ origin.x:compassNeedle.width / 2 origin.y:compassNeedle.height / 2 - angle:__root.orientation + angle:__root.orientation + 1 } } MouseArea { diff --git a/navit/gui/qt5_qml/themes/Levy/MenuDrawer.qml b/navit/gui/qt5_qml/themes/Levy/MenuDrawer.qml index 6e1bd4d1f..1b7810b35 100644 --- a/navit/gui/qt5_qml/themes/Levy/MenuDrawer.qml +++ b/navit/gui/qt5_qml/themes/Levy/MenuDrawer.qml @@ -85,31 +85,7 @@ Item { } } - Rectangle { - id: contentRect - color: "#a4a4a4" - radius: 15 - clip: true - anchors.topMargin: parent.height * 0.02 - anchors.bottomMargin: parent.height * 0.02 - anchors.rightMargin: parent.height * 0.02 - anchors.leftMargin: parent.height * 0.02 - anchors.fill: parent - Item { - id: contentWrapper - clip: true - anchors.rightMargin: parent.radius - anchors.leftMargin: parent.radius - anchors.bottomMargin: parent.radius - anchors.topMargin: parent.radius - anchors.fill: parent - StackView { - id:menuStack - anchors.fill: parent - initialItem: menuListView - } - } - } + Component { id:menuListView @@ -263,11 +239,6 @@ Item { imageUrl: "" } ListElement { - name: "Northing" - action: "" - imageUrl: "" - } - ListElement { name: "Map follows Vehicle" action: "" imageUrl: "" @@ -334,9 +305,46 @@ Item { imageUrl: "" } } + + Rectangle { + id: rectangle + color: "#ffffff" + radius: 20 + anchors.fill: parent + } + + Rectangle { + id: contentRect + color: "#a4a4a4" + radius: 15 + clip: true + anchors.topMargin: parent.height * 0.02 + anchors.bottomMargin: parent.height * 0.02 + anchors.rightMargin: parent.height * 0.02 + anchors.leftMargin: parent.height * 0.02 + anchors.fill: parent + Item { + id: contentWrapper + clip: true + anchors.rightMargin: parent.radius + anchors.leftMargin: parent.radius + anchors.bottomMargin: parent.radius + anchors.topMargin: parent.radius + anchors.fill: parent + StackView { + id:menuStack + anchors.fill: parent + initialItem: menuListView + } + } + } } + + + + /*##^## Designer { - D{i:0;autoSize:true;height:480;width:640} + D{i:0;autoSize:true;height:480;width:640}D{i:37;anchors_height:200;anchors_width:200} } ##^##*/ diff --git a/navit/gui/qt5_qml/themes/Levy/SearchDrawerRecentsList.qml b/navit/gui/qt5_qml/themes/Levy/SearchDrawerRecentsList.qml index 2b37a0b52..d781bb661 100644 --- a/navit/gui/qt5_qml/themes/Levy/SearchDrawerRecentsList.qml +++ b/navit/gui/qt5_qml/themes/Levy/SearchDrawerRecentsList.qml @@ -16,7 +16,7 @@ ListView { delegate: Item { id: element height: 40 - width: parent.width + width: __root.width Text { y: 0 diff --git a/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml b/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml index 424c73acb..dacb273c6 100644 --- a/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml +++ b/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml @@ -31,7 +31,7 @@ Item { delegate: Item { id: element height: 80 - width: parent.width + width: listView.width Text { id: element1 |