Skip to content

Commit

Permalink
upgrade qml 5.15 to 6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Oct 8, 2024
1 parent 1caeb77 commit 370f841
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 40 deletions.
48 changes: 31 additions & 17 deletions gui/controls2_640/MapView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ MapPage {
// configure style from setting
var flags = JSON.parse(settings.styleFlags);
if (Array.isArray(flags)) {
flags.push({ "name": "daylight", "value": !nightView });
flags.push({ "name": "daylight", "value": MapExtras.dayLight });
setStyleFlags(flags);
}

Expand All @@ -111,7 +111,6 @@ MapPage {
property double lon: 0.0
}

property bool nightView: false
property bool rotateEnabled: false
property real rotation: 0.0 // rotation of the map (radians)
property bool lockRotation: true // lock or unlock rotation of the map
Expand Down Expand Up @@ -334,7 +333,7 @@ MapPage {
ScaleIndicator{
id: scaleIndicator
pixelSize: map.pixelSize
color: "black"
color: MapExtras.dayLight ? "black" : "lightGray"
visible: !showToolbar
anchors{
bottom: parent.bottom
Expand All @@ -351,7 +350,7 @@ MapPage {
text: "© OpenStreetMap contributors"
font.pixelSize: units.fs("x-small")
font.weight: Font.Thin
color: nightView ? "white" : "black"
color: MapExtras.dayLight ? "black" : "white"
visible: !showToolbar && !navigation
}

Expand Down Expand Up @@ -483,27 +482,27 @@ MapPage {
id: currentSpeed
text: Converter.readableSpeed(Tracker.currentSpeed)
font.pixelSize: 1.5 * units.fs("x-large")
color: nightView ? "white" : "black"
color: MapExtras.dayLight ? "black" : "white"
}
Row {
spacing: units.gu(2)
Label {
id: duration
text: Converter.panelDurationHMS(Tracker.duration)
font.pixelSize: units.fs("medium")
color: nightView ? "white" : "black"
color: MapExtras.dayLight ? "black" : "white"
}
Label {
id: distance
text: Converter.panelDistance(Tracker.distance)
font.pixelSize: units.fs("medium")
color: nightView ? "white" : "black"
color: MapExtras.dayLight ? "black" : "white"
}
}
MapIcon {
id: elevation
source: "qrc:/images/trip/elevation.svg"
color: nightView ? "white" : "black"
color: MapExtras.dayLight ? "black" : "white"
enabled: false
height: units.gu(2)
borderPadding: 0
Expand Down Expand Up @@ -786,8 +785,7 @@ MapPage {
opacity: 0.7
height: units.gu(6)
onClicked: {
nightView = !nightView;
MapExtras.setDaylight(!nightView);
MapExtras.setDaylight(!MapExtras.dayLight);
}
}
}
Expand Down Expand Up @@ -929,8 +927,7 @@ MapPage {
opacity: 0.7
height: units.gu(6)
onClicked: {
nightView = !nightView;
map.toggleDaylight();
MapExtras.setDaylight(!MapExtras.dayLight);
}
}
}
Expand Down Expand Up @@ -1129,7 +1126,7 @@ MapPage {
popNavigatorInfo.visible = Qt.binding(function() { return mapView.state === "view"; });
}

onTargetReached: {
onTargetReached: function(targetDistance, targetBearing) {
popInfo.open(qsTr("Target reached at %1 %2.").arg(Converter.readableDistance(targetDistance)).arg(Converter.readableBearing(targetBearing)));
}
}
Expand Down Expand Up @@ -1165,12 +1162,29 @@ MapPage {
}
}

property QtObject suspendedState: QtObject {
property bool navigation: false
}

Connections {
target: mainView
function onApplicationSuspendedChanged() {
// On android disable navigation when the app is suspended
if (DeviceMobile && applicationSuspended && navigation)
navigation = false;
// On device mobile (e.g Android) disable all when the app is suspended
if (DeviceMobile) {
if (applicationSuspended) {
rotateEnabled = false;
map.lockToPosition = false;
// save current state
suspendedState.navigation = navigation;
// disable navigation state
if (navigation)
navigation = false;
} else {
// restore navigation state
if (suspendedState.navigation)
navigation = true;
}
}
}
function onShowFavoritesChanged() {
if (showFavorites)
Expand Down Expand Up @@ -1264,7 +1278,7 @@ MapPage {
if (Service.status === Service.ServiceConnected) {
popInfo.open(qsTr("Tracker service is connected"), "limegreen", "black");
// clear all data before ping ALL
Tracker.magneticDip = settings.magneticDip;
mainView.flipAzimuth(settings.magneticDip);
overlayManager.removeRecording();
overlayManager.removeMark(1);
overlayRecording.clear();
Expand Down
8 changes: 4 additions & 4 deletions gui/controls2_640/Settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ MapPage {
}
SpinBox {
id: magdipBox
from: -300
from: -1800
value: settings.magneticDip * 10
to: 300
to: 1800
stepSize: 10
font.pixelSize: units.fs("medium");
Layout.fillWidth: true
Expand All @@ -230,8 +230,8 @@ MapPage {
onValueModified: {
// save settings
settings.magneticDip = realValue;
// setup tracker
Tracker.magneticDip = realValue;
// reconfigure azimuth
mainView.flipAzimuth(realValue);
}
}
}
Expand Down
16 changes: 12 additions & 4 deletions gui/controls2_640/Tracking.qml
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,18 @@ PopOver {
color: styleMap.popover.highlightedColor
font.pixelSize: units.fs("medium")
}
Label {
text: Converter.readableDegreeGeocaching(180.0 * Tracker.bearing / Math.PI)
font.pixelSize: units.fs("large")
color: foregroundColor
Row {
spacing: units.gu(1)
Label {
text: Converter.readableDegree(180.0 * Tracker.bearing / Math.PI)
font.pixelSize: units.fs("large")
color: foregroundColor
}
Label {
text: "(" + Converter.readableCardinal(180.0 * Tracker.bearing / Math.PI) + ")"
font.pixelSize: units.fs("large")
color: foregroundColor
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gui/controls2_640/components/Navigator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Item {
}
}

onTargetReached: {
onTargetReached: function(targetBearing, targetDistance) {
console.log("Navigator: Target reached");
navigator.targetReached(targetDistance, targetBearing);
}
Expand Down
12 changes: 3 additions & 9 deletions gui/controls2_640/components/NavigatorInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,10 @@ Item {
id: speed
anchors.verticalCenter: parent.verticalCenter
text: Converter.readableSpeed(navigator.currentSpeed > 0 ? navigator.currentSpeed : 0.0)
color: styleMap.popover.foregroundColor
color: (navigator.maximumSpeed > 0 && navigator.maximumSpeed < (navigator.currentSpeed - 10.0)
? "red" : styleMap.popover.foregroundColor)
font.pixelSize: units.fs("x-large")
}
Label {
id: maxspeed
anchors.verticalCenter: parent.verticalCenter
text: navigator.maximumSpeed > 0 ? Converter.readableSpeed(navigator.maximumSpeed) : ""
color: styleMap.popover.highlightedColor
font.pixelSize: units.fs("medium")
}
MapIcon {
anchors.verticalCenter: parent.verticalCenter
source: {
Expand All @@ -226,7 +220,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
text: navigator.arrivalEstimate + " ~ " + Converter.panelDistance(navigator.remainingDistance)
color: styleMap.popover.foregroundColor
font.pixelSize: units.fs("medium")
font.pixelSize: units.fs("large")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gui/controls2_640/components/RouteOverview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Item {
delegate: Row {
id: row
spacing: units.gu(2)
width: parent.width
width: stepsView.width
height: Math.max(stepInfo.implicitHeight, icon.height)

WAYIcon {
Expand Down
34 changes: 30 additions & 4 deletions gui/controls2_640/osmin.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/

import QtQuick 2.9
import QtQuick.Window 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Universal 2.2
import QtQml 2.2
import Qt.labs.settings 1.0
import Qt5Compat.GraphicalEffects 6.0
import Osmin 1.0 as Osmin
Expand All @@ -35,6 +35,31 @@ ApplicationWindow {
width: 360
height: 640

property bool wideAspect: height < units.gu(64)

// the azimuth magnetic should be flipped depending on screen orientation
function flipAzimuth(dip) {
var angle = 0.0;
if (Android) { // tested only on android
switch(screen.primaryOrientation) {
case Qt.LandscapeOrientation:
angle = -90.0; break;
case Qt.InvertedLandscapeOrientation:
angle = +90.0; break;
case Qt.InvertedPortraitOrientation:
angle = 180.0; break;
case Qt.PortraitOrientation:
angle = 0.0; break;
default:
break;
}
}
console.log("flip azimuth: screen=" + angle + "deg , dip=" + dip + "deg");
Osmin.Tracker.magneticDip = dip - angle;
}

Screen.onPrimaryOrientationChanged: flipAzimuth(settings.magneticDip)

Settings {
id: settings
// General settings
Expand All @@ -50,7 +75,7 @@ ApplicationWindow {
// Navigation settings
property string systemOfUnits: "SI"
property bool hillShadesEnabled: false
property bool renderingTypeTiled: false
property bool renderingTypeTiled: true
property string lastVehicle: "car"
property int maximumRouteStep: 255
property int courseId: 0
Expand Down Expand Up @@ -120,7 +145,6 @@ ApplicationWindow {

// property to detect if the UI has finished
property bool loadedUI: false
property bool wideAspect: height < units.gu(64)

// Constants
readonly property int queueBatchSize: 100
Expand Down Expand Up @@ -327,7 +351,9 @@ ApplicationWindow {
Osmin.Converter.southwest = qsTr("southwest");
Osmin.Converter.southeast = qsTr("southeast");
Osmin.Converter.system = settings.systemOfUnits;
Osmin.Tracker.magneticDip = settings.magneticDip;

// reset magnetic dip according to the screen orientation
flipAzimuth(settings.magneticDip);

showFavorites = settings.showFavorites;
positionSource.active = true;
Expand Down

0 comments on commit 370f841

Please sign in to comment.