2023-12-15 15:48:40 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
|
2024-01-26 18:31:08 +00:00
|
|
|
import QtCore
|
2023-12-15 15:48:40 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
2024-01-26 18:31:08 +00:00
|
|
|
import QtQuick.Dialogs
|
2023-12-15 15:48:40 +00:00
|
|
|
|
2024-01-22 13:02:02 +00:00
|
|
|
Item {
|
2023-12-15 15:48:40 +00:00
|
|
|
visible: true
|
|
|
|
|
2024-01-26 18:31:08 +00:00
|
|
|
LocationPermission {
|
|
|
|
id: permission
|
|
|
|
accuracy: LocationPermission.Precise
|
|
|
|
availability: LocationPermission.WhenInUse
|
|
|
|
Component.onCompleted: request();
|
|
|
|
}
|
|
|
|
|
2023-12-15 15:48:40 +00:00
|
|
|
MapView {
|
|
|
|
id: mapView
|
|
|
|
anchors.fill: parent
|
|
|
|
zoomLevel: 5
|
|
|
|
mapType: actionsLayer.mapType
|
|
|
|
lightningLayerVisible: actionsLayer.lightningLayerVisible
|
2024-01-26 18:31:08 +00:00
|
|
|
distanceLayerVisible: locationAllowed && actionsLayer.distanceLayerVisible
|
|
|
|
locationAllowed: permission.status === Qt.Granted
|
2023-12-15 15:48:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ActionsLayer {
|
|
|
|
id: actionsLayer
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 15
|
|
|
|
lightningLayerVisible: true
|
|
|
|
distanceLayerVisible: false
|
2024-01-26 18:31:08 +00:00
|
|
|
onRecenterRequested: {
|
|
|
|
switch (permission.status) {
|
|
|
|
case Qt.Granted:
|
|
|
|
mapView.recenter();
|
|
|
|
break;
|
|
|
|
case Qt.Denied:
|
|
|
|
permissionMessageDialog.open();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
permission.request();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onDistanceLayerVisibleChanged: {
|
|
|
|
if (permission.status !== Qt.Granted) {
|
|
|
|
distanceLayerVisible = false;
|
|
|
|
permissionMessageDialog.open();
|
|
|
|
}
|
|
|
|
}
|
2023-12-15 15:48:40 +00:00
|
|
|
}
|
|
|
|
|
2024-01-18 11:45:31 +00:00
|
|
|
Binding {
|
|
|
|
target: LightningController
|
|
|
|
property: "distanceTimeLayerEnabled"
|
|
|
|
value: actionsLayer.distanceLayerVisible
|
2024-01-26 18:31:08 +00:00
|
|
|
when: permission.status === Qt.Granted
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: permissionMessageDialog
|
|
|
|
buttons: MessageDialog.Ok
|
|
|
|
text: qsTr("The application does not have the permission to access the Location.")
|
|
|
|
informativeText: qsTr("Please grant the permission and restart the application.")
|
|
|
|
onButtonClicked: function(button, role) {
|
|
|
|
if (button === MessageDialog.Ok)
|
|
|
|
accept();
|
|
|
|
}
|
2024-01-18 11:45:31 +00:00
|
|
|
}
|
2023-12-15 15:48:40 +00:00
|
|
|
}
|