Add weather routes project progress

This commit is contained in:
2025-04-07 19:40:38 +02:00
parent 8941d84bc8
commit fa5f6b2588
52 changed files with 2027 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import QtQuick
import QtQuick.Controls
Rectangle {
property alias logoSrc: logoImage.source
property alias placeHolderText: textInput.placeholderText
property alias text: textInput.text
Rectangle
{
id: logoRect
width: parent.width * 0.1
height: parent.height
anchors.left: parent.left
anchors.top: parent.top
anchors.verticalCenter: parent.verticalCenter
color: "transparent"
Image
{
id: logoImage
anchors.fill: parent
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
z: parent.z + 1
}
}
Rectangle
{
id: inputRect
width: parent.width * 0.9
height: parent.height
anchors.left: logoRect.right
anchors.top: parent.top
anchors.verticalCenter: parent.verticalCenter
color: "transparent"
radius: parent.radius
TextField
{
id: textInput
anchors.fill: parent
onPressed: textInput.forceActiveFocus()
background: Rectangle{
width: inputRect.width
height:inputRect.height
radius: inputRect.radius
}
}
}
}

View File

@@ -0,0 +1,97 @@
import QtQuick
import QtQuick.Controls
Rectangle {
id: root
anchors.fill: parent
border.color: "black"
border.width: 2
color: "transparent"
readonly property int radius: width * 0.025
Component.onCompleted:
{
mapView.positionSource.start()
weatherDetailsData.populate(mapView.positionSource.position.coordinate)
}
CustomInputField
{
id: inputFrom
width: parent.width - (2 * anchors.margins)
height: parent.height * 0.05
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.margins: parent.width * 0.01
anchors.topMargin: parent.width * 0.02
logoSrc: "qrc:/images/start_location.svg"
placeHolderText: "Start"
z: mapView.z + 1
radius: root.radius
}
CustomInputField
{
id: inputTo
width: parent.width - (2 * anchors.margins)
height: parent.height * 0.05
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: inputFrom.bottom
anchors.margins: parent.width * 0.01
logoSrc: "qrc:/images/Destination_location.png"
placeHolderText: "Destination"
z: mapView.z + 1
radius: root.radius
}
MapView
{
id: mapView
anchors.fill: parent
radius: root.radius
}
Button
{
id: myLocationButton
width: parent.width * 0.1
height: width
anchors.right: parent.right
anchors.bottom: weatherDetails.top
anchors.margins: parent.width * 0.01
background: Rectangle
{
anchors.fill: parent
color:"darkgray"
radius: width/2
Image
{
source: "qrc:/images/centerToGPS.png"
fillMode: Image.PreserveAspectFit
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}
onClicked:
{
mapView.resetZoomLevel()
}
z: mapView.z + 1
}
WeatherDetailsView
{
id: weatherDetails
width: parent.width
height: parent.height * 0.1
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
z: mapView.z + 1
radius: root.radius
imgSrc: weatherDetailsData.getImgSrc(weatherDetailsData.weatherStatus)
temperature: weatherDetailsData.temperature
precipitation: weatherDetailsData.precipitation
windSpeed: weatherDetailsData.windSpeed
humidity: weatherDetailsData.humidity
}
}

View File

@@ -0,0 +1,107 @@
import QtQuick
import QtLocation
import QtPositioning
Rectangle {
property alias positionSource: positionSource
property variant waypoints: mapData.waypoints
function resetZoomLevel()
{
map.zoomLevel = mapData.defaultZoomLevel
map.bearing = 0;
positionSource.start()
}
Plugin {
id: mapPlugin
name: "osm"
PluginParameter {
name: "osm.mapping.providersrepository.disabled"
value: "true"
}
PluginParameter {
name: "osm.mapping.providersrepository.address"
value: "http://maps-redirect.qt.io/osm/5.6/"
}
}
PositionSource
{
id: positionSource
updateInterval: mapData.gpsUpdateInterval
active: true
onPositionChanged: {
var coord = positionSource.position.coordinate;
map.visible = true;
map.center = positionSource.position.coordinate;
}
}
MapQuickItem {
id: marker
zoomLevel: map.zoomLevel
anchorPoint.x: image.width/2
anchorPoint.y: image.height
coordinate: positionSource.position.coordinate
sourceItem: Image {
id: image
height: 40
width: height*2/3
source: "qrc:/images/currentLocationOfWaypoint.svg"
transform: Rotation { origin.x: marker.anchorPoint.x; origin.y: marker.anchorPoint.y; angle: map.bearing}
}
Component.onCompleted: map.addMapItem(marker)
}
Map {
id: map
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(59.91, 10.75) // Oslo
zoomLevel: mapData.zoomLevel
property geoCoordinate startCentroid
PinchHandler {
id: pinch
target: null
onActiveChanged: if (active) {
map.startCentroid = map.toCoordinate(pinch.centroid.position, false)
}
onScaleChanged: (delta) => {
map.zoomLevel += Math.log2(delta)
map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
}
onRotationChanged: (delta) => {
map.bearing -= delta
map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
}
grabPermissions: PointerHandler.TakeOverForbidden
}
WheelHandler {
id: wheel
acceptedDevices: Qt.platform.pluginName === "cocoa" || Qt.platform.pluginName === "wayland"
? PointerDevice.Mouse | PointerDevice.TouchPad
: PointerDevice.Mouse
rotationScale: 1/120
property: "zoomLevel"
}
DragHandler {
id: drag
target: null
onTranslationChanged: (delta) => map.pan(-delta.x, -delta.y)
// onGrabChanged: positionSource.active = false
}
Shortcut {
enabled: map.zoomLevel < map.maximumZoomLevel
sequence: StandardKey.ZoomIn
onActivated: map.zoomLevel = Math.round(map.zoomLevel + 1)
}
Shortcut {
enabled: map.zoomLevel > map.minimumZoomLevel
sequence: StandardKey.ZoomOut
onActivated: map.zoomLevel = Math.round(map.zoomLevel - 1)
}
}
}

View File

@@ -0,0 +1,5 @@
import QtQuick 2.15
Item {
}

View File

@@ -0,0 +1,119 @@
import QtQuick
Rectangle {
id: root
property alias imgSrc: image.source
property alias temperature: tempValue.text
property alias humidity: humidityValue.text
property alias precipitation: precipValue.text
property alias windSpeed: windValue.text
property double rightMargin: root.width * 0.05
Rectangle
{
id: imageRect
width: parent.width * 0.2
height: parent.height
anchors.left: parent.left
anchors.top: parent.top
radius: 15
color: "black"
Image
{
id: image
fillMode: Image.PreserveAspectFit
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle
{
id: tempRect
width: parent.width * 0.4
height: parent.height * 0.5
anchors.left: imageRect.right
anchors.top: parent.top
Text
{
id: tempLabel
text: "Temp (C):"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
Text
{
id: tempValue
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: root.rightMargin
}
}
Rectangle
{
id: humidityRect
width: parent.width * 0.4
height: parent.height * 0.5
anchors.left: tempRect.right
anchors.top: parent.top
Text
{
id: humidityLabel
text: "Humidity (%):"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
Text
{
id: humidityValue
anchors.right: parent.right
anchors.rightMargin: root.rightMargin
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle
{
id: precipRect
width: parent.width * 0.4
height: parent.height * 0.5
anchors.left: imageRect.right
anchors.top: tempRect.bottom
Text
{
id: precipLabel
text: "Precipitation (mm)"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
Text
{
id: precipValue
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: root.rightMargin
}
}
Rectangle
{
id: windRect
width: parent.width * 0.4
height: parent.height * 0.5
anchors.left: tempRect.right
anchors.top: humidityRect.bottom
Text
{
id: windLabel
text: "Wind (km/h):"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
Text
{
id: windValue
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: root.rightMargin
}
}
}