From 3f9b7180bb7e5ecbaa0e52817e2890bca34de9d2 Mon Sep 17 00:00:00 2001 From: janbar Date: Fri, 13 Oct 2023 19:56:18 +0200 Subject: [PATCH] purge obsolete project (qt < 5.15) --- CMakeLists.txt | 6 +- README.md | 6 +- android/AndroidManifest.xml.in.ndk18 | 72 - gui/controls2_509/Banner.qml | 39 - gui/controls2_509/ConfigureMap.qml | 257 ---- gui/controls2_509/ConfigureVoice.qml | 194 --- gui/controls2_509/DialogAbout.qml | 78 - gui/controls2_509/Favorites.qml | 379 ----- gui/controls2_509/LocationInfo.qml | 187 --- gui/controls2_509/MainMenu.qml | 196 --- gui/controls2_509/MapDownloads.qml | 393 ----- gui/controls2_509/MapView.qml | 1278 ----------------- gui/controls2_509/Routing.qml | 594 -------- gui/controls2_509/SearchPlace.qml | 699 --------- gui/controls2_509/Settings.qml | 302 ---- gui/controls2_509/TrackCollection.qml | 490 ------- gui/controls2_509/Tracking.qml | 190 --- gui/controls2_509/Welcome.qml | 88 -- .../components/ActivitySpinner.qml | 39 - .../components/CompassSensor.qml | 58 - gui/controls2_509/components/DialogAction.qml | 57 - gui/controls2_509/components/DialogAlert.qml | 40 - gui/controls2_509/components/DialogBase.qml | 113 -- gui/controls2_509/components/DialogEnter.qml | 70 - .../components/DialogMarkPosition.qml | 132 -- gui/controls2_509/components/MapCheckBox.qml | 86 -- gui/controls2_509/components/MapIcon.qml | 132 -- gui/controls2_509/components/MapListView.qml | 32 - gui/controls2_509/components/MapPage.qml | 94 -- gui/controls2_509/components/MapPosition.qml | 45 - gui/controls2_509/components/MapRotator.qml | 62 - gui/controls2_509/components/MapVoice.qml | 86 -- gui/controls2_509/components/Navigator.qml | 203 --- .../components/NavigatorInfo.qml | 304 ---- .../components/NavigatorRouting.qml | 58 - .../components/OverlayManager.qml | 142 -- gui/controls2_509/components/POIIcon.qml | 182 --- gui/controls2_509/components/PhoneLink.qml | 55 - gui/controls2_509/components/PopInfo.qml | 106 -- gui/controls2_509/components/PopOver.qml | 125 -- .../components/RouteOverview.qml | 101 -- .../components/ScaleIndicator.qml | 90 -- gui/controls2_509/components/SearchField.qml | 88 -- .../components/SimpleListItem.qml | 82 -- gui/controls2_509/components/SimpleRow.qml | 86 -- gui/controls2_509/components/StyleLight.qml | 61 - gui/controls2_509/components/Units.qml | 61 - gui/controls2_509/components/WAYIcon.qml | 97 -- gui/controls2_509/components/WebLink.qml | 63 - gui/controls2_509/osmin.qml | 496 ------- gui/controls2_509/qtquickcontrols2.conf | 8 - gui/osmin_controls2_509.qrc | 281 ---- 52 files changed, 6 insertions(+), 9177 deletions(-) delete mode 100644 android/AndroidManifest.xml.in.ndk18 delete mode 100644 gui/controls2_509/Banner.qml delete mode 100644 gui/controls2_509/ConfigureMap.qml delete mode 100644 gui/controls2_509/ConfigureVoice.qml delete mode 100644 gui/controls2_509/DialogAbout.qml delete mode 100644 gui/controls2_509/Favorites.qml delete mode 100644 gui/controls2_509/LocationInfo.qml delete mode 100644 gui/controls2_509/MainMenu.qml delete mode 100644 gui/controls2_509/MapDownloads.qml delete mode 100644 gui/controls2_509/MapView.qml delete mode 100644 gui/controls2_509/Routing.qml delete mode 100644 gui/controls2_509/SearchPlace.qml delete mode 100644 gui/controls2_509/Settings.qml delete mode 100644 gui/controls2_509/TrackCollection.qml delete mode 100644 gui/controls2_509/Tracking.qml delete mode 100644 gui/controls2_509/Welcome.qml delete mode 100644 gui/controls2_509/components/ActivitySpinner.qml delete mode 100644 gui/controls2_509/components/CompassSensor.qml delete mode 100644 gui/controls2_509/components/DialogAction.qml delete mode 100644 gui/controls2_509/components/DialogAlert.qml delete mode 100644 gui/controls2_509/components/DialogBase.qml delete mode 100644 gui/controls2_509/components/DialogEnter.qml delete mode 100644 gui/controls2_509/components/DialogMarkPosition.qml delete mode 100644 gui/controls2_509/components/MapCheckBox.qml delete mode 100644 gui/controls2_509/components/MapIcon.qml delete mode 100644 gui/controls2_509/components/MapListView.qml delete mode 100644 gui/controls2_509/components/MapPage.qml delete mode 100644 gui/controls2_509/components/MapPosition.qml delete mode 100644 gui/controls2_509/components/MapRotator.qml delete mode 100644 gui/controls2_509/components/MapVoice.qml delete mode 100644 gui/controls2_509/components/Navigator.qml delete mode 100644 gui/controls2_509/components/NavigatorInfo.qml delete mode 100644 gui/controls2_509/components/NavigatorRouting.qml delete mode 100644 gui/controls2_509/components/OverlayManager.qml delete mode 100644 gui/controls2_509/components/POIIcon.qml delete mode 100644 gui/controls2_509/components/PhoneLink.qml delete mode 100644 gui/controls2_509/components/PopInfo.qml delete mode 100644 gui/controls2_509/components/PopOver.qml delete mode 100644 gui/controls2_509/components/RouteOverview.qml delete mode 100644 gui/controls2_509/components/ScaleIndicator.qml delete mode 100644 gui/controls2_509/components/SearchField.qml delete mode 100644 gui/controls2_509/components/SimpleListItem.qml delete mode 100644 gui/controls2_509/components/SimpleRow.qml delete mode 100644 gui/controls2_509/components/StyleLight.qml delete mode 100644 gui/controls2_509/components/Units.qml delete mode 100644 gui/controls2_509/components/WAYIcon.qml delete mode 100644 gui/controls2_509/components/WebLink.qml delete mode 100644 gui/controls2_509/osmin.qml delete mode 100644 gui/controls2_509/qtquickcontrols2.conf delete mode 100644 gui/osmin_controls2_509.qrc diff --git a/CMakeLists.txt b/CMakeLists.txt index c6bf36c4..8d6f141b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ find_package(Qt5Gui REQUIRED) find_package(Qt5Qml REQUIRED) find_package(Qt5Quick REQUIRED) -set(QT_MIN_VERSION 5.12.0) +set(QT_MIN_VERSION 5.15.0) find_package(Qt5QuickControls2 ${QT_MIN_VERSION} REQUIRED) if(ANDROID) @@ -173,8 +173,8 @@ endif() add_definitions(-DAPP_VERSION="${APP_VERSION}") -if(Qt5Core_VERSION VERSION_LESS 5.15.0) - qt5_add_resources(osmin-resources gui/osmin_controls2_509.qrc) +if(Qt5Core_VERSION VERSION_LESS 5.15.2) + message(FATAL_ERROR "Qt version not supported") else() qt5_add_resources(osmin-resources gui/osmin_controls2_515.qrc) endif() diff --git a/README.md b/README.md index 33182709..51e4bf3b 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ You can install osmin through the [IzzyOnDroid](https://apt.izzysoft.de/fdroid/i Alternatively the APKs are available on the Release page, for armv7(32bits) and arm64(64bits) devices. ## Develop/debug osmin -You can build and test osmin on Unix (Linux, BSD, MacOS 10.14) supported by Qt 5.12. Before build from source you have to install the following dependencies. +You can build and test osmin on Unix (Linux, BSD, MacOS 10.14) supported by Qt 5.15. Before build from source you have to install the following dependencies. -git, cmake, clang/clang++ (**>=12.0**), OpenMP, Qt5Core (**>=5.12**), Qt5Gui, Qt5Qml, Qt5Quick, Qt5QuickControls2, Qt5Widgets, Qt5Xml, Qt5Svg, Qt5Network, Qt5Sensors, Qt5Multimedia, Qt5RemoteObjects, Qt5Positioning. +git, cmake, clang/clang++ (**>=12.0**), OpenMP, Qt5Core (**>=5.15**), Qt5Gui, Qt5Qml, Qt5Quick, Qt5QuickControls2, Qt5Widgets, Qt5Xml, Qt5Svg, Qt5Network, Qt5Sensors, Qt5Multimedia, Qt5RemoteObjects, Qt5Positioning. -As example type the following on Ubuntu (>=20.04) to install all requirements. +As example type the following on Ubuntu (>=22.04) to install all requirements. ``` sudo apt install git cmake clang curl wget libomp-dev liblzma-dev libqt5remoteobjects5-bin libqt5quickwidgets5 libqt5quickcontrols2-5 libqt5qmlmodels5 libqt5qml5 libqt5positioning5 libqt5remoteobjects5-dev libqt5svg5-dev libqt5sensors5-dev qtquickcontrols2-5-dev qtmultimedia5-dev qtpositioning5-dev qml-module-qtgraphicaleffects qml-module-qtquick2 qml-module-qtquick-layouts qml-module-qtquick-controls2 qml-module-qt-labs-settings ``` diff --git a/android/AndroidManifest.xml.in.ndk18 b/android/AndroidManifest.xml.in.ndk18 deleted file mode 100644 index fccf4bd9..00000000 --- a/android/AndroidManifest.xml.in.ndk18 +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gui/controls2_509/Banner.qml b/gui/controls2_509/Banner.qml deleted file mode 100644 index 0cedd5a6..00000000 --- a/gui/controls2_509/Banner.qml +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import Osmin 1.0 - -Page { - id: bannerPage - objectName: "bannerPage" - property string pageTitle: "Banner" - property bool isRoot: true - - InstalledMapsModel { - id: installedMaps - } - - Component.onCompleted: { - if (installedMaps.rowCount() === 0) - mainView.launcherMode = 1; // launch the welcome page - else - mainView.launcherMode = 2; // run quick startup - } -} diff --git a/gui/controls2_509/ConfigureMap.qml b/gui/controls2_509/ConfigureMap.qml deleted file mode 100644 index b2569a69..00000000 --- a/gui/controls2_509/ConfigureMap.qml +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import Osmin 1.0 -import "./components" -import "../toolbox.js" as ToolBox - -PopOver { - id: configureMap - - title: qsTr("Configure Map") - contents: Column { - spacing: units.gu(1) - - Column { - width: parent.width - MapCheckBox { - id: renderingType - width: parent.width - color: styleMap.popover.foregroundColor - text: qsTr("Tiled rendering") - checked: settings.renderingTypeTiled - onClicked: { - settings.renderingTypeTiled = !settings.renderingTypeTiled; - } - } - Label { - text: qsTr("It supports map rotating, but labels are rotated too. Rendering may be more responsive, due to tile caching in memory.") - width: parent.width - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignJustify - maximumLineCount: 4 - wrapMode: Text.Wrap - color: foregroundColor - font.pointSize: units.fs("x-small") - font.weight: Font.Normal - } - } - - Column { - width: parent.width - MapCheckBox { - id: hillShading - width: parent.width - color: styleMap.popover.foregroundColor - text: qsTr("Hill Shades") - checked: settings.hillShadesEnabled && (hillshadeProvider != null) - onClicked: { - settings.hillShadesEnabled = !settings.hillShadesEnabled; - } - enabled: (hillshadeProvider != null) - } - Label { - visible: (hillshadeProvider == null) - text: qsTr("To activate the functionality, please configure the tile server file from the resources folder.") - width: parent.width - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignJustify - maximumLineCount: 4 - wrapMode: Text.Wrap - color: foregroundColor - font.pointSize: units.fs("x-small") - font.weight: Font.Normal - } - } - - MapCheckBox { - id: seaRendering - width: parent.width - color: styleMap.popover.foregroundColor - text: qsTr("Render Sea") - checked: mapSettings.renderSea - onClicked: { - mapSettings.renderSea = !mapSettings.renderSea; - } - } - - MapCheckBox { - id: showAltLanguage - width: parent.width - color: styleMap.popover.foregroundColor - text: qsTr("Prefer English names") - checked: mapSettings.showAltLanguage - onClicked: { - mapSettings.showAltLanguage = !mapSettings.showAltLanguage; - } - } - - Label { - text: qsTr("Font name") - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("small") - } - ComboBox { - id: fontName - width: parent.width - height: units.gu(4) - flat: true - background: Rectangle { - color: styleMap.view.backgroundColor - anchors.fill: parent - } - textRole: "text" - onActivated: mapSettings.fontName = model[currentIndex].text - Component.onCompleted: currentIndex = indexOfValue(mapSettings.fontName) - model: [ - { text: qsTr("DejaVu Sans") }, - { text: qsTr("Droid Serif") }, - { text: qsTr("Liberation Sans") } - ] - function indexOfValue(val) { - if (val === "DejaVu Sans") - return 0; - if (val === "Droid Serif") - return 1; - if (val === "Liberation Sans" ) - return 2; - return 0; - } - } - - Label { - text: qsTr("Font size") - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("small") - } - ComboBox { - id: fontSize - width: parent.width - height: units.gu(4) - flat: true - background: Rectangle { - color: styleMap.view.backgroundColor - anchors.fill: parent - } - textRole: "text" - onActivated: mapSettings.fontSize = model[currentIndex].value - Component.onCompleted: currentIndex = indexOfValue(mapSettings.fontSize) - model: [ - { value: 2.0, text: qsTr("Small") }, - { value: 3.0, text: qsTr("Normal") }, - { value: 4.0, text: qsTr("Big") }, - { value: 6.0, text: qsTr("Huge") } - ] - function indexOfValue(val) { - if (val <= 2.0) - return 0; - if (val <= 3.0) - return 1; - if (val <= 4.0) - return 2; - return 3; - } - } - - Label { - text: qsTr("Style") - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("small") - } - ComboBox { - id: mapStyleSheet - width: parent.width - height: units.gu(4) - flat: true - background: Rectangle { - color: styleMap.view.backgroundColor - anchors.fill: parent - } - textRole: "text" - onActivated: { - var stylesheet = mapStyle.file(currentIndex); - mapStyle.style = stylesheet; - mapSettings.styleSheetFile = stylesheet; - settings.styleFlags = "[]"; // clear settings - // reset flags after style is loaded - ToolBox.connectWhileFalse(map.onFinishedChanged, function(){ - if (!map.finished) - return false; - flags.resetData(); - MapExtras.setDaylight(!mapView.nightView); - return true; - }); - } - MapStyleModel { id: mapStyle } - Component.onCompleted: { - var tab = [] - for (var i = 0; i < mapStyle.rowCount(); ++i) { - tab.push({ "text": mapStyle.data(mapStyle.index(i, 0), MapStyleModel.NameRole), "value": i }); - } - model = tab.slice(); - var stylesheet = mapStyle.style; - currentIndex = mapStyle.indexOf(stylesheet); - } - } - - ListModel { // list of flags available for the style - id: flags - Component.onCompleted: { - resetData(); - } - function resetData() { - clear(); - var v = MapExtras.getStyleFlags(); - for (var i = 0; i < v.length; ++i) { - if (v[i].name !== "daylight") - append({ "name": v[i].name, "value": v[i].value }); - } - } - } - - ListView { // view of available flags for the style - width: parent.width - height: contentHeight - model: flags - interactive: false - delegate: MapCheckBox { - width: parent ? parent.width : 0 - color: styleMap.popover.foregroundColor - text: model.name - checked: model.value - onClicked: { - model.value = checked; - MapExtras.setStyleFlag(model.name, checked); - saveStyleFlags(); - } - - function saveStyleFlags() { - var flags = []; - var v = MapExtras.getStyleFlags(); - for (var i = 0; i < v.length; ++i) { - if (v[i].name !== "daylight") - flags.push({"name": v[i].name, "value": v[i].value}); - } - settings.styleFlags = JSON.stringify(flags); - } - } - } - } -} diff --git a/gui/controls2_509/ConfigureVoice.qml b/gui/controls2_509/ConfigureVoice.qml deleted file mode 100644 index d80a4dd0..00000000 --- a/gui/controls2_509/ConfigureVoice.qml +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import Osmin 1.0 -import "./components" - -MapPage { - id: configureVoice - pageTitle: qsTr("Configure Voice") - pageFlickable: availableList - - AvailableVoicesModel { - id: availableVoicesModel - property string msg: "" - onLoadingChanged: { - if (!loading && fetchError.length > 0) { - msg = qsTranslate("message", message); - console.log("Download available voices failed: " + msg); - } else if (loading) { - msg = ""; - } - } - } - - InstalledVoicesModel { - id: installedVoicesModel - } - - MapListView { - id: availableList - - header: Item { - height: statusSection.height - anchors { - left: parent.left - right: parent.right - } - - Row { - id: statusSection - leftPadding: units.gu(2) - rightPadding: units.gu(2) - height: visible ? units.gu(3) : 0 - spacing: units.gu(2) - - Label { - anchors.verticalCenter: parent.verticalCenter - color: "red" - font.pointSize: units.fs("large") - text: availableVoicesModel.msg - } - - visible: (availableVoicesModel.msg.length > 0) - } - } - - contentHeight: units.gu(8) - anchors.fill: parent - - model: DelegateModel { - id: delegateModel - model: availableVoicesModel - - delegate: SimpleListItem { - id: availableVoiceItem - height: units.gu(8) - color: "transparent" - paddingLeft: units.gu(0) - alternate: ((index & 1) === 0) - - column: Column { - Row { - height: availableVoiceItem.height - spacing: units.gu(1) - - MapCheckBox { - id: selector - visible: true - enabled: (rowState === AvailableVoicesModel.Downloaded) - anchors.verticalCenter: parent.verticalCenter - width: units.gu(5) - color: styleMap.view.foregroundColor - checked: false - opacity: (enabled ? 1.0 : 0.1) - onClicked: { - if (!selector.checked) { - mapVoice.select(""); - } else { - if (mapVoice.select(model.name)) - mapVoice.testVoice(); - } - } - Component.onCompleted: { - selector.checked = (mapVoice.voiceName === model.name); - } - Connections { - target: mapVoice - onVoiceSelected: { - selector.checked = (mapVoice.voiceName === model.name); - } - } - } - - Column { - anchors.verticalCenter: parent.verticalCenter - Label { - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - font.bold: true - text: name - elide: Text.ElideRight - } - Label { - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - text: qsTranslate("resource", lang) + " , " + qsTranslate("resource", gender) - } - Label { - font.pointSize: units.fs("x-small") - color: styleMap.view.secondaryColor - text: qsTr("Author: %1").arg(author) - } - } - } - } - - Timer { - id: delayAction - interval: 2000 - onTriggered: { - var rowIndex = availableVoicesModel.index(index, 0); - if (model.state === AvailableVoicesModel.Downloaded) { - if (mapVoice.voiceName === model.name) - mapVoice.select("") - availableVoicesModel.remove(rowIndex); - rowState = AvailableVoicesModel.Available; - } else { - availableVoicesModel.download(rowIndex); - rowState = Qt.binding(function foo(){return model.state;}); - } - } - } - - //@FIXME: signal on state update failed - property int rowState: AvailableVoicesModel.Available - Component.onCompleted: { - rowState = Qt.binding(function foo(){return model.state;}); - } - - action1 { - visible: (rowState !== AvailableVoicesModel.Downloading) - source: (rowState === AvailableVoicesModel.Downloaded ? "qrc:/images/delete.svg" - : "qrc:/images/download.svg") - onClicked: { - if (delayAction.running) - delayAction.stop(); - else - delayAction.start(); - } - animationRunning: delayAction.running - animationInterval: 150 - } - - BusyIndicator { - id: loadingIndicator - running: (rowState === AvailableVoicesModel.Downloading) - height: units.gu(6) - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: units.gu(1) - visible: running - } - } - } - } -} diff --git a/gui/controls2_509/DialogAbout.qml b/gui/controls2_509/DialogAbout.qml deleted file mode 100644 index fbeba994..00000000 --- a/gui/controls2_509/DialogAbout.qml +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import Osmin 1.0 -import "./components" - -DialogBase { - id: dialog - title: qsTr("About") - - footer: Row { - leftPadding: units.gu(1) - rightPadding: units.gu(1) - bottomPadding: units.gu(1) - spacing: units.gu(1) - layoutDirection: Qt.RightToLeft - - Button { - flat: true - text: qsTr("Close") - onClicked: dialog.reject() - } - } - - contentSpacing: units.gu(2) - - Text { - color: styleMap.dialog.foregroundColor - width: dialog.availableWidth - text: qsTr("OSMin is a GPS Navigator based on a fork of OSMScout. It allows on-road routing and off-road navigation with OpenStreetMap® data.") - wrapMode: Label.Wrap - font.pointSize: units.fs("medium") - } - Text { - color: styleMap.dialog.foregroundColor - width: dialog.availableWidth - text: qsTr("Author: %1").arg("Jean-Luc Barriere") - font.pointSize: units.fs("medium") - } - Text { - color: styleMap.dialog.foregroundColor - width: dialog.availableWidth - text: qsTr("Version: %1").arg(VersionString) - font.pointSize: units.fs("medium") - } - Text { - id: donate - color: styleMap.dialog.foregroundColor - width: dialog.availableWidth - font.pointSize: units.fs("medium") - text: "Donate with Paypal" - onLinkHovered: { - if (hoveredLink) - font.bold = true; - else - font.bold = false; - } - onLinkActivated: Qt.openUrlExternally(link) - linkColor: styleMap.view.linkColor - } -} diff --git a/gui/controls2_509/Favorites.qml b/gui/controls2_509/Favorites.qml deleted file mode 100644 index c41cf018..00000000 --- a/gui/controls2_509/Favorites.qml +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import Osmin 1.0 -import "./components" -import "../toolbox.js" as ToolBox - -MapPage { - id: favoritesPage - - states: [ - State { - name: "default" - }, - State { - name: "selection" - PropertyChanges { target: favoritesPage; pageTitle: qsTr("Select a Place"); } - } - ] - - state: "default" - - pageTitle: qsTr("Favorite Places") - pageFlickable: favoritesView - - signal selectPOI(var poi) - signal showPosition(double lat, double lon) - - onPopped: { - // a slot could be connected to signal, waiting a selection - // trigger the signal for null - if (state === "selection") - selectPOI(null); - } - - MapListView { - id: favoritesView - contentHeight: contentHeight - anchors.fill: parent - anchors.bottomMargin: mapPreview.height - - model: SortFilterModel { - model: FavoritesModel - sort.property: "label" - sort.order: Qt.AscendingOrder - sortCaseSensitivity: Qt.CaseInsensitive - //filter.property: "normalized" - //filter.pattern: new RegExp(Utils.normalizedInputString(filter.displayText), "i") - //filterCaseSensitivity: Qt.CaseInsensitive - } - - delegate: SimpleListItem { - id: favoriteItem - height: units.gu(8) - color: "transparent" - alternate: ((index & 1) === 0) - - column: Column { - Row { - POIIcon { - id: poi - anchors.verticalCenter: parent.verticalCenter - poiType: type - color: styleMap.view.foregroundColor - width: units.gu(6) - height: units.gu(6) - } - Column { - anchors.verticalCenter: parent.verticalCenter - width: parent.width - poi.width - Label { - width: parent.width - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - font.bold: true - wrapMode: Text.WordWrap - maximumLineCount: 2 - text: label - } - Label { - font.pointSize: units.fs("x-small") - color: styleMap.view.secondaryColor - text: Converter.readableCoordinatesGeocaching(lat, lon) - } - } - } - } - - highlighted: (parent && parent.pressed) || index === favoritesView.currentIndex - - onPressAndHold: { - if (favoritesPage.state === "default") { - mapPage.navigateTo(lat, lon, label); - stackView.pop(); - } - } - - onClicked: { - forceActiveFocus(); - favoritesView.currentIndex = index; - selectedPOI = { "lat": lat, "lon": lon, "label": label, "type": type }; - } - - menuItems: [ - MenuItem { - visible: favoritesPage.state === "default" - height: (visible ? implicitHeight : 0) - text: qsTr("Go there") - font.pointSize: units.fs("medium") - onTriggered: { - mapPage.navigateTo(lat, lon, label); - stackView.pop(); - } - }, - MenuItem { - text: qsTr("Rename") - font.pointSize: units.fs("medium") - onTriggered: { - dialogEdit.model = model; - dialogEdit.open(); - ToolBox.connectOnce(dialogEdit.requestUpdate, updateModel); - } - function updateModel(model) { - if (model) { - createFavorite(model.lat, model.lon, model.label); - removeFavorite(model.id); - } - } - }, - MenuItem { - text: qsTr("Delete") - font.pointSize: units.fs("medium") - onTriggered: { - dialogAction.title = qsTr("Delete favorite ?"); - dialogAction.text = model.label; - dialogAction.open(); - ToolBox.connectOnce(dialogAction.reply, deleteFavorite); - } - function deleteFavorite(accepted) { - if (accepted) - removeFavorite(model.id); - } - } - ] - - menuVisible: true - } - } - - property var selectedPOI: null - - Loader { - id: mapPreview - // active the preview on selection - active: selectedPOI !== null - height: active ? parent.height / 2 : 0 - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - asynchronous: true - sourceComponent: Item { - id: preview - anchors.fill: parent - property alias map: map - Map { - id: map - showCurrentPosition: true - anchors.fill: parent - - onTap: { - // on tap change the location - preview.mark.selected = false; // not the selected location - preview.mark.lat = lat; - preview.mark.lon = lon; - preview.mark.label = Converter.readableCoordinatesGeocaching(lat, lon); - preview.mark.type = ""; - locationInfoModel.setLocation(lat, lon); - showCoordinates(lat, lon); - addPositionMark(0, lat, lon); - } - } - - property int isFavoriteMark: 0 - property QtObject mark: QtObject { - property bool selected: false // is the selected location - property double lat: 0.0 // latitude - property double lon: 0.0 // longitude - property string label: "" // label - property string type: "" // type - } - - LocationInfoModel{ - id: locationInfoModel - onReadyChange: { - if (ready && rowCount() > 0) { - var str = ""; - var mi = index(0, 0) - str = data(mi, LocationInfoModel.LabelRole); - if (str === "") - str = data(mi, LocationInfoModel.AddressRole); - if (str === "") - str = data(mi, LocationInfoModel.PoiRole); - if (str !== "") - preview.mark.label = str; - preview.mark.type = data(mi, LocationInfoModel.TypeRole); - } - } - } - - MapIcon { - id: buttonClose - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: units.gu(1) - source: "qrc:/images/close.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.5) - opacity: 0.7 - height: units.gu(6) - onClicked: { - selectedPOI = null; // deactivate the preview - } - } - MapIcon { - id: buttonAccept - anchors.top: parent.top - anchors.left: parent.left - anchors.margins: units.gu(1) - source: favoritesPage.state === "default" ? "qrc:/images/trip/navigator.svg" - : "qrc:/images/trip/pin.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - label.text: favoritesPage.state === "default" ? qsTr("Go") : qsTr("Accept") - label.font.pointSize: units.fs("medium") - label.color: "black" - height: units.gu(6) - onClicked: { - if (favoritesPage.state === "default") { - mapPage.navigateTo(preview.mark.lat, preview.mark.lon, preview.mark.label); - } else { - selectPOI({ "lat": preview.mark.lat, "lon": preview.mark.lon, "label": preview.mark.label, "type": preview.mark.type }); - } - stackView.pop(); - } - } - MapIcon { - id: buttonShowPosition - visible: favoritesPage.state === "default" - anchors.top: parent.top - anchors.left: buttonAccept.right - anchors.margins: units.gu(1) - source: "qrc:/images/trip/here.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - showPosition(preview.mark.lat, preview.mark.lon); - stackView.pop(); - } - } - } - - onStatusChanged: { - if (active && status === Loader.Ready) { - console.log("Activate map preview"); - favoritesPage.selectedPOIChanged.connect(showSelectedLocation); - showSelectedLocation(); - } else if (!active) { - console.log("Deactivate map preview"); - favoritesPage.selectedPOIChanged.disconnect(showSelectedLocation); - } - } - - function showSelectedLocation() { - console.log("Show selected location on map preview"); - item.map.showCoordinatesInstantly(selectedPOI.lat, selectedPOI.lon); - item.map.addPositionMark(0, selectedPOI.lat, selectedPOI.lon); - item.map.removeAllOverlayObjects(); - // setup mark - item.mark.selected = true; - item.mark.lat = selectedPOI.lat; - item.mark.lon = selectedPOI.lon; - item.mark.type = selectedPOI.type; - if (selectedPOI.label !== "") - item.mark.label = selectedPOI.label; - else - item.mark.label = Converter.readableCoordinatesGeocaching(selectedPOI.lat, selectedPOI.lon); - //console.log("Selected location: \"" + item.mark.label + "\", " + item.mark.type); - } - - Behavior on height { - NumberAnimation { duration: 300; easing.type: Easing.InOutQuad; - onStopped: { - console.log("Animate is stopped"); - favoritesView.positionViewAtIndex(favoritesView.currentIndex, ListView.Contain); - } - } - } - } - - DialogBase { - id: dialogEdit - title: qsTr("Rename") - - property var model: null - - signal requestUpdate(var model) - - onClosed: { - if (result === Dialog.Accepted) { - if (inputLabel.text.length > 0) { - model.label = inputLabel.text; - requestUpdate(model); - } else - requestUpdate(null); - } else { - // caller is waiting the signal - requestUpdate(null); - } - } - - footer: Row { - leftPadding: units.gu(1) - rightPadding: units.gu(1) - bottomPadding: units.gu(1) - spacing: units.gu(1) - layoutDirection: Qt.RightToLeft - - Button { - flat: true - text: qsTr("Ok") - onClicked: { - dialogEdit.accept(); - } - } - } - - TextField { - id: inputLabel - font.pointSize: units.fs("medium") - placeholderText: qsTr("Enter the label") - inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhUrlCharactersOnly - EnterKey.type: Qt.EnterKeyDone - } - - onOpened: { - result = Dialog.Rejected; - inputLabel.text = model.label; - inputLabel.forceActiveFocus(); - } - } - - DialogAction { - id: dialogAction - } -} diff --git a/gui/controls2_509/LocationInfo.qml b/gui/controls2_509/LocationInfo.qml deleted file mode 100644 index 04e34d88..00000000 --- a/gui/controls2_509/LocationInfo.qml +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import Osmin 1.0 -import "./components" - -PopOver { - id: locationInfo - title: qsTr("Informations") - - property real maximumHeight: parent.height - - property MapPosition position - - function resizeBox(contentHeight) { - height = Math.min(Math.max(minimumHeight, contentHeight + contentTopMargin + contentEdgeMargins), maximumHeight); - } - - function searchLocation(lat, lon) { - sourceValid = position._posValid; - sourceLat = position._lat; - sourceLon = position._lon; - placeLat = lat; - placeLon = lon; - placeLabel = Converter.readableCoordinatesGeocaching(lat, lon); - placeType = ""; - isFavorite = FavoritesModel.isFavorite(lat, lon); - locationInfoModel.setLocation(lat, lon); - } - - property bool sourceValid: false - property double sourceLat: 0.0 - property double sourceLon: 0.0 - property double placeLat: 0.0 - property double placeLon: 0.0 - property string placeLabel: "" - property string placeType: "" - property int isFavorite: 0 - - LocationInfoModel{ - id: locationInfoModel - onReadyChange: { - // expose the place info - if (ready && rowCount() > 0) { - var mi = index(0, 0); - placeType = data(mi, LocationInfoModel.TypeRole); - var str = data(mi, LocationInfoModel.PoiRole); - if (str.length === 0) - str = data(mi, LocationInfoModel.AddressRole); - if (str.length > 0) - placeLabel = str; - } - } - } - - contents: Column { - id: locationInfoBody - spacing: units.gu(1) - - Label { - id: locationDistanceLabel - text: locationInfoModel.distance(sourceLat, sourceLon, placeLat, placeLon) < 5 ? - qsTr("You are here") : - qsTr("%1 %2 from you") - .arg(Converter.readableDistance(locationInfoModel.distance(sourceLat, sourceLon, placeLat, placeLon))) - .arg(Converter.readableBearing(locationInfoModel.bearing(sourceLat, sourceLon, placeLat, placeLon))) - - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("small") - visible: sourceValid - } - - ListView { - id: locationInfoView - width: parent.width - height: contentHeight - interactive: false - spacing: units.gu(1) - model: locationInfoModel - - onCountChanged: { - var h = (locationDistanceLabel.visible ? locationDistanceLabel.implicitHeight : 0) + locationInfoBody.spacing + - locationInfoView.contentHeight + locationInfoView.spacing * locationInfoView.count; - resizeBox(h); - } - - opacity: locationInfoModel.ready ? 1.0 : 0.0 - Behavior on opacity { NumberAnimation {} } - - delegate: Column { - spacing: 0 - - Label { - id: entryDistanceLabel - - width: locationInfoView.width - - text: qsTr("%1 %2 from").arg(Converter.readableDistance(distance)).arg(Converter.readableBearing(bearing)) - - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("small") - visible: !inPlace - } - Row { - POIIcon { - id: poiIcon - poiType: type - color: styleMap.popover.foregroundColor - width: units.gu(6) - height: units.gu(6) - } - Column { - Label { - id: entryPoi - width: locationInfoView.width - poiIcon.width - units.gu(1) - text: poi // label - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("large") - visible: poi != "" - } - Label { - id: entryAddress - width: locationInfoView.width - poiIcon.width - units.gu(1) - text: address - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("medium") - visible: address != "" - } - Label { - id: entryRegion - width: locationInfoView.width - poiIcon.width - units.gu(1) - wrapMode: Text.WordWrap - text: { - if (region.length > 0) { - var str = region[0]; - if (postalCode != "") { - str += ", "+ postalCode; - } - if (region.length > 1) { - for (var i = 1; i < region.length; ++i){ - str += ", "+ region[i]; - } - } - return str; - } else if (postalCode != ""){ - return postalCode; - } - } - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("medium") - visible: region.length > 0 || postalCode != "" - } - PhoneLink { - id: phoneLink - phone: model.phone - foregroundColor: styleMap.popover.foregroundColor - highlightedColor: styleMap.popover.highlightedColor - } - WebLink { - id: webLink - url: model.website - foregroundColor: styleMap.popover.foregroundColor - highlightedColor: styleMap.popover.highlightedColor - } - } - } - } - } - } -} diff --git a/gui/controls2_509/MainMenu.qml b/gui/controls2_509/MainMenu.qml deleted file mode 100644 index 2896b00a..00000000 --- a/gui/controls2_509/MainMenu.qml +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2020-2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import "./components" -import "../toolbox.js" as ToolBox - -PopOver { - id: mainMenu - title: qsTr("Main Menu") - contentEdgeMargins: 0 - - ListModel { - id: listmodel - ListElement { - art: "qrc:/images/trip/favourite.svg" - name: qsTr("My Places") - comment: qsTr("Manage your favorite places.") - foo: function() { - var page = stackView.push("qrc:/controls2/Favorites.qml"); - ToolBox.connectOnce(page.showPosition, function(lat, lon){ - if (lat !== NaN && lon !== NaN) { - map.showCoordinatesInstantly(lat, lon); - mark.lat = lat; - mark.lon = lon; - mark.screenX = map.width / 2; - mark.screenY = map.height / 2; - if (navigation) - navigation = false; - popLocationInfo.show(); } - }); - } - } - ListElement { - art: "qrc:/images/trip/route.svg" - name: qsTr("Routes") - comment: qsTr("Navigate to a destination.") - foo: function() { - popRouting.show(); - } - } - ListElement { - art: "qrc:/images/trip/track.svg" - name: qsTr("Tracks") - comment: qsTr("Manage the collection of saved tracks.") - foo: function() { - var page = stackView.push("qrc:/controls2/TrackCollection.qml", { "mapView": mapView }); - ToolBox.connectOnce(page.showPosition, function(lat, lon){ - if (lat !== NaN && lon !== NaN) { - map.showCoordinatesInstantly(lat, lon); - mark.lat = lat; - mark.lon = lon; - mark.screenX = map.width / 2; - mark.screenY = map.height / 2; - if (navigation) - navigation = false; - popLocationInfo.show(); } - }); - } - } - ListElement { - art: "qrc:/images/trip/navigation.svg" - name: qsTr("Tracking") - comment: qsTr("Statistics of the current track.") - foo: function() { - popTracking.show(); - } - } - ListElement { - art: "qrc:/images/map.svg" - name: qsTr("Configure Map") - comment: qsTr("Rendering and style of the map view.") - foo: function() { - popConfigureMap.show(); - } - } - ListElement { - art: "qrc:/images/download.svg" - name: qsTr("Download Maps") - comment: qsTr("Manage the map database.") - foo: function() { - var page = stackView.push("qrc:/controls2/MapDownloads.qml"); - } - } - ListElement { - art: "qrc:/images/voice.svg" - name: qsTr("Configure Voice") - comment: qsTr("Choose a voice for driving directions.") - foo: function() { - var page = stackView.push("qrc:/controls2/ConfigureVoice.qml"); - } - } -// ListElement { -// art: "qrc:/images/trip/measuring.svg" -// name: qsTr("Measure distance") -// comment: qsTr("") -// foo: function() { -// } -// } - ListElement { - art: "qrc:/images/cogs.svg" - name: qsTr("Settings") - comment: qsTr("General settings, units system and more ...") - foo: function() { - var page = stackView.push("qrc:/controls2/Settings.qml"); - } - } -// ListElement { -// art: "qrc:/images/help.svg" -// name: qsTr("Help") -// comment: qsTr("More about features and usage.") -// foo: function() { -// } -// } - } - - contents: Column { - Repeater { - model: listmodel - delegate: SimpleListItem { - id: listitem - height: units.gu(8) - color: "transparent" - paddingLeft: units.gu(0) - highlighted: pressed - - column: Column { - Row { - height: listitem.height - spacing: units.gu(1) - - MapIcon { - id: icon - visible: true - enabled: false - anchors.verticalCenter: parent.verticalCenter - width: units.gu(8) - iconSize: units.gu(5) - color: styleMap.view.foregroundColor - source: art - } - - Column { - width: parent.width - icon.width - units.gu(1) - anchors.verticalCenter: parent.verticalCenter - Label { - width: parent.width - units.gu(1) - color: styleMap.view.primaryColor - font.pointSize: units.fs("large") - font.bold: false - text: name - elide: Text.ElideRight - } -// Label { -// width: parent.width - units.gu(1) -// color: styleMap.view.secondaryColor -// font.pointSize: units.fs("small") -// verticalAlignment: Text.AlignVCenter -// horizontalAlignment: Text.AlignLeft -// maximumLineCount: 2 -// wrapMode: Text.Wrap -// text: comment -// } - } - } - } - - onPressAndHold: { - popInfo.open(comment, mainMenu.foregroundColor, mainMenu.backgroundColor) - } - - onClicked: { - mainMenu.close(); - model.foo(); - } - } - } - } -} diff --git a/gui/controls2_509/MapDownloads.qml b/gui/controls2_509/MapDownloads.qml deleted file mode 100644 index f4bb0fda..00000000 --- a/gui/controls2_509/MapDownloads.qml +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import Osmin 1.0 -import "./components" - -MapPage { - id: mapDownload - pageTitle: qsTr("Map Downloads") - pageFlickable: availableList - - MapDownloadsModel { - id:mapDownloadsModel - property string msg: "" - onMapDownloadFails: { - var msg = qsTranslate("message", message); - console.log("Map download failed: " + msg); - } - property string preferedDirectory: "" - Component.onCompleted: { - var dirs = mapDownloadsModel.getLookupDirectories(); - if (dirs.length > 1) - preferedDirectory = dirs[1]; // external storage - else - preferedDirectory = dirs[0]; // home maps store - } - } - - AvailableMapsModel { - id: availableMapsModel - } - - InstalledMapsModel { - id: installedMapsModel - } - - MapListView { - id: availableList - - header: Item { - height: downloadSection.height + downloadList.height + - installedSection.height + installedList.height + - availableSection.height - anchors { - left: parent.left - right: parent.right - } - - Row { - id: downloadSection - leftPadding: units.gu(2) - rightPadding: units.gu(2) - height: visible ? units.gu(5) : 0 - spacing: units.gu(2) - - Text { - anchors.verticalCenter: parent.verticalCenter - color: styleMap.view.highlightedColor - text: qsTr("Downloads") - font.pointSize: units.fs("x-large") - } - } - - MapListView { - id: downloadList - anchors.top: downloadSection.bottom - height: contentHeight - width: parent.width - interactive: false - model: mapDownloadsModel - - delegate: SimpleListItem { - id: donwloadMapItem - height: units.gu(6) - color: "transparent" - paddingLeft: units.gu(2) - alternate: ((index & 1) === 0) - - column: Column { - Row { - spacing: units.gu(2) - Label { - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - text: mapName - } - Label { - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - text: (Math.round(progressRole * 1000) / 10).toFixed(1) + " %"; - } - } - Label { - color: styleMap.view.secondaryColor - font.pointSize: units.fs("x-small") - text: errorString.length > 0 ? qsTranslate("message", errorString) : progressDescription - elide: Text.ElideRight - } - } - - Timer { - id: delayCancel - interval: 5000 - onTriggered: { - mapDownloadsModel.cancel(model.index); - } - } - action1 { - visible: true - source: "qrc:/images/close.svg" - onClicked: { - if (delayCancel.running) - delayCancel.stop(); - else - delayCancel.start(); - } - animationRunning: delayCancel.running - animationInterval: 200 - } - } - - function onModelReset() { - console.log("mapDownloadsModel rows: " + mapDownloadsModel.rowCount()); - downloadSection.visible = mapDownloadsModel.rowCount() > 0; - } - - Component.onCompleted: { - mapDownloadsModel.modelReset.connect(onModelReset); - onModelReset(); - } - } - - Row { - id: installedSection - leftPadding: units.gu(2) - rightPadding: units.gu(2) - anchors.top: downloadList.bottom - height: visible ? units.gu(5) : 0 - spacing: units.gu(2) - - Text { - anchors.verticalCenter: parent.verticalCenter - color: styleMap.view.highlightedColor - text: qsTr("Installed Maps") - font.pointSize: units.fs("x-large") - } - } - - MapListView { - id: installedList - anchors.top: installedSection.bottom - height: contentHeight - width: parent.width - interactive: false - model: installedMapsModel - - delegate: SimpleListItem { - id: installedMapItem - height: units.gu(6) - color: "transparent" - paddingLeft: units.gu(2) - alternate: ((index & 1) === 0) - - column: Column { - Label { - width: parent.width - (updateAvailable ? units.gu(12) : units.gu(6)) - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - text: name - elide: Text.ElideRight - } - Label{ - font.pointSize: units.fs("x-small") - color: styleMap.view.secondaryColor - text: time.toLocaleDateString(Locale.ShortFormat) - visible: time != null - } - } - - Timer { - id: delayDelete - interval: 5000 - onTriggered: { - installedMapsModel.deleteMap(model.index); - } - } - action1 { - visible: true - source: "qrc:/images/delete.svg" - onClicked: { - if (delayDelete.running) - delayDelete.stop(); - else - delayDelete.start(); - } - animationRunning: delayDelete.running - animationInterval: 200 - } - - Timer { - id: delayUpdate - interval: 2000 - onTriggered: { - updateMap(); - availableList.positionViewAtBeginning(); - } - } - action2 { - visible: updateAvailable - source: "qrc:/images/download.svg" - onClicked: { - if (delayUpdate.running) - delayUpdate.stop(); - else - delayUpdate.start(); - } - animationRunning: delayUpdate.running - animationInterval: 150 - } - - property bool updateAvailable: false - - function updateMap() { - var map = availableMapsModel.mapByPath(path); - if (map) { - var baseDir = directory.substring(0, directory.lastIndexOf("/")); - var dir = mapDownloadsModel.suggestedDirectory(map, baseDir); - mapDownloadsModel.downloadMap(map, dir); - console.log("Downloading to " + dir); - } - } - - function checkUpdate() { - console.log("checking updates for map " + name + " (" + path + ")"); - if (path.length > 0) { - var latestReleaseTime = availableMapsModel.timeOfMap(path); - console.log("map time: " + time + " latestReleaseTime: " + latestReleaseTime +" (" + typeof(latestReleaseTime) + ")"); - updateAvailable = latestReleaseTime !== null && latestReleaseTime > time; - } else { - updateAvailable = false; - } - } - - Component.onCompleted: { - checkUpdate(); - availableMapsModel.modelReset.connect(checkUpdate); - availableMapsModel.loadingChanged.connect(checkUpdate); - } - } - - function onModelChange() { - console.log("installedMapsModel rows: " + installedMapsModel.rowCount()); - installedSection.visible = installedMapsModel.rowCount() > 0; - } - - Component.onCompleted: { - installedMapsModel.modelReset.connect(onModelChange); - installedMapsModel.databaseListChanged.connect(onModelChange); - onModelChange(); - } - } - - Row { - id: availableSection - leftPadding: units.gu(2) - rightPadding: units.gu(2) - anchors.top: installedList.bottom - height: units.gu(5) - spacing: units.gu(2) - - Text { - anchors.verticalCenter: parent.verticalCenter - color: styleMap.view.highlightedColor - text: availableList.tree.length > 0 ? availableList.tree[0].name : qsTr("Available Maps") - font.pointSize: units.fs("x-large") - } - - MapIcon { - anchors.verticalCenter: parent.verticalCenter - height: units.gu(5) - source: "qrc:/images/go-previous.svg" - label.text: qsTr("Back") - label.font.pointSize: units.fs("small") - visible: availableList.tree.length > 0 - onClicked: { - availableList.tree = availableList.tree.slice(1, availableList.tree.length); - } - } - - BusyIndicator { - id: loadingIndicator - running: availableMapsModel.loading - height: units.gu(5) - anchors.verticalCenter: parent.verticalCenter - visible: running - } - } - } - - contentHeight: units.gu(6) - anchors.fill: parent - - property var tree: [] - - model: DelegateModel { - id: delegateModel - model: availableMapsModel - rootIndex : availableList.tree.length > 0 ? availableList.tree[0].index : null - - delegate: SimpleListItem { - id: availableMapItem - height: units.gu(6) - color: "transparent" - paddingLeft: units.gu(2) - alternate: ((index & 1) === 0) - - column: Column { - Label { - width: parent.width - units.gu(6) - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - font.bold: dir - text: name - elide: Text.ElideRight - } - Label { - font.pointSize: units.fs("x-small") - color: styleMap.view.secondaryColor - text: { dir ? null : time.toLocaleDateString(Locale.ShortFormat) + ", " + size } - visible: !dir - } - } - - Timer { - id: delayDownload - interval: 2000 - onTriggered: { - var map = availableMapsModel.map(availableMapsModel.index(model.index, 0, delegateModel.rootIndex)); - if (map) { - var dir = mapDownloadsModel.suggestedDirectory(map, mapDownloadsModel.preferedDirectory); - mapDownloadsModel.downloadMap(map, dir); - availableList.positionViewAtBeginning(); - } - } - } - action1 { - visible: !model.dir - source: "qrc:/images/download.svg" - onClicked: { - if (delayDownload.running) - delayDownload.stop(); - else - delayDownload.start(); - } - animationRunning: delayDownload.running - animationInterval: 150 - } - - //highlighted: model.dir && pressed - - onClicked: { - if (model.dir) { - var v = availableList.tree.slice(); - if (availableList.tree.length > 0) { - v.splice(0, 0, { "index": availableMapsModel.index(model.index, 0, availableList.tree[0].index), "name": model.name }); - } else { - v.splice(0, 0, { "index": availableMapsModel.index(model.index, 0), "name": model.name }); - } - availableList.tree = v; - } - } - } - } - } -} diff --git a/gui/controls2_509/MapView.qml b/gui/controls2_509/MapView.qml deleted file mode 100644 index 8dfcfccc..00000000 --- a/gui/controls2_509/MapView.qml +++ /dev/null @@ -1,1278 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQml 2.2 -import Osmin 1.0 -import "./components" -import "../toolbox.js" as ToolBox - -MapPage { - id: mapView - pageTitle: qsTr("Map View") - showHeader: false // hide the header bar - - //////////////////////////////////////////////////////////////////////////// - //// - //// Global functions - //// - - function navigateTo(lat, lon ,label) { - popRouting.goTo(lat, lon, label); - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Map - //// - - property real widgetBottomY: (map.height / 2) * 1.05 // the map view should be visible below - - property bool preventBlanking: navigation && !applicationSuspended - onPreventBlankingChanged: { - if (PlatformExtras.preventBlanking !== preventBlanking) { - PlatformExtras.preventBlanking = preventBlanking; - console.log("PreventBlanking: " + preventBlanking); - } - } - - function showPositionInfo() { - if (positionSource._posValid) { - popInfo.open(qsTr("Current position is %1").arg(Converter.readableCoordinatesGeocaching(positionSource._lat, positionSource._lon))); - } else { - popInfo.open(qsTr("Current position cannot be gathered")); - } - } - - function setStyleFlags(flags) { - // flags: [{name,value}, ...] - if (flags.length > 0) { - var styleFlags = MapExtras.getStyleFlags(); - for (var i = 0; i < flags.length; ++i) { - for (var j = 0; j < styleFlags.length; ++j) { - if (styleFlags[j].name === flags[i].name) { - console.log("set style flag '" + flags[i].name + "' to " + flags[i].value); - styleFlags[j].value = flags[i].value; - } - } - } - console.log("reload customized style"); - MapExtras.reloadStyle(styleFlags); - } - } - - Component.onCompleted: { - // Syncing all data from the tracker - Service.ping("ALL"); - // show current coordinates - ToolBox.connectOnce(positionSource.dataUpdated, function(){ - if (positionSource._posValid) { - map.showCoordinatesInstantly(positionSource._lat, positionSource._lon); - } - showPositionInfo(); - }); - // load current course or clean - if (settings.courseId > 0) { - if (!loadGPX(settings.courseId)) { - settings.courseId = 0; - } - } - // on azimuth changed - compass.polled.connect(function(azimuth, rotation){ mapView.azimuth = azimuth; }); - - // configure style from setting - var flags = JSON.parse(settings.styleFlags); - if (Array.isArray(flags)) { - flags.push({ "name": "daylight", "value": !nightView }); - setStyleFlags(flags); - } - } - - property QtObject mark: QtObject { - property bool showOverlay: true - property real screenX: 0.0 - property real screenY: 0.0 - property double lat: 0.0 - 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 - property real azimuth: 0.0 // the current azimuth (degrees) - - onRotationChanged: { - if (lockRotation) - rotator.rotateTo(rotation, map.lockToPosition); - } - onLockRotationChanged: { - if (lockRotation) - rotator.rotateTo(rotation, map.lockToPosition); - else - rotator.stop(); - } - - Map { - id: map - anchors.fill: parent - - // by default use plane unless tiled is forced - renderingType: ((mapView.rotateEnabled || mapView.navigation) && settings.renderingTypeTiled ? "tiled" : "plane") - - followVehicle: mapView.navigation - vehiclePosition: mapView.navigation && navigator.ready ? navigator.vehiclePosition : Tracker.trackerPosition - vehicleIconSize: 10 - showCurrentPosition: true - interactiveIcons: true - - TiledMapOverlay { - id: mapOverlay - anchors.fill: parent - view: map.view - enabled: settings.hillShadesEnabled && hillshadeProvider - opacity: 0.6 - provider: hillshadeProvider - } - - onTap: { - mark.screenX = screenX; - mark.screenY = screenY; - mark.lat = lat; - mark.lon = lon; - switch (mapView.state) { - case "view": - if (!edgeToolbar.visible) - mapView.showToolbar = true; - break; - case "locationInfo": - // check icon tapped previously - if (popLocationInfo.visible && !mark.showOverlay) - popLocationInfo.close(); - else - popLocationInfo.show(); - break; - case "routing": - popRouting.placePicked(true, lat, lon); - break; - default: - break; - } - } - - onLongTap: { - mark.showOverlay = true; - mark.screenX = screenX; - mark.screenY = screenY; - mark.lat = lat; - mark.lon = lon; - switch (mapView.state) { - case "view": - popLocationInfo.show(); - break; - default: - break; - } - } - - onIconTapped: { - mark.showOverlay = false; - mark.screenX = screenCoord.x; - mark.screenY = screenCoord.y; - mark.lat = lat; - mark.lon = lon; - switch (mapView.state) { - case "view": - popLocationInfo.show(); - break; - default: - break; - } - } - - Component.onCompleted: { - map.setVehicleScaleFactor(0.1); // hide vehicle - positionSource.dataUpdated.connect(function(valid, lat, lon, accValid, acc, alt){ - locationChanged(valid, lat, lon, accValid, acc); - }); - ToolBox.connectWhileFalse(map.finishedChanged, function(finished){ - if (finished) { - console.log("Configure after finished map"); - //rotateEnabled = true; - positionSource.active = true; - } - }); - } - } - - states: [ - State { - name: "view" - }, - State { - name: "locationInfo" - PropertyChanges { target: searchAroundPlace; visible: true; } - PropertyChanges { target: addFavorite; visible: true; } - PropertyChanges { target: goThere; visible: true; } - }, - State { - name: "pickLocation" - }, - State { - name: "measureDistance" - }, - State { - name: "routing" - } - ] - state: "view" - property var stateStack: [ "view" ] - - function pushState(state) { - var tmp = []; - for (var i = 0; i < stateStack.length; ++i) { - if (i === 0 || stateStack[i] !== state) - tmp.push(stateStack[i]); - } - tmp.push(state); - stateStack = tmp; - mapView.state = state; - console.log("mapView.state: " + mapView.state); - } - function popState(state) { - var tmp = []; - for (var i = 0; i < stateStack.length; ++i) { - if (i === 0 || stateStack[i] !== state) - tmp.push(stateStack[i]); - } - stateStack = tmp; - mapView.state = tmp[tmp.length - 1]; - console.log("mapView.state: " + mapView.state); - } - - // property to enable/disable the navigation mode - property bool navigation: false - - onNavigationChanged: { - if (navigation) { - // unlock rotation and disable rotate - lockRotation = false; - rotateEnabled = false; - // activate azimuth - compass.active = !applicationSuspended; - // show vehicle icon - map.setVehicleScaleFactor(1.0); - } else { - // hide vehicle icon - map.setVehicleScaleFactor(0.1); - // deactivate azimuth - compass.active = false; - // lock rotation - mapView.rotation = 0.0; - lockRotation = true; - } - } - - property int positionState: !positionSource._posValid ? 0 : (!navigation ? 1 : 2) - - function positionColor(val) { - switch(val) { - case 0: return "transparent"; - case 1: return "limegreen" - case 2: return "deepskyblue" - default: return "lightgrey" - } - } - - // button for location - MapIcon { - id: buttonLocation - anchors{ - bottom: parent.bottom - right: parent.right - bottomMargin: units.gu(1) - rightMargin: units.gu(1) - } - source: "qrc:/images/trip/location.svg" - backgroundColor: positionColor(positionState) - color: positionState === 0 ? "red" : "black" - borderPadding: units.gu(0) - opacity: 0.9 - height: units.gu(6) - animationRunning: (positionState === 0) - onClicked: { - switch(positionState) { - case 0: - // try to activate the source provided by service - Service.positionActive = true; - break; - case 1: - // enable navigation - navigation = true; - break; - case 2: - // disable navigation - navigation = false; - break; - default: - break; - } - } - } - - ScaleIndicator{ - id: scaleIndicator - pixelSize: map.pixelSize - color: "black" - visible: !showToolbar - anchors{ - bottom: parent.bottom - right: buttonLocation.left - bottomMargin: units.gu(1) - rightMargin: units.gu(1) - } - } - - Label { - id: copyright - anchors.bottom: parent.bottom - anchors.left: parent.left - text: "© OpenStreetMap contributors" - font.pointSize: units.fs("x-small") - font.weight: Font.Thin - color: nightView ? "white" : "black" - visible: !showToolbar && !navigation - } - - MapIcon { - id: trackRecording - anchors{ - bottom: parent.bottom - left: parent.left - bottomMargin: units.gu(1) - leftMargin: units.gu(1) - } - source: "qrc:/images/record.svg" - backgroundColor: "white" - color: Tracker.isRecording ? "red" : "black" - animationRunning: Tracker.isRecording && !navigation - visible: mapView.state === "view" && !showToolbar && (navigation || Tracker.isRecording) - borderPadding: units.gu(0.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - if (Tracker.isRecording) - Tracker.stopRecording(); - else - Tracker.startRecording(); - } - } - - MapIcon { - id: trackMarkPosition - anchors{ - bottom: parent.bottom - left: trackRecording.right - bottomMargin: units.gu(1) - leftMargin: units.gu(1) - } - source: "qrc:/images/trip/marker.svg" - color: "black" - backgroundColor: "white" - visible: mapView.state === "view" && !showToolbar && Tracker.isRecording - borderPadding: units.gu(1.0) - label.text: qsTr("Mark") - label.font.pointSize: units.fs("medium") - label.color: "black" - opacity: 0.7 - height: units.gu(6) - onClicked: { - Tracker.pinPosition(); // pin the current position - var name = "[" + Converter.panelDistance(Tracker.distance) + "]"; - dialogMarkPosition.model = { "name": name }; - dialogMarkPosition.open(); - ToolBox.connectOnce(dialogMarkPosition.reply, function(model){ - if (model !== null) { - Tracker.markPosition(model.symbol, model.name, ""); - } - }); - } - } - - DialogMarkPosition { - id: dialogMarkPosition - } - - // button for zoom out - MapIcon { - id: buttonZoomOut - anchors{ - bottom: buttonLocation.top - right: parent.right - bottomMargin: units.gu(1) - rightMargin: units.gu(1) - } - source: "qrc:/images/zoomout.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.5) - opacity: 0.7 - height: units.gu(6) - onClicked: map.zoomOut(1.732) - } - - MapIcon { - id: buttonZoomIn - anchors{ - bottom: buttonZoomOut.top - right: parent.right - bottomMargin: units.gu(1) - rightMargin: units.gu(1) - } - source: "qrc:/images/zoomin.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.5) - opacity: 0.7 - height: units.gu(6) - onClicked: map.zoomIn(1.732) - } - - MapIcon { - id: buttonRotate - anchors{ - top: parent.top - right: parent.right - topMargin: units.gu(1) - rightMargin: units.gu(1) - } - source: "qrc:/images/compass.svg" - color: rotateEnabled ? "white" : "black" - backgroundColor: rotateEnabled ? "black" : "white" - borderPadding: 0 - opacity: rotateEnabled || navigation ? 0.9 : 0.7 - height: units.gu(6) - onClicked: rotateEnabled = !rotateEnabled - rotation: navigation ? (360 - mapView.azimuth) : (mapView.rotation * 180.0 / Math.PI) - visible: !popNavigatorInfo.visible - enabled: !navigation - } - - Item { - visible: navigation && !popNavigatorInfo.visible - opacity: 0.9 - anchors{ - top: parent.top - left: parent.left - topMargin: units.gu(1) - leftMargin: units.gu(1) - } - Column { - Label { - id: currentSpeed - text: Converter.readableSpeed(Tracker.currentSpeed) - font.pointSize: 1.5 * units.fs("x-large") - color: nightView ? "white" : "black" - } - Row { - spacing: units.gu(2) - Label { - id: duration - text: Converter.panelDurationHMS(Tracker.duration) - font.pointSize: units.fs("medium") - color: nightView ? "white" : "black" - } - Label { - id: distance - text: Converter.panelDistance(Tracker.distance) - font.pointSize: units.fs("medium") - color: nightView ? "white" : "black" - } - } - MapIcon { - id: elevation - source: "qrc:/images/trip/elevation.svg" - color: nightView ? "white" : "black" - enabled: false - height: units.gu(2) - borderPadding: 0 - label.font.pointSize: units.fs("medium") - label.text: Converter.panelElevation(Tracker.elevation) - } - } - } - - OverlayManager { - id: overlayManager - map: map - } - - // Go there. The button is visible in state 'locationInfo' - MapIcon { - id: goThere - visible: false - z: 1 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.margins: units.gu(1) - source: "qrc:/images/trip/navigator.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - label.text: qsTr("Go") - label.font.pointSize: units.fs("medium") - label.color: "black" - onClicked: { - navigateTo(popLocationInfo.placeLat, - popLocationInfo.placeLon, - popLocationInfo.placeLabel); - popLocationInfo.close(); - } - } - // Add/Remove a favorite place. The button is visible in state 'locationInfo' - MapIcon { - id: addFavorite - visible: false - z: 1 - anchors.bottom: parent.bottom - anchors.left: goThere.right - anchors.margins: units.gu(1) - source: "qrc:/images/trip/favourite.svg" - color: popLocationInfo.isFavorite > 0 ? "deepskyblue" : "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - if (popLocationInfo.isFavorite === 0) { - dialogEnter.title = qsTr("Add favorite"); - dialogEnter.userEntry = popLocationInfo.placeLabel; - dialogEnter.open(); - ToolBox.connectOnce(dialogEnter.reply, function(accepted, entry){ - if (accepted) { - var label = entry.trim(); - popLocationInfo.isFavorite = createFavorite(popLocationInfo.placeLat, - popLocationInfo.placeLon, - (label.length > 0 ? label : popLocationInfo.placeLabel), - popLocationInfo.placeType); - } - }); - } else { - var favorite = FavoritesModel.getById(popLocationInfo.isFavorite); - dialogAction.title = qsTr("Delete favorite ?"); - dialogAction.text = favorite.label; - dialogAction.open(); - ToolBox.connectOnce(dialogAction.reply, function(accepted){ - if (accepted && removeFavorite(popLocationInfo.isFavorite)) - popLocationInfo.isFavorite = 0; - }); - } - } - } - // Search around place. The button is visible in state 'locationInfo' - MapIcon { - id: searchAroundPlace - visible: false - z: 1 - anchors.bottom: parent.bottom - anchors.left: addFavorite.right - anchors.margins: units.gu(1) - source: "qrc:/images/trip/search.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - var page = stackView.push("qrc:/controls2/SearchPlace.qml", { - "searchCenterLat": popLocationInfo.placeLat, - "searchCenterLon": popLocationInfo.placeLon, - "acceptLabel": qsTr("Go"), - "acceptIcon" : "qrc:/images/trip/navigator.svg", - "showPositionEnabled": true - }); - ToolBox.connectOnce(page.selectLocation, function(location, lat, lon, label){ - if (lat !== NaN && lon !== NaN && label !== "") { - popRouting.goTo(lat, lon, label); - } - }); - ToolBox.connectOnce(page.showPosition, function(lat, lon){ - if (lat !== NaN && lon !== NaN) { - map.showCoordinatesInstantly(lat, lon); - mark.showOverlay = true; - mark.lat = lat; - mark.lon = lon; - mark.screenX = map.width / 2; - mark.screenY = map.height / 2; - if (navigation) - navigation = false; - popLocationInfo.show(); - } - }); - } - } - - - //////////////////////////////////////////////////////////////////////////// - //// - //// Toolbar - //// - - property bool showToolbar: false - - onShowToolbarChanged: { - if (showToolbar && !hideFooter.running) { - hideFooter.start(); - } - } - - Timer { - id: hideFooter - interval: 5000 - onTriggered: { - showToolbar = false; - } - } - - Item { - id: footerToolbar - height: units.gu(8) - anchors.bottom: parent.bottom - anchors.bottomMargin: showToolbar && !edgeToolbar.visible ? 0 : - height - anchors.left: parent.left - anchors.right: parent.right - z: 99 - - Behavior on anchors.bottomMargin { - NumberAnimation { duration: 300; easing.type: Easing.OutBack; } - } - - Rectangle { - id: horizontalToolBar - anchors.fill: parent - color: "transparent" - opacity: mapView.state === "view" ? 1.0 : 0.0 - enabled: opacity > 0 - - Rectangle { - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: units.gu(1) - anchors.rightMargin: units.gu(1) - height: units.gu(8) - color: "transparent" - - Row { - anchors.verticalCenter: parent.verticalCenter - spacing: units.gu(1) - - MapIcon { - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/navigation-menu.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.5) - opacity: 0.7 - height: units.gu(6) - onClicked: { - popMainMenu.show(); - } - } - - MapIcon { - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/trip/here.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - if (!lockRotation) { - map.lockToPosition = true; - } else if(positionSource._posValid) { - map.showCoordinatesInstantly(positionSource._lat, positionSource._lon); - showPositionInfo(); - } else { - showPositionInfo(); - } - } - } - - MapIcon { - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/trip/pin.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - var page = stackView.push("qrc:/controls2/Favorites.qml"); - ToolBox.connectOnce(page.showPosition, function(lat, lon){ - if (lat !== NaN && lon !== NaN) { - map.showCoordinatesInstantly(lat, lon); - mark.showOverlay = true; - mark.lat = lat; - mark.lon = lon; - mark.screenX = map.width / 2; - mark.screenY = map.height / 2; - if (navigation) - navigation = false; - popLocationInfo.show(); } - }); - } - } - - MapIcon { - visible: true - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/trip/search.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - var page = stackView.push("qrc:/controls2/SearchPlace.qml", { - "searchCenterLat": positionSource._lat, - "searchCenterLon": positionSource._lon, - "acceptLabel": qsTr("Go"), - "acceptIcon" : "qrc:/images/trip/navigator.svg", - "showPositionEnabled": true - }); - ToolBox.connectOnce(page.selectLocation, function(location, lat, lon, label){ - if (lat !== NaN && lon !== NaN && label !== "") { - popRouting.goTo(lat, lon, label); - } - }); - ToolBox.connectOnce(page.showPosition, function(lat, lon){ - if (lat !== NaN && lon !== NaN) { - map.showCoordinatesInstantly(lat, lon); - mark.showOverlay = true; - mark.lat = lat; - mark.lon = lon; - mark.screenX = map.width / 2; - mark.screenY = map.height / 2; - if (navigation) - navigation = false; - popLocationInfo.show(); - } - }); - } - } - - MapIcon { - visible: true - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/day-night.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - nightView = !nightView; - MapExtras.setDaylight(!nightView); - } - } - } - } - } - } - - Item { - id: edgeToolbar - width: units.gu(8) - anchors.top: buttonRotate.bottom - anchors.bottom: buttonZoomIn.top - anchors.right: parent.right - visible: !mainView.wideAspect && !popNavigatorInfo.visible - z: 99 - - Rectangle { - id: verticalToolBar - anchors.fill: parent - color: "transparent" - opacity: (!mainView.wideAspect && mapView.state === "view" ? 1.0 : 0.0) - enabled: opacity > 0 - - Rectangle { - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.topMargin: units.gu(1) - anchors.bottomMargin: units.gu(1) - width: units.gu(8) - color: "transparent" - - Column { - anchors.horizontalCenter: parent.horizontalCenter - spacing: units.gu(1) - - MapIcon { - anchors.horizontalCenter: parent.horizontalCenter - source: "qrc:/images/navigation-menu.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.5) - opacity: 0.7 - height: units.gu(6) - onClicked: { - popMainMenu.show(); - } - } - - MapIcon { - anchors.horizontalCenter: parent.horizontalCenter - source: "qrc:/images/trip/here.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - if (!lockRotation) { - map.lockToPosition = true; - } else if(positionSource._posValid) { - map.showCoordinatesInstantly(positionSource._lat, positionSource._lon); - showPositionInfo(); - } else { - showPositionInfo(); - } - } - } - - MapIcon { - anchors.horizontalCenter: parent.horizontalCenter - source: "qrc:/images/trip/pin.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - var page = stackView.push("qrc:/controls2/Favorites.qml"); - ToolBox.connectOnce(page.showPosition, function(lat, lon){ - if (lat !== NaN && lon !== NaN) { - map.showCoordinatesInstantly(lat, lon); - mark.showOverlay = true; - mark.lat = lat; - mark.lon = lon; - mark.screenX = map.width / 2; - mark.screenY = map.height / 2; - if (navigation) - navigation = false; - popLocationInfo.show(); } - }); - } - } - - MapIcon { - visible: true - anchors.horizontalCenter: parent.horizontalCenter - source: "qrc:/images/trip/search.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - var page = stackView.push("qrc:/controls2/SearchPlace.qml", { - "searchCenterLat": positionSource._lat, - "searchCenterLon": positionSource._lon, - "acceptLabel": qsTr("Go"), - "acceptIcon" : "qrc:/images/trip/navigator.svg", - "showPositionEnabled": true - }); - ToolBox.connectOnce(page.selectLocation, function(location, lat, lon, label){ - if (lat !== NaN && lon !== NaN && label !== "") { - popRouting.goTo(lat, lon, label); - } - }); - ToolBox.connectOnce(page.showPosition, function(lat, lon){ - if (lat !== NaN && lon !== NaN) { - map.showCoordinatesInstantly(lat, lon); - mark.showOverlay = true; - mark.lat = lat; - mark.lon = lon; - mark.screenX = map.width / 2; - mark.screenY = map.height / 2; - if (navigation) - navigation = false; - popLocationInfo.show(); } - }); - } - } - - MapIcon { - visible: true - anchors.horizontalCenter: parent.horizontalCenter - source: "qrc:/images/day-night.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - nightView = !nightView; - map.toggleDaylight(); - } - } - } - } - } - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Widgets - //// - - DialogAction { - id: dialogAction - } - - DialogEnter { - id: dialogEnter - } - - PopInfo { - id: popInfo - anchors { - top: parent.top - left: parent.left - right: parent.right - } - } - - NavigatorInfo { - id: popNavigatorInfo - navigator: navigator - anchors { - top: popInfo.bottom - left: parent.left - right: parent.right - } - maximumHeight: units.gu(16) - visible: false - onClose: { - navigator.stop(); - visible = false; - // exit navigation mode if the status of the position does not allow it - if (mapView.positionState === 0) { - mapView.navigation = false; - } - } - } - - Connections { - target: popNavigatorInfo - onVisibleChanged: { - if (popNavigatorInfo.visible && !mapVoice.voiceValid) { - popInfo.open(qsTr("The voice GPS driving directions is not activated")); - } - } - } - - LocationInfo { - id: popLocationInfo - position: positionSource - anchors { - top: popInfo.bottom - left: parent.left - right: parent.right - } - maximumHeight: widgetBottomY - visible: false - onClose: { - visible = false; - overlayManager.removeMark(0); - } - onShow: { - if (mark.showOverlay) { - map.interactiveIcons = false; - overlayManager.addMark(0, mark.lat, mark.lon); - } - if (mark.screenY < widgetBottomY / 2) - map.up(); - popLocationInfo.searchLocation(mark.lat, mark.lon); - visible = true; - } - onVisibleChanged: { - if (visible) - mapView.pushState("locationInfo"); - else { - map.interactiveIcons = true; - mapView.popState("locationInfo"); - } - } - } - - Routing { - id: popRouting - position: positionSource - navigator: navigator - anchors { - top: popInfo.bottom - left: parent.left - right: parent.right - } - maximumHeight: map.height - y /*- units.gu(8)*/ - height: maximumHeight - visible: false - onClose: visible = false - onShow: visible = true - onVisibleChanged: { - if (visible) - mapView.pushState("routing"); - else - mapView.popState("routing"); - } - - function goTo(lat, lon, label) { - placeTo.lat = lat; - placeTo.lon = lon; - placeTo.address = label; - placeTo.valid = true; - placeFrom.lat = position._lat; - placeFrom.lon = position._lon; - placeFrom.address = qsTr("My Position"); - placeFrom.valid = true; - state = "dialog"; - show(); - } - } - - MainMenu { - id: popMainMenu - anchors { - top: popInfo.bottom - left: parent.left - right: parent.right - } - height: map.height - y /*- units.gu(8)*/ - visible: false - onClose: visible = false - onShow: visible = true - onVisibleChanged: { - if (visible) - mapView.pushState("mainMenu"); - else - mapView.popState("mainMenu"); - } - } - - ConfigureMap { - id: popConfigureMap - anchors { - top: popInfo.bottom - left: parent.left - right: parent.right - } - height: map.height - y /*- units.gu(8)*/ - visible: false - onClose: visible = false - onShow: visible = true - onVisibleChanged: { - if (visible) - mapView.pushState("configureMap"); - else - mapView.popState("configureMap"); - } - } - - Tracking { - id: popTracking - anchors { - top: popInfo.bottom - left: parent.left - right: parent.right - } - height: map.height - y /*- units.gu(8)*/ - visible: false - onClose: visible = false - onShow: visible = true - onVisibleChanged: { - if (visible) - mapView.pushState("Tracking"); - else - mapView.popState("Tracking"); - } - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Navigation - //// - - Navigator { - id: navigator - position: positionSource - overlayManager: overlayManager - - onStarted: { - popNavigatorInfo.visible = Qt.binding(function() { return mapView.state === "view"; }); - } - - onTargetReached: { - popInfo.open(qsTr("Target reached at %1 %2.").arg(Converter.readableDistance(targetDistance)).arg(Converter.readableBearing(targetBearing))); - } - } - - MapRotator { - id: rotator - map: map - } - - property var overlayRecording: map.createOverlayWay("_track"); - property bool isRecording: false - - Connections { - target: Tracker - onRecordingFailed: { - popInfo.open(qsTr("Track recording failed")); - } - onIsRecordingChanged: { - // clear previous recording - if (Tracker.isRecording && !mapView.isRecording) { - overlayManager.removeRecording(); - overlayManager.removeMark(1); - overlayRecording.clear(); - } - mapView.isRecording = Tracker.isRecording; - } - onTrackerPositionRecorded: { - overlayRecording.addPoint(lat, lon); - overlayManager.addRecording(overlayRecording); - } - onTrackerPositionMarked: { - overlayManager.addMark(1, lat, lon); - } - } - - // On android disable navigation when the app is suspended - Connections { - target: mainView - onApplicationSuspendedChanged: { - if ((Android || DeviceMobile) && applicationSuspended && navigation) - navigation = false; - } - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Courses - //// - - // Store the selected course - property int courseId: 0 - - function addCourse(bid, overlays) { - if (overlayManager.addCourse(bid, overlays)) { - settings.courseId = courseId = bid; - } - } - - function removeCourse() { - overlayManager.removeAllCourses(); - settings.courseId = courseId = 0; - } - - GPXFileModel { - id: courseFile - onParseFinished: { - if (succeeded) - loadData(); - } - onProgressChanged: { - popInfo.open(qsTr("Loading") + " " + (Math.round(courseFile.progress * 1000) / 10).toFixed(1) + " %"); - } - } - - function loadGPX(bid) { - GPXListModel.loadData(); - var file = GPXListModel.findFileById(bid); - if (file !== "") { - ToolBox.connectOnce(courseFile.loaded, function(succeeded){ - if (succeeded) - mapView.addCourse(bid, courseFile.createOverlayObjects()); - }); - courseFile.parseFile(file); - return true; - } else { - return false; - } - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Rotation - //// - - onRotateEnabledChanged: { - configureRotation(rotateEnabled); - } - - function configureRotation(enabled) { - if (enabled) { - compass.active = !applicationSuspended; - compass.polled.connect(handleRotation); - } else { - compass.polled.disconnect(handleRotation); - compass.active = false; - mapView.rotation = 0.0; - } - } - - function handleRotation(azimuth, rotation) { - var d = rotation - map.view.angle; - if (d > Math.PI) - d = d - Math.PI*2.0; - else if (d < -Math.PI) - d = d + Math.PI*2.0; - if (d > 0.14 || d < -0.14) { - mapView.rotation = (map.view.angle + d); - } - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// About the tracker service - //// - - Connections { - target: Service - onStatusChanged: { - if (Service.status === Service.ServiceConnected) { - popInfo.open(qsTr("Tracker service is connected"), "limegreen", "black"); - // clear all data before ping ALL - overlayManager.removeRecording(); - overlayManager.removeMark(1); - overlayRecording.clear(); - Service.ping("ALL"); - } else { - popInfo.open(qsTr("Tracker service has been disconnected")); - } - } - } -} diff --git a/gui/controls2_509/Routing.qml b/gui/controls2_509/Routing.qml deleted file mode 100644 index d30cabff..00000000 --- a/gui/controls2_509/Routing.qml +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import Osmin 1.0 -import "./components" -import "../toolbox.js" as ToolBox - -PopOver { - id: routingDialog - title: "" - property MapPosition position - property Navigator navigator - property string vehicle: "car" - property real maximumHeight: parent.height - - states: [ - State { - name: "dialog" - PropertyChanges { target: routingDialog; title: qsTr("Navigation"); height: maximumHeight; } - PropertyChanges { target: dialog; visible: true; } - PropertyChanges { target: way; visible: false; } - }, - State { - name: "pickPlace" - PropertyChanges { target: routingDialog; title: qsTr("Pick a place on the Map"); height: minimumHeight; } - }, - State { - name: "navigate" - PropertyChanges { target: routingDialog; title: qsTr("Navigate"); height: maximumHeight; } - PropertyChanges { target: dialog; visible: false; } - PropertyChanges { target: way; visible: true; } - }, - State { - name: "navigation" - PropertyChanges { target: routingDialog; title: qsTr("Navigation"); height: maximumHeight; } - PropertyChanges { target: dialog; visible: false; } - PropertyChanges { target: way; visible: true; } - } - ] - state: "dialog" - - signal placePicked(bool valid, double lat, double lon) - - property QtObject placeFrom: QtObject { - property bool valid: false - property string address: qsTr("Select a position") - property double lat: 0.0 - property double lon: 0.0 - property LocationEntry location: null - } - - property QtObject placeTo: QtObject { - property bool valid: false - property string address: qsTr("Select a destination") - property double lat: 0.0 - property double lon: 0.0 - property LocationEntry location: null - } - - LocationInfoModel{ - id: locationInfoModel - } - - function locationDescription(index) { - var str = ""; - if (locationInfoModel.rowCount() > index) { - var mi = locationInfoModel.index(index, 0); - var d = locationInfoModel.data(mi, LocationInfoModel.DistanceRole); - if (d < 100.0) { - str = locationInfoModel.data(mi, LocationInfoModel.AddressRole); - if (str === "") - str = locationInfoModel.data(mi, LocationInfoModel.PoiRole); - if (str !== "") - str += " - "; - str += locationInfoModel.data(mi, LocationInfoModel.RegionRole); - } - } - return str; - } - - contents: Column { - id: routingBody - - Column { - id: dialog - width: parent.width - spacing: units.gu(1) - - // Route from - - Label { - text: qsTr("From") - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - ComboBox { - id: from - width: parent.width - height: units.gu(4) - flat: true - background: Rectangle { - color: styleMap.view.backgroundColor - anchors.fill: parent - } - textRole: "text" - Component.onCompleted: { - currentIndex = 0; - // by default set the current position - if (!placeFrom.valid && position._posValid) { - selectPosition(position._lat, position._lon); - } - } - model: [ - { text: placeFrom.address }, - { text: qsTr("My position") }, - { text: qsTr("Search Place") }, - { text: qsTr("Select on Map") }, - { text: qsTr("Favorite") } - ] - - onActivated: { - var page = null; - if (currentIndex === 1 && position._posValid) { - selectPosition(position._lat, position._lon); - } else if (currentIndex === 2) { - page = stackView.push("qrc:/controls2/SearchPlace.qml", { - "searchCenterLat": position._lat, - "searchCenterLon": position._lon, - "acceptLabel": qsTr("Accept") - }); - ToolBox.connectOnce(page.selectLocation, selectLocation); - } else if (currentIndex === 3) { - ToolBox.connectOnce(routingDialog.placePicked, picked); - routingDialog.state = "pickPlace"; - } else if (currentIndex === 4) { - page = stackView.push("qrc:/controls2/Favorites.qml", { "state": "selection" }); - ToolBox.connectOnce(page.selectPOI, selectPOI); - } - if (currentIndex !== 0) - currentIndex = 0; - } - function selectPosition(lat, lon) { - placeFrom.valid = true; - placeFrom.lat = lat; - placeFrom.lon = lon; - ToolBox.connectWhileFalse(locationInfoModel.readyChange, infoReadyChange); - locationInfoModel.setLocation(placeFrom.lat, placeFrom.lon); - } - function picked(valid, lat, lon) { - routingDialog.state = "dialog"; - if (valid) { - placeFrom.valid = true; - placeFrom.lat = lat; - placeFrom.lon = lon; - ToolBox.connectWhileFalse(locationInfoModel.readyChange, infoReadyChange); - locationInfoModel.setLocation(lat, lon); - } - } - function infoReadyChange(ready) { - if (ready) { - var str = locationDescription(0); - placeFrom.address = str.length > 0 ? str : Converter.readableCoordinatesGeocaching(placeFrom.lat, placeFrom.lon); - } - } - function selectLocation(location, lat, lon, label) { - if (lat !== NaN && lon !== NaN && label !== "") { - placeFrom.valid = true; - placeFrom.lat = lat; - placeFrom.lon = lon; - placeFrom.address = label; - } - } - function selectPOI(poi) { - if (poi) - selectLocation(null, poi.lat, poi.lon, poi.label); - } - } - Label { - id: fromCoordinates - width: parent.width - text: placeFrom.valid ? Converter.readableCoordinatesGeocaching(placeFrom.lat, placeFrom.lon) : "" - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("small") - } - - // Separator - Item { - width: parent.width - height: units.gu(1) - } - - // Route to - - Label { - text: qsTr("Destination") - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - ComboBox { - id: to - width: parent.width - height: units.gu(4) - flat: true - background: Rectangle { - color: styleMap.view.backgroundColor - anchors.fill: parent - } - textRole: "text" - Component.onCompleted: currentIndex = 0 - model: [ - { text: placeTo.address }, - { text: qsTr("Search Place") }, - { text: qsTr("Select on Map") }, - { text: qsTr("Favorite") } - ] - - onActivated: { - var page = null; - if (currentIndex === 1) { - page = stackView.push("qrc:/controls2/SearchPlace.qml", { - "searchCenterLat": position._lat, - "searchCenterLon": position._lon, - "acceptLabel": qsTr("Accept") - }); - ToolBox.connectOnce(page.selectLocation, selectLocation); - } else if (currentIndex === 2) { - ToolBox.connectOnce(routingDialog.placePicked, picked); - routingDialog.state = "pickPlace"; - } else if (currentIndex === 3) { - page = stackView.push("qrc:/controls2/Favorites.qml", { "state": "selection" }); - ToolBox.connectOnce(page.selectPOI, selectPOI); - } - if (currentIndex !== 0) - currentIndex = 0; - } - function picked(valid, lat, lon) { - routingDialog.state = "dialog"; - if (valid) { - placeTo.valid = true; - placeTo.lat = lat; - placeTo.lon = lon; - ToolBox.connectWhileFalse(locationInfoModel.readyChange, infoReadyChange); - locationInfoModel.setLocation(lat, lon); - } - } - function infoReadyChange(ready) { - if (ready) { - var str = locationDescription(0); - placeTo.address = str.length > 0 ? str : Converter.readableCoordinatesGeocaching(placeTo.lat, placeTo.lon); - } - } - function selectLocation(location, lat, lon, label) { - if (lat !== NaN && lon !== NaN && label !== "") { - placeTo.valid = true; - placeTo.lat = lat; - placeTo.lon = lon; - placeTo.address = label; - } - } - function selectPOI(poi) { - if (poi) - selectLocation(null, poi.lat, poi.lon, poi.label); - } - } - Label { - id: toCoordinates - width: parent.width - text: placeTo.valid ? Converter.readableCoordinatesGeocaching(placeTo.lat, placeTo.lon) : "" - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("small") - } - - ProgressBar { - height: units.gu(2) - width: parent.width - from: 0 - to: 100 - opacity: computeRunning && routeProgress > 0 ? 1.0 : 0.0 - value: routeProgress - } - - // vehicle - - Row { - anchors.horizontalCenter: parent.horizontalCenter - spacing: units.gu(3) - - MapIcon { - readonly property string transport: "foot" - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/trip/walk.svg" - height: units.gu(7) - width: height - color: vehicle === transport ? styleMap.popover.highlightedColor : styleMap.popover.foregroundColor - animationInterval: 500 - animationRunning: (vehicle === transport && computeRunning) - enabled: (!computeRunning && placeFrom.valid && placeTo.valid) || computeRunning - onClicked: { - if (vehicle === transport) { - if (computeRunning) - breakCompute(); - else - computeRoute(); - } else { - if (computeRunning) - breakCompute(); - vehicle = transport; - computeRoute(); - } - } - } - MapIcon { - readonly property string transport: "bicycle" - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/trip/bike.svg" - height: units.gu(7) - width: height - color: vehicle === transport ? styleMap.popover.highlightedColor : styleMap.popover.foregroundColor - animationInterval: 500 - animationRunning: (vehicle === transport && computeRunning) - enabled: (!computeRunning && placeFrom.valid && placeTo.valid) || computeRunning - onClicked: { - if (vehicle === transport) { - if (computeRunning) - breakCompute(); - else - computeRoute(); - } else { - if (computeRunning) - breakCompute(); - vehicle = transport; - computeRoute(); - } - } - } - MapIcon { - readonly property string transport: "car" - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/trip/car.svg" - height: units.gu(7) - width: height - color: vehicle === transport ? styleMap.popover.highlightedColor : styleMap.popover.foregroundColor - animationInterval: 500 - animationRunning: (vehicle === transport && computeRunning) - enabled: (!computeRunning && placeFrom.valid && placeTo.valid) || computeRunning - onClicked: { - if (vehicle === transport) { - if (computeRunning) - breakCompute(); - else - computeRoute(); - } else { - if (computeRunning) - breakCompute(); - vehicle = transport; - computeRoute(); - } - } - } - } - - Label { - width: parent.width - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("small") - text: routeMessage - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.Wrap - visible: text !== "" - } - } - - Column { - id: way - width: parent.width - spacing: units.gu(1) - - Row { - width: parent.width - spacing: units.gu(2) - MapIcon { - id: navigateButton - source: { - if (vehicle === "car") return "qrc:/images/trip/car.svg"; - if (vehicle === "bicycle") return "qrc:/images/trip/bike.svg"; - if (vehicle === "foot") return "qrc:/images/trip/walk.svg"; - return "qrc:/images/trip/navigation.svg"; - } - height: units.gu(6) - width: parent.width / 2 - units.gu(1) - color: styleMap.popover.foregroundColor - onClicked: { - // When current position cannot be defined, i.e sensor disabled, - // reset the current position at the location of the start point - // of the route. In other way it could schedule reroute. - if (!position._posValid) { - position._lat = placeFrom.lat; - position._lon = placeFrom.lon; - } - mapView.navigation = true; - ToolBox.connectOnce(navigator.stopped, onNavigatorStopped); - navigator.setup(vehicle, routingModel, placeTo.location); - routingDialog.state = "navigation"; - routingDialog.close(); - } - label.text: qsTr("Navigate") - enabled: routingDialog.state === "navigate" - opacity: enabled ? 1.0 : 0.5 - - function onNavigatorStopped() { - routingDialog.state = "navigate"; - } - } - MapIcon { - id: clearButton - source: "qrc:/images/delete.svg" - height: units.gu(6) - width: parent.width / 2 - units.gu(1) - color: styleMap.popover.foregroundColor - onClicked: { - routingModel.cancel(); - routingDialog.state = "dialog" - } - label.text: qsTr("Clear") - } - } - - ListView { - id: stepsView - width: parent.width - height: contentHeight - interactive: false - spacing: units.gu(1) - model: routingModel - - header: Row { - spacing: units.gu(1) - width: parent.width - Label { - text: qsTr("Route length:") - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("medium") - } - Label { - id: distanceLabel - text: Converter.readableDistance(routingModel.length) - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - Label { - text: ", " + qsTr("Duration:") - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("medium") - } - Label { - id: durationLabel - text: Converter.panelDurationHM(routingModel.duration) - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - } - delegate: Row { - spacing: units.gu(2) - width: parent ? parent.width : 0 - height: Math.max(stepInfo.implicitHeight, icon.height) - - WAYIcon { - id: icon - anchors.verticalCenter: parent.verticalCenter - color: styleMap.popover.foregroundColor - stepType: model.type - roundaboutExit: model.roundaboutExit - roundaboutClockwise: model.roundaboutClockwise - width: units.gu(7) - height: width - } - Column { - id: stepInfo - anchors.verticalCenter: parent.verticalCenter - width: parent.width - icon.width - units.gu(2) - Label { - id: distance - width: parent.width - color: styleMap.popover.foregroundColor - text: { - return settings.routeStepDelta - ? Converter.panelDistance(model.distanceDelta) + " ~ " + Converter.panelDurationHM(model.timeDelta) + " Δ" - : Converter.panelDistance(model.distance) + " ~ " + Converter.panelDurationHM(model.time) - } - font.pointSize: units.fs("small") - horizontalAlignment: Label.AlignRight - MouseArea { - anchors.fill: parent - onClicked: { - settings.routeStepDelta = (settings.routeStepDelta ? false : true); - } - } - } - Label { - id: entryDescription - color: styleMap.popover.foregroundColor - width: parent.width - text: model.description - font.pointSize: units.fs("small") - wrapMode: Text.Wrap - } - } - } - } - } - } - - property int routeProgress: 0 - property string routeMessage: "" - property bool computeRunning: false - - RoutingListModel { - id: routingModel - onRouteFailed: { - routeMessage = qsTranslate("message", reason); - computeRunning = false; - } - onRoutingProgress: { - routeProgress = percent; - } - onComputingChanged: { - routeProgress = 0; - if (!computeRunning) { - console.log("Computing aborted"); - routingModel.clear(); - } else { - var count = routingModel.count; - if (count > 0) { - if (count > settings.maximumRouteStep) { - popInfo.open(qsTr("The number of steps exceeds the limit. Please reduce the length of the route and restart the calculation.")); - routingModel.clear(); - } else { - routingDialog.state = "navigate"; - } - computeRunning = false; - } - } - } - } - - function breakCompute() { - routingModel.cancel(); - computeRunning = false; - } - - function computeRoute() { - routeProgress = 0; - routeMessage = ""; - placeFrom.location = routingModel.locationEntryFromPosition(placeFrom.lat, placeFrom.lon); - placeTo.location = routingModel.locationEntryFromPosition(placeTo.lat, placeTo.lon); - if (placeFrom.location && placeTo.location) { - computeRunning = true; - routingModel.setStartAndTarget(placeFrom.location, placeTo.location, vehicle); - settings.lastVehicle = vehicle; - } else { - routeMessage = qsTr("Invalid entry"); - routingModel.clear(); - } - } - - Component.onCompleted: { - if (settings.lastVehicle !== "") - vehicle = settings.lastVehicle; - } - - onClose: { - // abort pick - if (state === "pickPlace") - placePicked(false, 0.0, 0.0); - } -} diff --git a/gui/controls2_509/SearchPlace.qml b/gui/controls2_509/SearchPlace.qml deleted file mode 100644 index 215c31ed..00000000 --- a/gui/controls2_509/SearchPlace.qml +++ /dev/null @@ -1,699 +0,0 @@ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import Osmin 1.0 -import "./components" -import "../toolbox.js" as ToolBox - -MapPage { - id: searchPage - pageTitle: qsTr("Search Place") - isRoot: true - - property bool acceptEnabled: true - property string acceptLabel: qsTr("Accept") - property string acceptIcon: "qrc:/images/trip/pin.svg" - property bool addFavoriteEnabled: true - property bool addMarkerEnabled: true - property bool showPositionEnabled: false - property double searchCenterLat - property double searchCenterLon - - readonly property var distanceTypes: [ 1000.0, 3000.0, 6000.0, 10000.0, 15000.0, 20000.0 ] - - states: [ - State { - name: "dialog" - PropertyChanges { target: searchPage; pageTitle: qsTr("Search Place"); isRoot: true; } - PropertyChanges { target: searchField; visible: true; } - PropertyChanges { target: suggestionView; visible: true; } - PropertyChanges { target: searchView; visible: false; model: null; } - PropertyChanges { target: noData; visible: false; } - }, - State { - name: "poi" - PropertyChanges { target: searchPage; pageTitle: qsTr(suggestionView.selectedItem.label); isRoot: false; } - PropertyChanges { target: searchField; visible: false; } - PropertyChanges { target: suggestionView; visible: false; } - PropertyChanges { target: searchView; visible: true; model: poiModel; } - PropertyChanges { target: noData; visible: poiModel.noDataFound; } - }, - State { - name: "place" - PropertyChanges { target: searchPage; pageTitle: qsTr("Search Place"); isRoot: false; } - PropertyChanges { target: searchField; visible: true; } - PropertyChanges { target: suggestionView; visible: false; } - PropertyChanges { target: searchView; visible: true; model: placeModel; } - PropertyChanges { target: noData; visible: placeModel.noDataFound; } - } - ] - - state: "dialog" - - onStateChanged: { - console.log("Search state changed: "+ state); - } - - signal selectLocation(LocationEntry location, double lat, double lon, string label) - signal showPosition(double lat, double lon) - - onPopped: { - // a slot could be connected to signal, waiting a selection - // trigger the signal for null - selectLocation(null, NaN, NaN, ""); - } - - onGoUpClicked: { - selectedLocation = null; - searchPage.state = "dialog"; - searchField.clear(); - } - - header: Item { - width: searchPage.width - height: units.gu(8) - - SearchField { - id: searchField - width: parent.width - anchors.centerIn: parent - onDisplayTextChanged: { - var pattern = displayText.trim(); - if (pattern.length > 0) { - if (searchPage.state === "dialog") { - // show the places - searchPage.state = "place"; - } - searchPage.searchPattern = pattern; - } else if (searchPage.state !== "dialog") { - // cancel search and show suggestions - searchPage.searchPattern = ""; - searchPage.selectedLocation = null; - searchPage.state = "dialog"; - } - postponeSearch.restart(); - } - Component.onCompleted: { - forceActiveFocus(); - } - onAccepted: { - if (searchPage.state !== "dialog") { - // accept the top item without preview - var selectedLocation = searchView.model.get(0); - if (selectedLocation !== null) { - //@TODO: save history - if (selectedLocation.label !== "") { - selectLocation(selectedLocation, selectedLocation.lat, selectedLocation.lon, selectedLocation.label); - } else { - selectLocation(selectedLocation, selectedLocation.lat, selectedLocation.lon, - Converter.readableCoordinatesGeocaching(selectedLocation.lat, selectedLocation.lon)); - } - stackView.pop(); - } - } - } - } - - Column { - visible: !searchField.visible - width: parent.width - units.gu(4) - anchors.centerIn: parent - Label { - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Up to distance %1").arg(Converter.readableDistance(distanceTypes[distanceSelector.value])) - color: styleMap.view.foregroundColor - font.pointSize: units.fs("small") - } - Slider { - id: distanceSelector - width: parent.width - height: units.gu(3) - snapMode: Slider.SnapAlways - stepSize : 1 - from: 0 - to: distanceTypes.length - 1 - value: 0 - onValueChanged: { - postponeMaxDistance.restart(); - } - Timer { - id: postponeMaxDistance - interval: 1000 - onTriggered: { - var distance = distanceTypes[distanceSelector.value]; - if (poiModel.maxDistance !== distance) { - poiModel.maxDistance = distance; - } - } - } - } - } - } - - property string searchPattern: "" - - Timer { - id: postponeSearch - interval: 1000 - property string _old: "" - onTriggered: { - if (searchPattern !== _old) { - _old = searchPattern; - if (searchPattern.length > 2) { - console.log("Search expression: \"" + searchPattern + "\""); - placeModel.pattern = searchPattern; - } else { - placeModel.pattern = ""; - } - // reset current of the search view - searchView.currentIndex = -1; - } - } - } - - ///////////////////////////////////////////////////////////////////// - //// - //// Suggestions - - /** - * Inspired by Search.qml in OSMScout - * - */ - ListModel { - id: poiTypesModel - // amenities - ListElement { - label: QT_TR_NOOP("Restaurant"); distanceId: 0; iconType: "amenity_restaurant"; - types: "amenity_restaurant amenity_restaurant_building"; } - ListElement { - label: QT_TR_NOOP("Fast Food"); distanceId: 0; iconType: "amenity_fast_food"; - types: "amenity_fast_food amenity_fast_food_building"; } - ListElement { - label: QT_TR_NOOP("Cafe"); distanceId: 0; iconType: "amenity_cafe"; - types: "amenity_cafe amenity_cafe_building"; } - ListElement { - label: QT_TR_NOOP("Pub"); distanceId: 0; iconType: "amenity_pub"; - types: "amenity_pub amenity_pub_building"; } - ListElement { - label: QT_TR_NOOP("Bar"); distanceId: 0; iconType: "amenity_bar"; - types: "amenity_bar amenity_bar_building"; } - ListElement { - label: QT_TR_NOOP("ATM"); distanceId: 0; iconType: "amenity_atm"; - types: "amenity_atm"; } - ListElement { - label: QT_TR_NOOP("Drinking water"); distanceId: 0; iconType: "amenity_drinking_water"; - types: "amenity_drinking_water"; } - ListElement { - label: QT_TR_NOOP("Toilets"); distanceId: 0; iconType: "amenity_toilets"; - types: "amenity_toilets"; } - - // public transport - ListElement { - label: QT_TR_NOOP("Public transport stop"); distanceId: 0; iconType: "railway_tram_stop"; - types: "railway_station railway_subway_entrance railway_tram_stop highway_bus_stop railway_halt amenity_ferry_terminal"; } - - ListElement { - label: QT_TR_NOOP("Fuel"); distanceId: 3; iconType: "amenity_fuel"; - types: "amenity_fuel amenity_fuel_building"; } - ListElement { - label: QT_TR_NOOP("Pharmacy"); distanceId: 3; iconType: "amenity_pharmacy"; - types: "amenity_pharmacy"; } - ListElement { - label: QT_TR_NOOP("Accomodation"); distanceId: 3; iconType: "tourism_hotel"; - types: "tourism_hotel tourism_hotel_building tourism_hostel tourism_hostel_building tourism_motel tourism_motel_building tourism_alpine_hut tourism_alpine_hut_building"; } - ListElement { - label: QT_TR_NOOP("Camp"); distanceId: 3; - iconType: "tourism_camp_site"; types: "tourism_camp_site tourism_caravan_site"; } - ListElement { - label: QT_TR_NOOP("Castle, Manor"); distanceId: 3; iconType: "historic_castle"; - types: "historic_castle historic_castle_building historic_manor historic_manor_building historic_ruins historic_ruins_building"; } - ListElement { - label: QT_TR_NOOP("Spring"); distanceId: 1; iconType: "natural_spring"; - types: "natural_spring"; } - - // and somethig for fun - ListElement { - label: QT_TR_NOOP("Via ferrata route"); distanceId: 5; iconType: "natural_peak"; - types: "highway_via_ferrata_easy highway_via_ferrata_moderate highway_via_ferrata_difficult highway_via_ferrata_extreme"; } - } - - MapListView { - id: suggestionView - anchors.fill: parent - height: contentHeight - spacing: 0 - clip: true - model: poiTypesModel - delegate: MouseArea { - height: rowPoiType.height + units.gu(1) - width: parent.width - Rectangle { - anchors.fill: parent - visible: parent.pressed - color: styleMap.view.highlightedColor - opacity: 0.2 - } - Row { - id: rowPoiType - anchors.verticalCenter: parent.verticalCenter - POIIcon { - id: poiIcon - anchors.verticalCenter: parent.verticalCenter - poiType: iconType - color: styleMap.view.foregroundColor - width: units.gu(6) - height: units.gu(6) - } - Column { - anchors.verticalCenter: parent.verticalCenter - Label { - id: labelLabel - width: suggestionView.width - poiIcon.width - units.gu(1) - font.pointSize: units.fs("medium") - color: styleMap.view.primaryColor - textFormat: Text.StyledText - text: qsTr(label) - } - Label { - id: descriptionLabel - width: suggestionView.width - poiIcon.width - units.gu(1) - font.pointSize: units.fs("small") - wrapMode: Text.WordWrap - visible: distanceId > 0 - text: qsTr("Up to distance %1").arg(Converter.readableDistance(distanceTypes[distanceId])) - color: styleMap.view.highlightedColor - } - } - } - onClicked: { - suggestionView.selectedItem = poiTypesModel.get(index); - poiModel.maxDistance = distanceTypes[distanceId]; - poiModel.types = types.split(" "); - distanceSelector.value = distanceId; // reset the distance selector - searchPage.state = "poi"; - } - } - property var selectedItem: null - } - - - ///////////////////////////////////////////////////////////////////// - //// - //// Search location - - MapListView { - id: searchView - anchors.fill: parent - anchors.bottomMargin: mapPreview.height - height: contentHeight - spacing: 0 - clip: true - model: null - delegate: MouseArea { - height: rowEntry.implicitHeight + units.gu(1) - width: parent ? parent.width : 0 - Rectangle { - anchors.fill: parent - visible: parent.pressed || index === searchView.currentIndex - color: styleMap.view.highlightedColor - opacity: 0.2 - } - Row { - id: rowEntry - anchors.verticalCenter: parent.verticalCenter - POIIcon { - id: entryIcon - anchors.verticalCenter: parent.verticalCenter - poiType: type - color: styleMap.view.foregroundColor - width: units.gu(6) - height: units.gu(6) - } - Column { - anchors.verticalCenter: parent.verticalCenter - Label { - id: entryLabel - width: searchView.width - entryIcon.width - units.gu(1) - font.pointSize: units.fs("medium") - color: styleMap.view.primaryColor - textFormat: Text.StyledText - text: (type === "coordinate") ? Converter.readableCoordinatesGeocaching(lat, lon) - : label === "" ? qsTr("Unnamed") - : label - } - Label { - id: entryRegion - width: searchView.width - entryIcon.width - units.gu(1) - wrapMode: Text.WordWrap - text: { - var str = ""; - if (region.length > 0) { - var start = 0; - while (start < region.length && region[start] === label) { - start++; - } - if (start < region.length) { - str = region[start]; - for (var i = start + 1; i < region.length; ++i) { - str += ", "+ region[i]; - } - } else { - str = region[0]; - } - } - return str; - } - color: styleMap.view.secondaryColor - font.pointSize: units.fs("medium") - visible: region.length > 0 - } - Label{ - id: entryDistance - width: searchView.width - entryIcon.width - units.gu(1) - color: styleMap.view.highlightedColor - font.pointSize: units.fs("medium") - text: Converter.readableDistance(distance) + " " + Converter.readableBearing(bearing) - } - } - } - onClicked: { - forceActiveFocus(); - searchView.currentIndex = index; - var selected = searchView.model.get(index); - selectedIsFavorite = FavoritesModel.isFavorite(selected.lat, selected.lon); - selectedLocation = selected; - } - } - } - - NearPOIModel { - id: poiModel - lat: searchCenterLat - lon: searchCenterLon - resultLimit: 100 - - property bool noDataFound: false - onSearchingChanged: { - if (searching) { - noDataFound = false; - } else { - noDataFound = (rowCount() === 0); - } - } - } - - LocationListModel { - id: placeModel - lat: searchCenterLat - lon: searchCenterLon - resultLimit: 100 - - property bool noDataFound: false - onSearchingChanged: { - if (searching) { - noDataFound = false; - } else { - noDataFound = (rowCount() === 0); - } - } - - /** - * Inspired by Search.qml in OSMScout - * compute rank for location, it should be in range 0~1 - */ - function locationRank(loc){ - var rank = 1; - if (loc.type === "coordinate") { - return rank; - } else if (loc.type === "object") { - if (loc.objectType === "boundary_country") { - rank *= 1; - } else if (loc.objectType === "boundary_state") { - rank *= 0.93; - } else if (loc.objectType === "boundary_administrative" || - loc.objectType === "place_town") { - rank *= 0.9; - } else if (loc.objectType === "highway_residential" || - loc.objectType === "address") { - rank *= 0.8; - } else if (loc.objectType === "railway_station" || - loc.objectType === "railway_tram_stop" || - loc.objectType === "railway_subway_entrance" || - loc.objectType === "highway_bus_stop" - ) { - rank *= 0.7; - } else { - rank *= 0.5; - } - var distance = loc.distanceTo(searchCenterLat, searchCenterLon); - rank *= 1 / Math.log(distance / 1000 + Math.E); - return rank; - } - return 0; - } - - compare: function(a, b){ - return locationRank(b) - locationRank(a); - } - - equals: function(a, b){ - if (a.objectType === b.objectType && - a.distanceTo(b.lat, b.lon) < 300 && - a.distanceTo(searchCenterLat, searchCenterLon) > 3000 - ) { - return true; - } - return false; - } - } - - - property LocationEntry selectedLocation: null - property int selectedIsFavorite: 0 - - Loader { - id: mapPreview - // active the preview on selection - active: selectedLocation !== null && !searchField.fieldFocus - height: active ? parent.height / 2 : 0 - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - asynchronous: true - sourceComponent: Item { - id: preview - anchors.fill: parent - property alias map: map - Map { - id: map - showCurrentPosition: true - anchors.fill: parent - - onTap: { - // on tap change the location - preview.mark.selected = false; // not the selected location - preview.mark.lat = lat; - preview.mark.lon = lon; - preview.mark.label = Converter.readableCoordinatesGeocaching(lat, lon); - preview.mark.type = ""; - preview.isFavoriteMark = FavoritesModel.isFavorite(lat, lon); - locationInfoModel.setLocation(lat, lon); - showCoordinates(lat, lon); - addPositionMark(0, lat, lon); - } - } - - property int isFavoriteMark: 0 - property QtObject mark: QtObject { - property bool selected: false // is the selected location - property double lat: 0.0 // latitude - property double lon: 0.0 // longitude - property string label: "" // label - property string type: "" // type - } - - LocationInfoModel{ - id: locationInfoModel - onReadyChange: { - if (ready && rowCount() > 0) { - var str = ""; - var mi = index(0, 0) - str = data(mi, LocationInfoModel.LabelRole); - if (str === "") - str = data(mi, LocationInfoModel.AddressRole); - if (str === "") - str = data(mi, LocationInfoModel.PoiRole); - if (str !== "") - preview.mark.label = str; - preview.mark.type = data(mi, LocationInfoModel.TypeRole); - } - } - } - - MapIcon { - id: buttonClose - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: units.gu(1) - source: "qrc:/images/close.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.5) - opacity: 0.7 - height: units.gu(6) - onClicked: { - selectedLocation = null; // deactivate the preview - } - } - MapIcon { - id: buttonAccept - anchors.top: parent.top - anchors.left: parent.left - anchors.margins: units.gu(1) - source: acceptIcon - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - label.text: acceptLabel - label.font.pointSize: units.fs("medium") - label.color: "black" - height: units.gu(6) - onClicked: { - if (mark.selected) { - selectLocation(selectedLocation, preview.mark.lat, preview.mark.lon, preview.mark.label); - } else { - selectLocation(null, preview.mark.lat, preview.mark.lon, preview.mark.label); - } - stackView.pop(); - } - } - MapIcon { - id: buttonShowPosition - visible: showPositionEnabled - anchors.top: parent.top - anchors.left: buttonAccept.right - anchors.margins: units.gu(1) - source: "qrc:/images/trip/here.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - showPosition(preview.mark.lat, preview.mark.lon); - stackView.pop(); - } - } - MapIcon { - id: buttonAddFavorite - visible: addFavoriteEnabled - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.margins: units.gu(1) - source: "qrc:/images/trip/favourite.svg" - color: preview.isFavoriteMark > 0 ? "deepskyblue" : "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - if (preview.isFavoriteMark === 0) { - dialogEnter.title = qsTr("Add favorite"); - dialogEnter.userEntry = preview.mark.label; - dialogEnter.open(); - ToolBox.connectOnce(dialogEnter.reply, function(accepted, entry){ - if (accepted) { - var label = entry.trim(); - preview.isFavoriteMark = createFavorite(preview.mark.lat, - preview.mark.lon, - (label.length > 0 ? label : preview.mark.label), - preview.mark.type); - } - }); - } else { - var favorite = FavoritesModel.getById(preview.isFavoriteMark); - dialogAction.title = qsTr("Delete favorite ?"); - dialogAction.text = favorite.label; - dialogAction.open(); - ToolBox.connectOnce(dialogAction.reply, function(accepted){ - if (accepted && removeFavorite(preview.isFavoriteMark)) - preview.isFavoriteMark = 0; - }); - } - } - } - } - - onStatusChanged: { - if (active && status === Loader.Ready) { - console.log("Activate map preview"); - searchPage.selectedLocationChanged.connect(showSelectedLocation); - showSelectedLocation(); - } else if (!active) { - console.log("Deactivate map preview"); - searchPage.selectedLocationChanged.disconnect(showSelectedLocation); - } - } - - function showSelectedLocation() { - console.log("Show selected location on map preview"); - item.map.showCoordinatesInstantly(selectedLocation.lat, selectedLocation.lon); - item.map.addPositionMark(0, selectedLocation.lat, selectedLocation.lon); - item.map.removeAllOverlayObjects(); - // setup mark - item.mark.selected = true; - item.mark.lat = selectedLocation.lat; - item.mark.lon = selectedLocation.lon; - item.mark.type = selectedLocation.objectType; - item.isFavoriteMark = selectedIsFavorite; - if (selectedLocation.label !== "") - item.mark.label = selectedLocation.label; - else - item.mark.label = Converter.readableCoordinatesGeocaching(selectedLocation.lat, selectedLocation.lon); - //console.log("Selected location: \"" + item.mark.label + "\", " + item.mark.type); - } - - Behavior on height { - NumberAnimation { duration: 300; easing.type: Easing.InOutQuad; - onStopped: { - console.log("Animate is stopped"); - searchView.positionViewAtIndex(searchView.currentIndex, ListView.Contain); - } - } - } - } - - Text { - id: noData - anchors.top: parent.top - anchors.topMargin: units.gu(8) - anchors.horizontalCenter: parent.horizontalCenter - color: styleMap.view.foregroundColor - font.pointSize: units.fs("large") - text: qsTr("No data") - visible: false - } - - ActivitySpinner { - id: busyIndicator - visible: poiModel.searching || placeModel.searching - anchors.centerIn: null - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: units.gu(8) - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Dialog - //// - - DialogAction { - id: dialogAction - } - - DialogEnter { - id: dialogEnter - } -} diff --git a/gui/controls2_509/Settings.qml b/gui/controls2_509/Settings.qml deleted file mode 100644 index 51f46db0..00000000 --- a/gui/controls2_509/Settings.qml +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import QtQuick.Layouts 1.3 -import Osmin 1.0 -import "./components" - -MapPage { - id: settingsPage - pageTitle: qsTr("Settings") - pageFlickable: body - - onPopped: { -// var needRestart = (settings.systemOfUnits !== Converter.system); -// if (needRestart) { -// mainView.jobRunning = true; -// Qt.exit(16); -// } - } - - property string mapsDirectory: "" - Component.onCompleted: { - if (MapsDirectories.length > 1) - mapsDirectory = MapsDirectories[1]; // external storage - else - mapsDirectory = MapsDirectories[0]; // home maps store - } - - Flickable { - id: body - anchors.fill: parent - contentHeight: settingsColumn.implicitHeight - ScrollBar.vertical: ScrollBar {} - - Column { - id: settingsColumn - width: parent.width - units.gu(4) - anchors.horizontalCenter: parent.horizontalCenter - spacing: units.gu(1) - - RowLayout { - spacing: 0 - MapIcon { - height: units.gu(6) - source: "qrc:/images/font-scalling.svg" - hoverEnabled: false - } - SpinBox { - id: fontScaleBox - enabled: !Android - from: 50 - value: settings.fontScaleFactor * 100 - to: 150 - stepSize: 10 - font.pointSize: units.fs("medium"); - Layout.fillWidth: true - - property int decimals: 2 - property real realValue: value / 100 - property real acceptedValue: settings.fontScaleFactor - - validator: DoubleValidator { - bottom: Math.min(fontScaleBox.from, fontScaleBox.to) - top: Math.max(fontScaleBox.from, fontScaleBox.to) - } - - textFromValue: function(value, locale) { - return Number(value / 100).toLocaleString(locale, 'f', fontScaleBox.decimals) - } - - valueFromText: function(text, locale) { - return Number.fromLocaleString(locale, text) * 100 - } - - onValueModified: { - settings.fontScaleFactor = realValue - } - } - } - - RowLayout { - spacing: 0 - MapIcon { - height: units.gu(6) - source: "qrc:/images/graphic-scalling.svg" - hoverEnabled: false - } - SpinBox { - id: scaleBox - enabled: !Android - from: 50 - value: settings.scaleFactor * 100 - to: 400 - stepSize: 10 - font.pointSize: units.fs("medium"); - Layout.fillWidth: true - - property int decimals: 2 - property real realValue: value / 100 - property real acceptedValue: settings.scaleFactor - - validator: DoubleValidator { - bottom: Math.min(scaleBox.from, scaleBox.to) - top: Math.max(scaleBox.from, scaleBox.to) - } - - textFromValue: function(value, locale) { - return Number(value / 100).toLocaleString(locale, 'f', scaleBox.decimals) - } - - valueFromText: function(text, locale) { - return Number.fromLocaleString(locale, text) * 100 - } - - onValueModified: { - mainView.width = Math.round(realValue * mainView.width / settings.scaleFactor); - mainView.height = Math.round(realValue * mainView.height / settings.scaleFactor); - settings.scaleFactor = realValue - } - } - } - - RowLayout { - spacing: units.gu(1) - Layout.fillWidth: true - Label { - text: qsTr("Theme") - font.pointSize: units.fs("medium"); - } - ComboBox { - id: themeBox - flat: true - property int acceptedValue: settings.theme - model: [ - qsTr("Light"), - qsTr("Dark") - ] - - currentIndex: settings.theme - onActivated: { - settings.theme = index - } - - Layout.fillWidth: true - font.pointSize: units.fs("medium"); - Component.onCompleted: { - popup.font.pointSize = units.fs("medium"); - } - } - } - - RowLayout { - spacing: units.gu(1) - Layout.fillWidth: true - Label { - text: qsTr("System of Units") - font.pointSize: units.fs("medium"); - } - ComboBox { - id: unitsBox - flat: true - model: [ - qsTr("SI"), - qsTr("Imperial") - ] - property string selected: Converter.system - currentIndex: (settings.systemOfUnits === "Imperial" ? 1 : 0) - Layout.fillWidth: true - font.pointSize: units.fs("medium"); - onActivated: { - settings.systemOfUnits = Converter.systems()[index] - } - Component.onCompleted: { - popup.font.pointSize = units.fs("medium"); - } - } - } - - RowLayout { - spacing: 0 - MapIcon { - height: units.gu(6) - source: "qrc:/images/compass.svg" - hoverEnabled: false - rotation: (-1.0) * magdipBox.realValue - } - SpinBox { - id: magdipBox - from: -300 - value: settings.magneticDip * 10 - to: 300 - stepSize: 10 - font.pointSize: units.fs("medium"); - Layout.fillWidth: true - - property int decimals: 1 - property real realValue: 0.1 * value - - validator: DoubleValidator { - bottom: Math.min(magdipBox.from, magdipBox.to) - top: Math.max(magdipBox.from, magdipBox.to) - } - - textFromValue: function(value, locale) { - return Number(0.1 * value).toLocaleString(locale, 'f', magdipBox.decimals) - } - - valueFromText: function(text, locale) { - return Number.fromLocaleString(locale, text) * 10 - } - - onValueModified: { - settings.magneticDip = realValue - } - } - } - - Label { - text: qsTr("The change will be effective after restart.") - font.pointSize: units.fs("medium") - color: "red" - visible: settings.systemOfUnits !== Converter.system - maximumLineCount: 2 - width: parent.width - wrapMode: Text.WordWrap - } - - Label { - text: qsTr("Data directory") - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - Label { - text: qsTr("%1 free").arg(Converter.readableBytes(Utils.storageBytesFree(DataDirectory))) - color: styleMap.view.foregroundColor - font.pointSize: units.fs("small") - } - Label { - text: DataDirectory - color: styleMap.view.foregroundColor - font.pointSize: units.fs("small") - maximumLineCount: 3 - width: parent.width - wrapMode: Text.WrapAnywhere - } - Label { - text: qsTr("Maps directory") - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - Label { - text: qsTr("%1 free").arg(Converter.readableBytes(Utils.storageBytesFree(mapsDirectory))) - color: styleMap.view.foregroundColor - font.pointSize: units.fs("small") - } - Label { - text: mapsDirectory - color: styleMap.view.foregroundColor - font.pointSize: units.fs("small") - maximumLineCount: 3 - width: parent.width - wrapMode: Text.WrapAnywhere - } - Label { - text: qsTr("Hillshade provider") - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - Label { - text: (hillshadeProvider != null ? hillshadeProvider.name : qsTr("Not configured")) - color: styleMap.view.foregroundColor - font.pointSize: units.fs("small") - } - Label { - text: (hillshadeProvider != null ? hillshadeProvider.copyright : "") - color: styleMap.view.foregroundColor - font.pointSize: units.fs("small") - maximumLineCount: 3 - width: parent.width - wrapMode: Text.WrapAnywhere - } - } - } -} diff --git a/gui/controls2_509/TrackCollection.qml b/gui/controls2_509/TrackCollection.qml deleted file mode 100644 index 119ddeea..00000000 --- a/gui/controls2_509/TrackCollection.qml +++ /dev/null @@ -1,490 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import Osmin 1.0 -import "./components" -import "../toolbox.js" as ToolBox - -MapPage { - id: trackCollection - pageTitle: qsTr("Track Collection") - pageFlickable: availableList - isRoot: (availableList.tree.length === 0) - onGoUpClicked: { - var v = availableList.tree.slice(1, availableList.tree.length); - availableList.tree = v; - } - - property var mapView: null - - signal showPosition(double lat, double lon) - - Component.onCompleted: { - GPXListModel.loadData(); - } - - MapListView { - id: availableList - contentHeight: units.gu(8) - width: parent.width - height: parent.height - mapPreview.height - - property var tree: [] - - model: DelegateModel { - id: delegateModel - model: GPXListModel - rootIndex : availableList.tree.length > 0 ? availableList.tree[0].index : null - - delegate: MouseArea { - id: availableMapItem - width: availableList.width - height: fileView.height - - GPXFileModel { - id: fileModel - onParseFinished: { - // caller wait for signal loaded(bool) - loadData(); - // on failure show alert - if (!succeeded) { - dialogAlert.title = name - dialogAlert.text = qsTr("Parsing file has failed. The format is not supported or data are corrupted."); - dialogAlert.open(); - } - } - } - - ListView { - id: fileView - width: parent.width - units.gu(6) - height: contentHeight - interactive: false - model: fileModel - - header: Row { - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - height: Math.max(units.gu(8), implicitHeight) - - MapCheckBox { - id: display - visible: !model.dir - anchors.verticalCenter: parent.verticalCenter - width: units.gu(5) - color: styleMap.view.foregroundColor - checked: false - onClicked: { - if (display.checked) { - mapView.removeCourse(); - if (!fileModel.fileValid) { - ToolBox.connectOnce(fileModel.loaded, function(succeeded){ - if (succeeded) - mapView.addCourse(bigId, fileModel.createOverlayObjects()); - else - display.checked = false; - }); - fileModel.parseFile(model.absoluteFilePath); - } else { - fileModel.loadData(); - mapView.addCourse(bigId, fileModel.createOverlayObjects()); - } - } else { - mapView.removeCourse(); - } - } - Component.onCompleted: { - display.checked = (mapView.courseId === bigId); - } - Connections { - target: mapView - onCourseIdChanged: { - display.checked = (mapView.courseId === bigId); - } - } - } - - MapIcon { - id: folderIcon - visible: model.dir - anchors.verticalCenter: parent.verticalCenter - height: units.gu(5) - source: "qrc:/images/go-next.svg" - onClicked: optionsMenu.open() - enabled: false - } - - Column { - width: parent.width - units.gu(5) - anchors.verticalCenter: parent.verticalCenter - Label { - width: parent.width - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - font.bold: dir - text: name - elide: Text.ElideRight - } - Label { - visible: !dir - width: parent.width - height: visible ? implicitHeight : 0 - color: styleMap.view.secondaryColor - font.pointSize: units.fs("x-small") - text: fileModel.parsing ? (Math.round(fileModel.progress * 1000) / 10).toFixed(1) + " %" - : timestamp.toLocaleDateString() + " " + timestamp.toLocaleTimeString() - } - Label { - visible: text !== "" - height: visible ? implicitHeight : 0 - color: styleMap.view.secondaryColor - font.pointSize: units.fs("x-small") - text: fileModel.description - wrapMode: Text.WordWrap - } - } - - MapIcon { - id: menu - anchors.verticalCenter: parent.verticalCenter - width: units.gu(5) - height: width - source: "qrc:/images/contextual-menu.svg" - onClicked: optionsMenu.open() - visible: (path !== "." || name !== "TRACKER") - - Menu { - id: optionsMenu - width: implicitWidth * units.scaleFactor - x: parent.width - width - transformOrigin: Menu.TopRight - MenuItem { - text: qsTr("Rename") - font.pointSize: units.fs("medium") - onTriggered: { - if (display.checked) - mapView.removeCourse(); - dialogEdit.model = model; - dialogEdit.open(); - ToolBox.connectOnce(dialogEdit.requestUpdate, renameItem); - } - function renameItem(model, newValue) { - if (model) { - var index = null; - if (availableList.tree.length > 0) - index = GPXListModel.index(model.index, 0, availableList.tree[0].index); - else - index = GPXListModel.index(model.index, 0); - GPXListModel.renameItem(newValue, index); - } - } - } - MenuItem { - text: qsTr("Delete") - font.pointSize: units.fs("medium") - onTriggered: { - dialogAction.title = model.dir ? qsTr("Delete folder ?") : qsTr("Delete file ?"); - dialogAction.text = model.name; - dialogAction.open(); - ToolBox.connectOnce(dialogAction.reply, deleteItem); - } - function deleteItem(accepted) { - if (accepted) { - if (display.checked) - mapView.removeCourse(); - var index = null; - if (availableList.tree.length > 0) - index = GPXListModel.index(model.index, 0, availableList.tree[0].index); - else - index = GPXListModel.index(model.index, 0); - GPXListModel.removeItem(index); - } - } - } - } - } - } - - delegate: Item { - width: fileRow.implicitWidth - height: fileRow.implicitHeight - Row { - id: fileRow - MapIcon { - id: poi - anchors.verticalCenter: parent.verticalCenter - color: type === 0 && displayColor !== "" ? displayColor : styleMap.view.foregroundColor - width: units.gu(6) - height: units.gu(6) - enabled: false - source: type === 0 ? "qrc:/images/trip/segment.svg" - : symbol === "Bar" ? "qrc:/images/poi/bar.svg" - : symbol === "Campground" ? "qrc:/images/poi/campsite.svg" - : symbol === "Gas Station" ? "qrc:/images/poi/fuel.svg" - : symbol === "Lodging" ? "qrc:/images/poi/lodging.svg" - : symbol === "Restaurant" ? "qrc:/images/poi/restaurant.svg" - : symbol === "Skull and Crossbones" ? "qrc:/images/poi/danger.svg" - : symbol === "Car Repair" ? "qrc:/images/poi/car.svg" - : "qrc:/images/poi/marker.svg" - } - Column { - anchors.verticalCenter: parent.verticalCenter - width: fileView.width - spacing: 0 - - Label { - text: name - color: styleMap.view.primaryColor - font.pointSize: units.fs("medium") - } - Label { - visible: text !== "" - height: visible ? implicitHeight : 0 - text: type === 0 ? Converter.readableDistance(length) : "" /*symbol*/ - color: styleMap.view.secondaryColor - font.pointSize: units.fs("medium") - } - } - } - MouseArea { - anchors.fill: parent - onClicked: { - // show the map preview - if (type === 1) // waypoint - selectedPOI = { "lat": lat, "lon": lon, "label": name, "elevation": elevation }; - } - } - } - } - - Rectangle { - anchors.fill: parent - visible: ((index & 1) === 1) - color: styleMap.view.highlightedColor - opacity: 0.05 - } - - BusyIndicator { - id: loadingIndicator - running: fileModel.parsing - height: units.gu(6) - anchors.centerIn: parent - visible: running - } - - onClicked: { - if (model.dir) { - var v = availableList.tree.slice(); - if (availableList.tree.length > 0) { - v.splice(0, 0, { "index": GPXListModel.index(model.index, 0, availableList.tree[0].index), "name": model.name }); - } else { - v.splice(0, 0, { "index": GPXListModel.index(model.index, 0), "name": model.name }); - } - availableList.tree = v; - } else { - // show/hide details - if (!fileModel.fileValid) { - fileModel.parseFile(model.absoluteFilePath); - } else if (fileModel.count === 0) { - fileModel.loadData(); - } else { - fileModel.clearData(); - } - } - } - } - } - } - - property var selectedPOI: null - - Loader { - id: mapPreview - // active the preview on selection - active: selectedPOI !== null - height: active ? parent.height / 2 : 0 - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - asynchronous: true - sourceComponent: Item { - id: preview - anchors.fill: parent - property alias map: map - Map { - id: map - showCurrentPosition: true - anchors.fill: parent - } - - Rectangle { - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - color: "white" - opacity: 0.7 - height: about.height - Column { - id: about - anchors.left: parent.left - anchors.right: parent.right - padding: units.gu(1) - Label { - width: parent.width - font.pointSize: units.fs("medium") - font.bold: true - color: "black" - elide: Text.ElideRight - text: selectedPOI.label - } - Label { - width: parent.width - font.pointSize: units.fs("small") - color: "black" - elide: Text.ElideRight - text: Converter.readableCoordinatesNumeric(selectedPOI.lat, selectedPOI.lon) + - (selectedPOI.elevation > 0 ? " Δ " + Converter.panelElevation(selectedPOI.elevation) : "") + - " | " + Converter.readableCoordinatesGeocaching(selectedPOI.lat, selectedPOI.lon) - } - } - } - MapIcon { - id: buttonShowPosition - anchors.top: parent.top - anchors.left: parent.left - anchors.margins: units.gu(1) - source: "qrc:/images/trip/here.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.0) - opacity: 0.7 - height: units.gu(6) - onClicked: { - showPosition(selectedPOI.lat, selectedPOI.lon); - stackView.pop(); - } - } - MapIcon { - id: buttonClose - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: units.gu(1) - source: "qrc:/images/close.svg" - color: "black" - backgroundColor: "white" - borderPadding: units.gu(1.5) - opacity: 0.7 - height: units.gu(6) - onClicked: { - selectedPOI = null; // deactivate the preview - } - } - } - - onStatusChanged: { - if (active && status === Loader.Ready) { - console.log("Activate map preview"); - trackCollection.selectedPOIChanged.connect(showSelectedLocation); - showSelectedLocation(); - } else if (!active) { - console.log("Deactivate map preview"); - trackCollection.selectedPOIChanged.disconnect(showSelectedLocation); - } - } - - function showSelectedLocation() { - console.log("Show selected location on map preview"); - item.map.showCoordinatesInstantly(selectedPOI.lat, selectedPOI.lon); - item.map.addPositionMark(0, selectedPOI.lat, selectedPOI.lon); - item.map.removeAllOverlayObjects(); - } - - Behavior on height { - NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } - } - } - - DialogBase { - id: dialogEdit - title: qsTr("Rename") - - property var model: null - - signal requestUpdate(var model, var newValue) - - onClosed: { - if (result === Dialog.Accepted) { - var newValue = inputLabel.text.trim(); - if (newValue.length > 0) { - if (!model.dir) - newValue += ".gpx"; - requestUpdate(model, newValue); - } else - requestUpdate(null, ""); - } else { - // caller is waiting the signal - requestUpdate(null, ""); - } - } - - footer: Row { - leftPadding: units.gu(1) - rightPadding: units.gu(1) - bottomPadding: units.gu(1) - spacing: units.gu(1) - layoutDirection: Qt.RightToLeft - - Button { - flat: true - text: qsTr("Ok") - onClicked: { - dialogEdit.accept(); - } - } - } - - TextField { - id: inputLabel - font.pointSize: units.fs("medium") - placeholderText: qsTr("Enter the name") - inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhUrlCharactersOnly - EnterKey.type: Qt.EnterKeyDone - } - - onOpened: { - result = Dialog.Rejected; - var name = model.name; - var p = name.lastIndexOf("."); - if (p >= 0) - name = name.substr(0, p); - inputLabel.text = name; - inputLabel.forceActiveFocus(); - } - } - - DialogAction { - id: dialogAction - } - - DialogAlert { - id: dialogAlert - } -} diff --git a/gui/controls2_509/Tracking.qml b/gui/controls2_509/Tracking.qml deleted file mode 100644 index 9d83b8ab..00000000 --- a/gui/controls2_509/Tracking.qml +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import Osmin 1.0 -import "./components" - -PopOver { - id: tracking - - title: qsTr("Tracking") - contents: Column { - spacing: units.gu(2) - - Column { - width: parent.width - spacing: units.gu(1) - Row { - width: parent.width - spacing: units.gu(2) - Label { - width: parent.width / 2 - text: qsTr("Average Speed") - font.pointSize: units.fs("large") - color: styleMap.popover.highlightedColor - } - Label { - id: avgSpeed - text: Converter.readableSpeed(Tracker.duration < 1 ? 0 : 3.6 * Tracker.distance/Tracker.duration) - font.pointSize: units.fs("large") - color: foregroundColor - } - } - Row { - width: parent.width - spacing: units.gu(2) - Label { - width: parent.width / 2 - text: qsTr("Duration") - font.pointSize: units.fs("large") - color: styleMap.popover.highlightedColor - } - Label { - id: duration - text: Converter.panelDurationHMS(Tracker.duration) - font.pointSize: units.fs("large") - color: foregroundColor - } - } - Row { - width: parent.width - spacing: units.gu(2) - Label { - width: parent.width / 2 - text: qsTr("Distance") - font.pointSize: units.fs("large") - color: styleMap.popover.highlightedColor - } - Label { - id: distance - text: Converter.readableDistance(Tracker.distance) - font.pointSize: units.fs("large") - color: foregroundColor - } - } - Row { - width: parent.width - spacing: units.gu(2) - Label { - width: parent.width / 2 - text: qsTr("Ascent") - font.pointSize: units.fs("large") - color: styleMap.popover.highlightedColor - } - Label { - id: ascent - text: Converter.readableDistance(Tracker.ascent) - font.pointSize: units.fs("large") - color: foregroundColor - } - } - Row { - width: parent.width - spacing: units.gu(2) - Label { - width: parent.width / 2 - text: qsTr("Descent") - font.pointSize: units.fs("large") - color: styleMap.popover.highlightedColor - } - Label { - id: descent - text: Converter.readableDistance(Tracker.descent) - font.pointSize: units.fs("large") - color: foregroundColor - } - } - Row { - width: parent.width - spacing: units.gu(2) - Label { - width: parent.width / 2 - text: qsTr("Maximum Speed") - font.pointSize: units.fs("large") - color: styleMap.popover.highlightedColor - } - Label { - id: maxSpeed - text: Converter.readableSpeed(Tracker.maxSpeed) - font.pointSize: units.fs("large") - color: foregroundColor - } - } - } - - Column { - width: parent.width - MapIcon { - source: "qrc:/images/record.svg" - color: Tracker.recording !== "" ? "red" : foregroundColor - height: units.gu(6) - label.text: " " + (Tracker.recording !== "" ? qsTr("Cut track recording") : qsTr("Start track recording")) - label.color: foregroundColor - label.font.pointSize: units.fs("medium") - label.elide: Text.ElideRight - label.width: parent.width - units.gu(7) - onClicked: { - Tracker.startRecording(); - } - enabled: !Tracker.processing - animationRunning: Tracker.processing - animationInterval: 200 - } - } - - Column { - width: parent.width - MapIcon { - source: "qrc:/images/save.svg" - color: foregroundColor - height: units.gu(6) - label.text: " " + qsTr("Close track recording") - label.color: foregroundColor - label.font.pointSize: units.fs("medium") - label.elide: Text.ElideRight - label.width: parent.width - units.gu(7) - onClicked: { - Tracker.stopRecording(); - } - enabled: Tracker.recording !== "" - opacity: enabled ? 1.0 : 0.5 - } - } - - Column { - width: parent.width - MapIcon { - source: "qrc:/images/reset.svg" - color: foregroundColor - height: units.gu(6) - label.text: " " + qsTr("Reset statistics") - label.color: foregroundColor - label.font.pointSize: units.fs("medium") - label.elide: Text.ElideRight - label.width: parent.width - units.gu(7) - onClicked: { - Tracker.reset(); - } - enabled: Tracker.recording === "" - opacity: enabled ? 1.0 : 0.5 - } - } - } -} diff --git a/gui/controls2_509/Welcome.qml b/gui/controls2_509/Welcome.qml deleted file mode 100644 index 86a593ea..00000000 --- a/gui/controls2_509/Welcome.qml +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import "./components" - -MapPage { - id: welcomePage - objectName: "welcomePage" - pageTitle: qsTr("Welcome") - - // Overlay to show when no map is installed - Rectangle { - id: downloadLauncher - anchors { - fill: parent - } - color: styleMap.view.backgroundColor - - Column { - anchors { - centerIn: parent - } - spacing: units.gu(4) - width: parent.width > units.gu(44) ? parent.width - units.gu(8) : units.gu(36) - - Image { - anchors.horizontalCenter: parent.horizontalCenter - antialiasing: true - fillMode: Image.PreserveAspectFit - height: units.gu(10) - smooth: true - source: "qrc:/images/osmin.png" - } - - Label { - anchors.horizontalCenter: parent.horizontalCenter - color: styleMap.view.foregroundColor - font.pointSize: units.fs("medium") - horizontalAlignment: Text.AlignHCenter - text: "OSMin " + VersionString - } - - Label { - color: styleMap.view.foregroundColor - elide: Text.ElideRight - font.pointSize: units.fs("large") - horizontalAlignment: Text.AlignHCenter - maximumLineCount: 10 - text: qsTr("First of all to use OSMin, you need to download the map of your region. " + - "Online maps are not activated with this software, in order to better assist " + - "you in navigating outside the areas covered by a network.") - width: parent.width - wrapMode: Text.WordWrap - } - - MapIcon { - anchors.horizontalCenter: parent.horizontalCenter - source: "qrc:/images/download.svg" - color: styleMap.view.foregroundColor - height: units.gu(6) - label.text: qsTr("Download Maps") - label.color: styleMap.view.foregroundColor - label.font.pointSize: units.fs("medium") - onClicked: { - stackView.pop(); - stackView.push("qrc:/controls2/MapDownloads.qml"); - } - } - } - } -} diff --git a/gui/controls2_509/components/ActivitySpinner.qml b/gui/controls2_509/components/ActivitySpinner.qml deleted file mode 100644 index b6ff6a02..00000000 --- a/gui/controls2_509/components/ActivitySpinner.qml +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Item { - id: loading - height: units.gu(12) - width: parent.width - visible: false - - anchors.centerIn: parent - - BusyIndicator { - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - running: loading.visible - height: parent.height - width: height - opacity: 0.9 - z: 1 - } -} diff --git a/gui/controls2_509/components/CompassSensor.qml b/gui/controls2_509/components/CompassSensor.qml deleted file mode 100644 index d7b0b206..00000000 --- a/gui/controls2_509/components/CompassSensor.qml +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.0 -import QtQml 2.2 -//import QtSensors 5.2 as Legacy -import Osmin 1.0 as Osmin - -Item { - id: compass - - property bool active: true - property real calibration: 0.0 // Default to 0% - property real azimuth: 0.0 // current azimuth in degrees - property real direction: 0.0 // the orienteering direction set by user, 0-359.99 degrees - property bool rightDirection: false // (diff < 4.0) - property real magneticDip: 0.0 - - property real __normalDirection: normalize360(direction) // 0-359.99 degrees for sure - property real scaledDirection: scaleAngle(direction) - property real scaledAzimuth: scaleAngle(azimuth) - property real compassScaleVal: 360 // default, bound to settings later from outside - - function normalize360(angle) { - var semiNormalized = angle % 360 - return semiNormalized < 0 ? 360 + semiNormalized : semiNormalized - } - function scaleAngle(angle360) { - return angle360 / 360 * compassScaleVal - } - - Osmin.Compass { - id: compassBuiltin - active: compass.active - onReadingChanged: { - var n = normalize360(reading.azimuth + magneticDip); - compass.azimuth = n; - var d = Math.abs(n - compass.__normalDirection); - compass.rightDirection = d < 4.0 || d > 356.0; - compass.calibration = reading.calibrationLevel; - } - Component.onCompleted: { connectToService(Osmin.Service.getServiceHandle()) } - } -} diff --git a/gui/controls2_509/components/DialogAction.qml b/gui/controls2_509/components/DialogAction.qml deleted file mode 100644 index f1f111ea..00000000 --- a/gui/controls2_509/components/DialogAction.qml +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -DialogBase { - id: dialog - - // note: connect the signal reply(bool) to process the response - signal reply(bool accepted) - - onClosed: { - reply((result === Dialog.Accepted)); - } - onOpened: { - result = Dialog.Rejected; - } - - footer: Row { - leftPadding: units.gu(1) - rightPadding: units.gu(1) - bottomPadding: units.gu(1) - spacing: units.gu(1) - layoutDirection: Qt.RightToLeft - - Button { - flat: true - text: qsTr("Ok") - onClicked: { - dialog.accept(); - } - } - Button { - flat: true - text: qsTr("Cancel") - onClicked: { - dialog.reject(); - } - } - } -} diff --git a/gui/controls2_509/components/DialogAlert.qml b/gui/controls2_509/components/DialogAlert.qml deleted file mode 100644 index ca285168..00000000 --- a/gui/controls2_509/components/DialogAlert.qml +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -DialogBase { - id: dialog - - footer: Row { - leftPadding: units.gu(1) - rightPadding: units.gu(1) - bottomPadding: units.gu(1) - spacing: units.gu(1) - layoutDirection: Qt.RightToLeft - - Button { - flat: true - text: qsTr("Ok") - onClicked: { - dialog.close(); - } - } - } -} diff --git a/gui/controls2_509/components/DialogBase.qml b/gui/controls2_509/components/DialogBase.qml deleted file mode 100644 index c4ee6618..00000000 --- a/gui/controls2_509/components/DialogBase.qml +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2017 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Dialog { - id: dialog - - /*! - \qmlproperty list contents - Content will be put inside a column in the foreround of the Dialog. - */ - default property alias contents: contentsColumn.data - - /*! - The property holds the margins from the dialog's dismissArea. - */ - property real edgeMargins: units.gu(2) - - /*! - The property controls whether the dialog is modal or not. Modal dialogs block - event propagation to items under dismissArea, when non-modal ones let these - events passed to these items. In addition, non-modal dialogs do not dim the - dismissArea. - - The default value is true. - */ - modal: true - - /*! - Grab focus when Dialog is shown - */ - focus: true - - - /*! - The question to the user. - \qmlproperty string text - */ - property string text - - property real minimumWidth: units.gu(minSizeGU - 2) - property real minimumHeight: Math.max(160, units.gu(20)) - property real contentSpacing: units.gu(1) - - x: Math.round((mainView.width - width) / 2) - y: Math.round((mainView.height - (height + header.height + footer.height)) / 2) - width: Math.max(Math.round(Math.min(mainView.width, mainView.height) / 3 * 2), dialog.minimumWidth) - readonly property real h: contentsColumn.height + units.gu(6) + - dialog.header.height + dialog.footer.height - height: Math.max(Math.min(h, Math.round(mainView.height / 4 * 3)), dialog.minimumHeight) - - Rectangle { - id: background - color: "transparent" - anchors.fill: parent - anchors.margins: dialog.edgeMargins - } - - Flickable { - anchors.fill: parent - anchors.leftMargin: dialog.edgeMargins - contentWidth: contentsColumn.width - contentHeight: contentsColumn.height - boundsBehavior: Flickable.StopAtBounds - clip: true - - ScrollBar.vertical: ScrollBar { - policy: ScrollBar.AlwaysOn - visible: (parent.visibleArea.heightRatio < 1.0) - } - - Column { - id: contentsColumn - spacing: dialog.contentSpacing - width: background.width - onWidthChanged: updateChildrenWidths(); - - Text { - horizontalAlignment: Text.AlignHCenter - text: dialog.text - font.pointSize: units.fs("medium") - color: styleMap.dialog.foregroundColor - wrapMode: Text.Wrap - visible: (text !== "") - } - - onChildrenChanged: updateChildrenWidths() - - function updateChildrenWidths() { - for (var i = 0; i < children.length; i++) { - children[i].width = contentsColumn.width; - } - } - } - } -} diff --git a/gui/controls2_509/components/DialogEnter.qml b/gui/controls2_509/components/DialogEnter.qml deleted file mode 100644 index 0c3b0ffa..00000000 --- a/gui/controls2_509/components/DialogEnter.qml +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2022 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -DialogBase { - id: dialog - property alias userEntry: textField.text - - // note: connect the signal reply(bool, entry) to process the response - signal reply(bool accepted, string entry) - - onClosed: { - reply((result === Dialog.Accepted), textField.text); - } - onOpened: { - result = Dialog.Rejected; - } - - footer: Row { - leftPadding: units.gu(1) - rightPadding: units.gu(1) - bottomPadding: units.gu(1) - spacing: units.gu(1) - layoutDirection: Qt.RightToLeft - - Button { - flat: true - text: qsTr("Ok") - onClicked: { - dialog.accept(); - } - focus: true - } - Button { - flat: true - text: qsTr("Cancel") - onClicked: { - dialog.reject(); - } - } - } - - TextField { - id: textField - anchors { - left: parent.left - right: parent.right - } - inputMethodHints: Qt.ImhNoPredictiveText - font.pointSize: units.fs("medium") - Keys.onReturnPressed: dialog.accept() - } -} diff --git a/gui/controls2_509/components/DialogMarkPosition.qml b/gui/controls2_509/components/DialogMarkPosition.qml deleted file mode 100644 index d2161fd7..00000000 --- a/gui/controls2_509/components/DialogMarkPosition.qml +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -DialogBase { - id: dialog - title: qsTr("Mark position") - - // { symbol, name } - property var model: ({}) - - // note: connect the signal reply(var) to process the response - signal reply(var model) - - onClosed: { - if (result === Dialog.Accepted) { - var txt = inputName.text.trim(); - if (txt.length > 0) - model.name = txt; - model.symbol = markersModel.get(symbols.currentIndex).symbol; - reply(model); - } else { - // caller is waiting the signal - reply(null); - } - } - - footer: Row { - leftPadding: units.gu(1) - rightPadding: units.gu(1) - bottomPadding: units.gu(1) - spacing: units.gu(1) - layoutDirection: Qt.RightToLeft - - Button { - flat: true - text: qsTr("Ok") - onClicked: { - dialog.accept(); - } - } - } - - TextField { - id: inputName - font.pointSize: units.fs("medium") - placeholderText: qsTr("Enter the name") - inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhUrlCharactersOnly - EnterKey.type: Qt.EnterKeyDone - } - - ListModel { - id: markersModel - ListElement { symbol: "Pin, Red"; iconSource: "qrc:/images/trip/marker.svg"; iconColor: "red" } - ListElement { symbol: "Pin, Green"; iconSource: "qrc:/images/trip/marker.svg"; iconColor: "green" } - ListElement { symbol: "Pin, Blue"; iconSource: "qrc:/images/trip/marker.svg"; iconColor: "blue" } - ListElement { symbol: "Restaurant"; iconSource: "qrc:/images/poi/restaurant.svg"; } - ListElement { symbol: "Bar"; iconSource: "qrc:/images/poi/bar.svg"; } - ListElement { symbol: "Lodging"; iconSource: "qrc:/images/poi/lodging.svg" } - ListElement { symbol: "Campground"; iconSource: "qrc:/images/poi/campsite.svg" } - ListElement { symbol: "Car Repair"; iconSource: "qrc:/images/poi/car.svg"; } - ListElement { symbol: "Gas Station"; iconSource: "qrc:/images/poi/fuel.svg"; } - ListElement { symbol: "Skull and Crossbones"; iconSource: "qrc:/images/poi/danger.svg"; } - } - - Rectangle { - width: parent.width - height: units.gu(8) - color: "transparent" - Tumbler { - id : symbols - anchors.centerIn: parent - rotation: -90 - height: parent.width - width: units.gu(8) - model : markersModel - - delegate: Item { - property bool selected: (index === symbols.currentIndex) - Rectangle { - anchors.fill: parent - color: styleMap.view.highlightedColor - opacity: selected ? 0.3 : 0.0 - } - MapIcon { - anchors.centerIn: parent - rotation: 90 - height: units.gu(6) - enabled: true - source: iconSource - color: iconColor !== undefined ? iconColor : styleMap.dialog.foregroundColor - onClicked: { - symbols.currentIndex = index; - } - } - } - } - } - - onOpened: { - // reset dialog result - result = Dialog.Rejected; - // preset inputs - if (model.name !== undefined) - inputName.text = model.name + " "; - if (model.symbol !== undefined) { - for (var i = 0; i < markersModel.count; ++i) { - if (markersModel.get(i).symbol === model.symbol) { - symbols.currentIndex = i; - break; - } - } - } - } -} diff --git a/gui/controls2_509/components/MapCheckBox.qml b/gui/controls2_509/components/MapCheckBox.qml deleted file mode 100644 index ed8ecd70..00000000 --- a/gui/controls2_509/components/MapCheckBox.qml +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.2 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Item { - id: control - property color color: styleMap.view.foregroundColor - property color controlDownColor: styleMap.view.highlightedColor - property real zoom: 1.0 - property alias text: label.text - property alias font: label.font - property alias textAlignment: label.horizontalAlignment - property bool checked: false - property alias down: area.pressed - property alias checkable: area.enabled - - signal clicked(bool checked) - - height: units.gu(5.0 * zoom) - width: height - opacity: checkable ? 1.0 : 0.1 - - Text { - id: label - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - width: parent.width - indicator.width - units.gu(2.0 * zoom) - text: "" - font.pointSize: units.fs("medium") - opacity: enabled ? 1.0 : 0.3 - color: control.down ? control.controlDownColor : control.color - elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } - - Rectangle { - id: indicator - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.margins: units.gu(1.0 * zoom) - height: parent.height - units.gu(2.0 * zoom) - width: height - radius: height / 2 - color: "transparent" - border.color: control.down ? control.controlDownColor : control.color - - Rectangle { - width: units.gu(2.0 * zoom) - height: units.gu(2.0 * zoom) - x: units.gu(0.5 * zoom) - y: units.gu(0.5 * zoom) - radius: height / 2 - color: control.down ? control.controlDownColor : control.color - visible: control.checked - } - } - - MouseArea { - id: area - anchors.fill: parent - anchors.margins: -units.gu(1.0 * zoom) - - onClicked: { - control.checked = !control.checked; - control.clicked(control.checked); - } - } -} diff --git a/gui/controls2_509/components/MapIcon.qml b/gui/controls2_509/components/MapIcon.qml deleted file mode 100644 index ab353b1a..00000000 --- a/gui/controls2_509/components/MapIcon.qml +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtGraphicalEffects 1.0 - -MouseArea { - id: area - property alias source: icon.source - property alias label: label - property color color: styleMap.view.foregroundColor - property color backgroundColor: "transparent" - property color pressedColor: styleMap.view.highlightedColor - property alias animationRunning: icon.animationRunning - property int animationInterval: 500 // slow flashing - property alias iconSize: icon.height - property real borderPadding: units.gu(1) - readonly property real implicitWidth: row.width + 2 * borderPadding - width: implicitWidth - height: units.gu(5) - enabled: true - visible: true - hoverEnabled: enabled && visible - - Rectangle { - id: background - anchors.fill: parent - color: backgroundColor - radius: height / 2 - } - - Row { - id: row - spacing: label.text !== "" ? units.gu(0.5) : 0 - height: parent.height - visible: false - anchors.centerIn: parent - - Image { - id: icon - anchors.verticalCenter: parent.verticalCenter - height: parent.height < units.gu(3) ? parent.height : parent.height - 2 * borderPadding - width: area.visible ? height : 0 - sourceSize.height: height - sourceSize.width: width - source: "qrc:/images/delete.svg" - - property bool animationRunning: false - - onAnimationRunningChanged: { - if (animationRunning) { - if (!animator.running) - animator.savedOpacity = area.opacity; - animator.start(); - } else - animator.stop(); - } - - Timer { - id: animator - interval: area.animationInterval - repeat: true - property real savedOpacity: 1.0 - onTriggered: { - opacity = (opacity === 0.0 ? savedOpacity : 0.0); - } - onRunningChanged: opacity = savedOpacity // reset opacity on stop - } - - Behavior on opacity { - NumberAnimation { duration: area.animationInterval / 2 } - } - } - - Label { - id: label - anchors.verticalCenter: parent.verticalCenter - width: text !== "" && area.visible ? implicitWidth + units.gu(0.5) : 0 - font.pointSize: units.fs("medium") - } - } - - Rectangle { - id: iconFill - visible: false - anchors.fill: row - color: parent.pressed ? parent.pressedColor : parent.color - } - - OpacityMask { - anchors.fill: iconFill - source: iconFill - maskSource: row - } - - Rectangle { - id: ripple - readonly property bool square: area.implicitWidth <= area.implicitHeight - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - clip: !square - width: parent.width - height: parent.height - radius: height / 2 - color: area.color - opacity: 0 - - Behavior on opacity { - NumberAnimation { duration: 100 } - } - } - - onEntered: ripple.opacity = 0.1 - onExited: ripple.opacity = 0 - onReleased: ripple.opacity = 0 -} diff --git a/gui/controls2_509/components/MapListView.qml b/gui/controls2_509/components/MapListView.qml deleted file mode 100644 index aa21f3b5..00000000 --- a/gui/controls2_509/components/MapListView.qml +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -ListView { - Component.onCompleted: { - // Return values depending on the grid unit definition - // for Flickable.maximumFlickVelocity and Flickable.flickDeceleration - var scaleFactor = units.scaleFactor; - maximumFlickVelocity = maximumFlickVelocity * scaleFactor; - flickDeceleration = flickDeceleration * scaleFactor; - } - - ScrollBar.vertical: ScrollBar {} -} diff --git a/gui/controls2_509/components/MapPage.qml b/gui/controls2_509/components/MapPage.qml deleted file mode 100644 index abf1ebc5..00000000 --- a/gui/controls2_509/components/MapPage.qml +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQml 2.2 - -// generic page for map -Page { - id: thisPage - - property string pageTitle: "" - property Flickable pageFlickable: null - property bool isRoot: true // by default this page is root - property bool showFooter: false // by default don't show the footer bar - property bool showHeader: true // by default show the header bar - - property alias optionsMenuVisible: optionsMenu.visible - property alias optionsMenuContentItems: optionsMenuPopup.contentData - - signal popped // action for root page - signal goUpClicked // action for a non-root page - signal searchClicked - - Item { - id: footer - height: units.gu(6) - anchors.bottom: parent.bottom - anchors.bottomMargin: showFooter ? 0 : - height - anchors.left: parent.left - anchors.right: parent.right - z: 99 - - Behavior on anchors.bottomMargin { - NumberAnimation { duration: 300; easing.type: Easing.OutBack; } - } - - Rectangle { - id: footerBar - anchors.fill: parent - color: "transparent" - - Rectangle { - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: units.gu(1) - anchors.rightMargin: units.gu(1) - height: units.gu(5) - color: "transparent" - - Item { - id: optionsMenu - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - width: units.gu(4) - height: parent.height - visible: false - - MapIcon { - width: units.gu(5) - height: width - anchors.centerIn: parent - source: "qrc:/images/contextual-menu.svg" - - onClicked: optionsMenuPopup.open() - enabled: parent.visible - - Menu { - id: optionsMenuPopup - x: parent.width - width - transformOrigin: Menu.TopRight - } - } - } - } - } - } -} diff --git a/gui/controls2_509/components/MapPosition.qml b/gui/controls2_509/components/MapPosition.qml deleted file mode 100644 index 545a177d..00000000 --- a/gui/controls2_509/components/MapPosition.qml +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.2 -import Osmin 1.0 as Osmin - -Osmin.PositionSource { - id: positionSource - property double _lat: 0.0 - property double _lon: 0.0 - property double _alt: 0.0 - property real _acc: 0.0 - property bool _posValid: false - property bool _accValid: false - - signal dataUpdated(bool valid, double lat, double lon, bool accValid, real acc, double alt) - - onPositionChanged: { - _lat = position.latitude; - _lon = position.longitude; - _alt = position.altitude; - _acc = position.horizontalAccuracy; - _posValid = position.valid; - _accValid = position.horizontalAccuracyValid; - dataUpdated(_posValid, _lat, _lon, _accValid, _acc, _alt); - } - - active: true - - Component.onCompleted: { connectToService(Osmin.Service.getServiceHandle()) } -} diff --git a/gui/controls2_509/components/MapRotator.qml b/gui/controls2_509/components/MapRotator.qml deleted file mode 100644 index 58aacc11..00000000 --- a/gui/controls2_509/components/MapRotator.qml +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.2 -import QtQml 2.2 -import Osmin 1.0 - -Item { - property Map map - signal begin - signal finished - - readonly property alias isRunning: worker.running - - function rotateTo(angle, lockToPosition) { - worker.stop(); - worker.angle = Math.round(angle * 1000.0); - worker.lockToPosition = (lockToPosition ? true : false); - worker.start(); - begin(); - } - - function stop() { - worker.stop(); - finished(); - } - - Timer { - id: worker - interval: 1000 - repeat: true - triggeredOnStart: true - property int angle: 0 // milli rad - property bool lockToPosition: false - onTriggered: { - if (Math.round(map.view.angle * 1000.0) != angle) { - map.rotateTo(0.001 * angle); - } else { - stop(); - finished(); - } - } - onRunningChanged: { - if (!running && lockToPosition) - map.lockToPosition = true; - } - } -} diff --git a/gui/controls2_509/components/MapVoice.qml b/gui/controls2_509/components/MapVoice.qml deleted file mode 100644 index 7f0cf07f..00000000 --- a/gui/controls2_509/components/MapVoice.qml +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQml 2.2 -import Osmin 1.0 - -Item { - readonly property alias voiceValid: internal.voiceValid - readonly property alias voiceName: internal.voiceName - readonly property alias voiceId: internal.voiceId - readonly property alias voiceLang: internal.voiceLang - readonly property alias voiceGender: internal.voiceGender - readonly property alias voiceLicense: internal.voiceLicense - - signal voiceSelected() - - function select(name) { - for (var i = 0; i < voiceModel.rowCount(); ++i) { - if (name === voiceModel.data(voiceModel.index(i, 0), InstalledVoicesModel.NameRole)) { - internal.select(i); - console.log("Selected voice: \"" + voiceName + "\""); - return true; - } - } - return false; - } - - function testVoice() { - if (voiceValid) { - var indexObj = voiceModel.index(voiceId, 0); - var samples = ["Arrive.ogg"]; - voiceModel.playSample(indexObj, samples); - } - } - - InstalledVoicesModel { - id: voiceModel - } - - QtObject { - id: internal - property bool voiceValid: false - property string voiceName - property int voiceId - property string voiceLang - property string voiceGender - property string voiceLicense - - function select(row) { - var index = voiceModel.index(row, 0); - voiceModel.select(index); - if (voiceModel.data(index, InstalledVoicesModel.SelectedRole)) { - voiceId = row; - voiceName = voiceModel.data(index, InstalledVoicesModel.NameRole); - voiceLang = voiceModel.data(index, InstalledVoicesModel.LangRole); - voiceGender = voiceModel.data(index, InstalledVoicesModel.GenderRole); - voiceLicense = voiceModel.data(index, InstalledVoicesModel.LicenseRole); - voiceValid = (row > 0 ? voiceModel.data(index, InstalledVoicesModel.ValidRole) : false); - voiceSelected(); - } - } - } - - Component.onCompleted: { - // get first available as default - if (voiceModel.rowCount() > 1 && !select(settings.voiceName)) { - internal.select(1); - console.log("Selected voice: \"" + voiceName + "\""); - } - } -} diff --git a/gui/controls2_509/components/Navigator.qml b/gui/controls2_509/components/Navigator.qml deleted file mode 100644 index dbab61df..00000000 --- a/gui/controls2_509/components/Navigator.qml +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.2 -import QtQml 2.2 -import Osmin 1.0 - -Item { - id: navigator - - property MapPosition position - property OverlayManager overlayManager - readonly property bool ready: !suspended && destination !== null && destination.type !== "none" - - property LocationEntry destination - property string vehicle: "car" - property bool suspended: true - property bool connected: false - property bool routeRunning: runningRouting !== null - - property alias vehiclePosition: navigationModel.vehiclePosition - property alias nextRouteStep: navigationModel.nextRouteStep - property alias currentSpeed: navigationModel.currentSpeed - property alias maximumSpeed: navigationModel.maxAllowedSpeed - property alias remainingDistance: navigationModel.remainingDistance - property string arrivalEstimate: "" - - property alias model: navigationModel - - // the routing model to navigate - property RoutingListModel routingModel: null - - signal rerouteRequested - signal targetReached(double targetDistance, string targetBearing) - signal started - signal stopped - - function setup(vehicle, routingModel, destination) { - // change routing model - navigator.vehicle = vehicle; - navigator.routingModel = routingModel; - navigator.destination = destination; - // show route overlays - overlayManager.addRoute(routingModel.routeWay); - overlayManager.addMarkEnd(destination.lat, destination.lon); - // setup navigation module - navigationModel.locationChanged(position._posValid, position._lat, position._lon, position._accValid, position._acc); - navigationModel.route = routingModel.route; - // start navigation - suspended = false; - started(); - } - - Timer { - id: delayReroute - interval: 5000 - onTriggered: { - } - } - - function stop() { - cancelRouting(); - delayReroute.stop(); - suspended = true; - destination = null; - navigationModel.route = null; - overlayManager.removeRoute(); - overlayManager.removeMarkEnd(); - stopped(); - } - - // passing signal args to the slot of NavigationModel - function locationChanged(valid, lat, lon, accValid, acc, alt) { - navigationModel.locationChanged(valid, lat, lon, accValid, acc); - } - - onSuspendedChanged: { - if (!suspended) { - if (!connected) { - console.log("Navigator: Connect on positionChanged"); - position.dataUpdated.connect(locationChanged); - connected = true; - } - } else { - if (connected) { - console.log("Navigator: Disconnect from positionChanged"); - position.dataUpdated.disconnect(locationChanged); - connected = false; - } - } - } - - NavigationModel { - id: navigationModel - - onArrivalEstimateChanged: { - if (!isNaN(arrivalEstimate.getTime())) { - navigator.arrivalEstimate = Qt.formatTime(arrivalEstimate); - } else { - navigator.arrivalEstimate = ""; - } - } - - onRerouteRequest: { - if (!delayReroute.running) { - delayReroute.start(); // wait 5 sec before next reroute - navigator.reroute(); - } - } - - onTargetReached: { - console.log("Navigator: Target reached"); - navigator.targetReached(targetDistance, targetBearing); - } - } - - property Component routingComponent - property NavigatorRouting runningRouting: null - property NavigatorRouting currentRouting: null - - Component.onCompleted: { - // prepare the routing component - routingComponent = Qt.createComponent("NavigatorRouting.qml"); - } - Component.onDestruction: { - cancelRouting(); - navigator.routingModel = null; - if (currentRouting) - currentRouting.destroy(); - } - - // cancel running routing - function cancelRouting() { - if (runningRouting) { - runningRouting.routing.cancel(); - runningRouting.destroy(); - runningRouting = null; - } - } - - // create routing instance and reroute - function reroute() { - if (destination && !runningRouting) { - runningRouting = routingComponent.createObject(navigator); - runningRouting.routeComputed.connect(routeComputed); - runningRouting.routeNoRoute.connect(routeNoRoute); - runningRouting.routeFailed.connect(routeFailed); - runningRouting.setup(navigator); - } - } - - // on routing completion - function routeComputed() { - if (navigator.destination) { - delayReroute.start(); // wait 5 sec before next reroute - navigator.routingModel = runningRouting.routing; // update routing model - if (currentRouting) - currentRouting.destroy(); - currentRouting = runningRouting; - runningRouting = null; - console.log("Navigator: route has " + navigator.routingModel.count + " steps"); - overlayManager.addRoute(navigator.routingModel.routeWay); - navigationModel.locationChanged(position._posValid, position._lat, position._lon, position._accValid, position._acc); - navigationModel.route = navigator.routingModel.route; - navigator.suspended = false; - } else { - runningRouting.destroy(); // destroy unusable obj - runningRouting = null; - } - } - - function routeNoRoute() { - navigator.routingModel = runningRouting.routing; // update routing model - if (currentRouting) - currentRouting.destroy(); - currentRouting = runningRouting; - runningRouting = null; - console.log("Navigator: Request to reroute again"); - delayReroute.stop(); - navigator.rerouteRequested(); - } - - function routeFailed(reason) { - runningRouting.destroy(); // destroy unusable obj - runningRouting = null; - delayReroute.stop(); - navigator.rerouteRequested(); - } -} diff --git a/gui/controls2_509/components/NavigatorInfo.qml b/gui/controls2_509/components/NavigatorInfo.qml deleted file mode 100644 index 4fdc0e13..00000000 --- a/gui/controls2_509/components/NavigatorInfo.qml +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import Osmin 1.0 - -Item { - id: navigationInfo - property Navigator navigator - - property color backgroundColor: styleMap.popover.backgroundColor - property color foregroundColor: styleMap.popover.foregroundColor - property real edgeMargins: 0.0 - property real backgroundRadius: 0.0 - property real backgroundOpacity: 1.0 - property real contentEdgeMargins: units.gu(1) - property real contentSpacing: units.gu(1) - readonly property real headerHeight: units.gu(6) - property real maximumHeight: parent.height - - signal show - signal close // triggered on button close pressed - - z: 99 - focus: true - height: minimumHeight - - function resizeBox() { - height = maximumHeight; - } - - function resizeFull() { - height = Qt.binding(function(){ return parent.height; }); - } - - onVisibleChanged: { - if (visible) { - resizeBox(); - } - } - - states: [ - State { - name: "running" - }, - State { - name: "suspended" - } - ] - state: "running" - - Connections { - target: navigator - onStarted: { - state = "running" - } - onRerouteRequested: { - navigator.suspended = true; - state = "suspended" - } - onTargetReached: { - navigator.suspended = true; - state = "suspended" - } - onNextRouteStepChanged: { - switch(state) { - case "running": - if (overview.active && overview.status === Loader.Ready) { - overview.item.show(navigator.nextRouteStep); - } - break; - default: - break; - } - } - } - - // background - Rectangle { - id: popover - anchors.fill: parent - anchors.margins: edgeMargins - color: backgroundColor - opacity: backgroundOpacity - radius: backgroundRadius - } - - // content box - Rectangle { - id: contentBox - anchors.top: popover.top - anchors.topMargin: navigationInfo.headerHeight - anchors.left: popover.left - anchors.right: popover.right - height: navigationInfo.maximumHeight - navigationInfo.headerHeight - color: styleMap.view.highlightedColor - opacity: overview.active ? 0.2 : 0.0 - } - - Flickable { - id: contents - anchors.fill: contentBox - anchors.topMargin: contentEdgeMargins - anchors.leftMargin: contentEdgeMargins - anchors.rightMargin: contentEdgeMargins - anchors.bottomMargin: contentEdgeMargins - contentHeight: contentsColumn.height - boundsBehavior: Flickable.StopAtBounds - clip: true - - Column { - id: contentsColumn - spacing: contentSpacing - width: parent.width - Row { - id: rowStep - opacity: navigationInfo.state === "running" ? 1.0 : 0.0 - spacing: units.gu(2) - width: parent.width - height: Math.max(distanceToNextStep.implicitHeight + contentSpacing + nextStepDescription.implicitHeight, icon.height) - - WAYIcon { - id: icon - anchors.verticalCenter: parent.verticalCenter - color: styleMap.popover.foregroundColor - stepType: navigator.nextRouteStep.type - roundaboutExit: navigator.nextRouteStep.roundaboutExit - roundaboutClockwise: navigator.nextRouteStep.roundaboutClockwise - width: units.gu(8) - height: width - label.text: navigator.nextRouteStep.type === "leave-roundabout" ? navigator.nextRouteStep.roundaboutExit : "" - } - Column { - spacing: contentSpacing - Label { - id: distanceToNextStep - text: Converter.readableDistance(navigator.nextRouteStep.distanceTo) - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("x-large") - } - Text { - id: nextStepDescription - text: navigator.nextRouteStep.shortDescription - font.pointSize: units.fs("large") - color: styleMap.popover.foregroundColor - wrapMode: Text.Wrap - } - } - } - } - } - - BusyIndicator{ - id: reroutingIndicator - running: navigator.routeRunning - height: units.gu(7) - anchors.verticalCenter: contentBox.verticalCenter - anchors.right: contentBox.right - visible: running - } - - Item { - id: board - anchors.verticalCenter: closeButton.verticalCenter - anchors.left: popover.left - anchors.right: closeButton.left - anchors.leftMargin: contentEdgeMargins - anchors.rightMargin: contentEdgeMargins - height: minimumHeight - - Row { - id: headInfo - anchors.verticalCenter: parent.verticalCenter - width: parent.width - spacing: units.gu(1) - - Label { - id: speed - anchors.verticalCenter: parent.verticalCenter - text: Converter.readableSpeed(navigator.currentSpeed > 0 ? navigator.currentSpeed : 0.0) - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("x-large") - } - Label { - id: maxspeed - anchors.verticalCenter: parent.verticalCenter - text: navigator.maximumSpeed > 0 ? Converter.readableSpeed(navigator.maximumSpeed) : "" - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("medium") - } - MapIcon { - anchors.verticalCenter: parent.verticalCenter - source: { - switch(navigator.vehicle) { - case "bicycle": - return "qrc:/images/trip/bike.svg" - case "foot": - return "qrc:/images/trip/walk.svg" - default: - return "qrc:/images/trip/car.svg" - } - } - height: units.gu(5) - width: height - color: styleMap.popover.foregroundColor - enabled: false - } - Label { - id: eta - anchors.verticalCenter: parent.verticalCenter - text: navigator.arrivalEstimate + " ~ " + Converter.panelDistance(navigator.remainingDistance) - color: styleMap.popover.foregroundColor - font.pointSize: units.fs("medium") - } - } - } - - // close button - MapIcon { - id: closeButton - source: "qrc:/images/close.svg" - height: units.gu(5) - anchors.top: popover.top - anchors.right: popover.right - anchors.rightMargin: units.gu(0.5) - anchors.topMargin: units.gu(0.5) - anchors.bottomMargin: units.gu(0.5) - color: foregroundColor - onClicked: { - console.log("close navigator info"); - if (overview.active) - overview.active = false; - close(); - } - } - - // show/hide overview - MouseArea { - id: showHideOverview - anchors.fill: contentBox - onClicked: { - if (!overview.active) { - navigationInfo.resizeFull(); - overview.active = true; - } else { - overview.active = false; - navigationInfo.resizeBox(); - } - } - } - - MapIcon { - id: resume - source: "qrc:/images/trip/route.svg" - height: units.gu(7) - anchors.centerIn: contentBox - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: contentEdgeMargins - anchors.rightMargin: contentEdgeMargins - color: styleMap.popover.foregroundColor - onClicked: { - navigator.suspended = false; - navigator.reroute(); - navigationInfo.state = "running"; - } - label.text: qsTr("Resume navigation") - visible: navigationInfo.state === "suspended" - enabled: visible - } - - Loader { - id: overview - active: false - height: navigationInfo.height - navigationInfo.headerHeight - contentBox.height; - anchors.left: parent.left - anchors.right: parent.right - anchors.top: contentBox.bottom - asynchronous: true - sourceComponent: RouteOverview { - routingModel: navigator.routingModel - anchors.fill: overview - } - onLoaded: { - item.show(navigator.nextRouteStep); - } - } -} diff --git a/gui/controls2_509/components/NavigatorRouting.qml b/gui/controls2_509/components/NavigatorRouting.qml deleted file mode 100644 index 47c82690..00000000 --- a/gui/controls2_509/components/NavigatorRouting.qml +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQml 2.2 -import Osmin 1.0 - -Item { - signal routeComputed() - signal routeFailed(var reason) - signal routeNoRoute() - - function setup(navigator) { - var location = routing.locationEntryFromPosition(navigator.position._lat, navigator.position._lon); - routing.setStartAndTarget(location, navigator.destination, navigator.vehicle); - } - - property alias routing: routing - - RoutingListModel { - id: routing - onComputingChanged: { - if (routing.ready) { - console.log("Route computed"); - if (routing.count > 0) - routeComputed(); - else - routeNoRoute(); - } else { - console.log("Route computing"); - } - } - onRouteFailed: { - console.log("Route failed: " + reason); - // on failure computing has been canceled, causing the signal routeNoRoute - // but if it still running then handle cancelling here to stop computing - // and reset callback immediately, finally signal the failure 1 times - if (!routing.ready) { - routing.cancel(); - routeFailed(reason); - } - } - } -} diff --git a/gui/controls2_509/components/OverlayManager.qml b/gui/controls2_509/components/OverlayManager.qml deleted file mode 100644 index ab62f91f..00000000 --- a/gui/controls2_509/components/OverlayManager.qml +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQml 2.2 -import Osmin 1.0 - -QtObject { - // the map to handle - property Map map - - // constants - readonly property int id_ROUTE: 0 // the route overlay - readonly property int id_RECORDING: 1 // the recording overlay - readonly property int id_DEPARTURE: 4 // the departure of route - readonly property int id_ARRIVAL: 5 // the arrival of route - readonly property int id_MARK_POINT: 8 // range start for marks - readonly property int id_WAY_POINT: 128 // range start for way points - readonly property int id_COURSE: 256 // range start for courses - - // add the route on the map - function addRoute(routeWay) { - map.addOverlayObject(id_ROUTE, routeWay); - } - - // remove the route on the map - function removeRoute() { - map.removeOverlayObject(id_ROUTE); - } - - // add the START mark on the map - function addMarkStart(lat, lon) { - map.addPositionMark(id_DEPARTURE, lat, lon); - } - - // remove the START mark on the map - function removeMarkStart() { - map.removePositionMark(id_DEPARTURE); - } - - // add the END mark on the map - function addMarkEnd(lat, lon) { - map.addPositionMark(id_ARRIVAL, lat, lon); - } - - // remove the END mark on the map - function removeMarkEnd() { - map.removePositionMark(id_ARRIVAL); - } - - // add a mark on the map - function addMark(id, lat, lon) { - map.addPositionMark(id_MARK_POINT + id, lat, lon); - } - - // remove a mark on the map - function removeMark(id) { - map.removePositionMark(id_MARK_POINT + id); - } - - // add a way point on the map - function addWayPoint(id, lat, lon) { - var wpt = map.createOverlayNode("_waypoint"); - wpt.addPoint(lat, lon); - wpt.name = "Pos: " + lat.toFixed(4) + " " + lon.toFixed(4); - map.addOverlayObject(id_WAY_POINT + id, wpt); - } - - // remove a way point on the map - function removeWayPoint(id) { - map.removeOverlayObject(id_WAY_POINT + id); - } - - // add the recording track on the map - function addRecording(overlayObject) { - map.addOverlayObject(id_RECORDING, overlayObject); - } - - // remove the recording track on the map - function removeRecording() { - map.removeOverlayObject(id_RECORDING); - } - - // keep track of courses added on the map - property var courseObjects: [] - - // add a course on the map - function addCourse(bid, overlays) { - if (overlays.length > 0) { - for (var i = 0; i < overlays.length; ++i) { - console.log("Add overlay " + (bid + i) + " : " + overlays[i].objectType + " , " + overlays[i].name); - map.addOverlayObject((bid + i), overlays[i]); - } - courseObjects.push({ "bid": bid, "overlays": overlays}); - return true; - } - return false; - } - - // remove a previously added course on the map - function removeCourse(bid) { - for (var c = 0; c < courseObjects.length; ++c) { - if (courseObjects[c].bid === bid) { - var len = courseObjects[c].overlays.length; - for (var i = 0; i < len; ++i) { - console.log("Remove overlay " + (bid + i)); - map.removeOverlayObject((bid + i)); - } - courseObjects.splice(c, 1); - return true; - } - } - return false; - } - - // remove all previously added courses on the map - function removeAllCourses() { - for (var c = 0; c < courseObjects.length; ++c) { - var bid = courseObjects[c].bid; - var len = courseObjects[c].overlays.length; - for (var i = 0; i < len; ++i) { - console.log("Remove overlay " + (bid + i)); - map.removeOverlayObject((bid + i)); - } - } - courseObjects = []; - } -} diff --git a/gui/controls2_509/components/POIIcon.qml b/gui/controls2_509/components/POIIcon.qml deleted file mode 100644 index 91c71149..00000000 --- a/gui/controls2_509/components/POIIcon.qml +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -MapIcon { - id: poiIcon - - property string poiType: "unknown" - property string unknownTypeIcon: "marker" - - /* - * This is mapping libosmscout types (defined in *.ost file used for import) - * and poi icons. - */ - property variant iconMapping: { - 'address': 'marker', - - 'amenity_atm': 'bank', - 'amenity_bank_building': 'bank', - 'amenity_bank': 'bank', - 'amenity_cafe_building': 'cafe', - 'amenity_cafe': 'cafe', - 'amenity_pub': 'pub', - 'amenity_pub_building': 'pub', - 'amenity_bar': 'bar', - 'amenity_bar_building': 'bar', - 'amenity_fast_food_building': 'fast-food', - 'amenity_fast_food': 'fast-food', - 'amenity_fuel_building': 'fuel', - 'amenity_fuel': 'fuel', - 'amenity_grave_yard': 'religious-christian', - 'amenity_hospital_building': 'hospital', - 'amenity_hospital': 'hospital', - 'amenity_kindergarten_building': 'playground', - 'amenity_kindergarten': 'playground', - 'amenity_parking_building': 'parking-garage', - 'amenity_parking': 'parking', - 'amenity_pharmacy': 'pharmacy', - 'amenity_post_office_building': 'post', - 'amenity_post_office': 'post', - 'amenity_post_box': 'post', - 'amenity_restaurant_building': 'restaurant', - 'amenity_restaurant': 'restaurant', - 'amenity_school_building': 'school', - 'amenity_school': 'school', - 'amenity_ferry_terminal': 'ferry', - 'amenity_toilets': 'toilet', - 'amenity_drinking_water': 'drinking-water', - - 'railway_station': 'rail', - 'railway_subway': 'rail', - 'railway_rail': 'rail', - 'highway_bus_stop': 'bus', - 'railway_tram_stop': 'rail-light', - 'railway_tram': 'rail-light', - 'aeroway_aerodrome': 'airport', - 'aeroway_terminal': 'airport', - - 'leisure_building': 'building', - 'leisure_sports_centre': 'soccer', - 'leisure_stadium': 'stadium', - 'leisure_golf_course': 'golf', - 'leisure_water_park': 'swimming', - 'leisure_swimming_pool': 'swimming', - 'leisure_marina': 'harbor', - 'leisure_park': 'park', - 'leisure_garden': 'garden', - 'leisure_playground': 'playground', - - 'tourism_aquarium': 'aquarium', - 'tourism_attraction_building': 'circle-stroked', - 'tourism_attraction': 'circle-stroked', - 'tourism_artwork': 'monument', - 'tourism_camp_site': 'campsite', - 'tourism_caravan_site': 'circle-stroked', - 'tourism_picnic_site': 'circle-stroked', - 'tourism_theme_park': 'circle-stroked', - 'tourism_zoo': 'zoo', - 'tourism_chalet_building': 'shelter', - 'tourism_chalet': 'shelter', - 'tourism_guest_house_building': 'circle-stroked', - 'tourism_guest_house': 'circle-stroked', - 'tourism_hostel_building': 'lodging', - 'tourism_hostel': 'lodging', - 'tourism_hotel_building': 'lodging', - 'tourism_hotel': 'lodging', - 'tourism_information_building': 'information', - 'tourism_information': 'information', - 'tourism_motel_building': 'lodging', - 'tourism_motel': 'lodging', - 'tourism_museum_building': 'museum', - 'tourism_museum': 'museum', - 'tourism_building': 'town-hall', - 'tourism': 'circle-stroked', - - 'historic_castle_building': 'castle', - 'historic_castle': 'castle', - 'historic_manor_building': 'town-hall', - 'historic_manor': 'town-hall', - 'historic_monument_building': 'landmark', - 'historic_monument': 'landmark', - 'historic_memorial_building': 'landmark', - 'historic_memorial': 'landmark', - 'historic_ruins_building': 'castle', - 'historic_ruins': 'castle', - 'historic_archaeological_site': 'square-stroked', - 'historic_battlefield': 'square-stroked', - 'historic_wreck': 'square-stroked', - 'historic_building': 'town-hall', - 'historic': 'square-stroked', - - 'shop': 'shop', - 'christian_church_building':'religious-christian', - 'christian_church': 'religious-christian', - 'landuse_cemetery': 'religious-christian', - 'railway_subway_entrance': 'entrance', - - 'place_locality': 'circle-stroked', - 'boundary_administrative': 'square-stroked', - 'boundary_state': 'square-stroked', - 'boundary_country': 'square-stroked', - 'boundary_county': 'square-stroked', - 'place_island': 'circle-stroked', - - 'landuse_farm':'farm', - 'landuse_farmyard':'farm', - 'place_hamlet': 'hamlet', - 'place_village': 'residential-community', - 'place_suburb': 'residential-community', - 'place_bigcity': 'city', - 'highway_residential': 'highway_residential', - 'highway_tertiary': 'highway_tertiary', - 'highway_unclassified': 'highway_tertiary', - 'highway_secondary': 'highway_tertiary', - 'highway_cycleway':'bicycle-share', - 'route_ferry': 'ferry', - 'building': 'building', - 'amenity_building': 'building', - 'landuse_industrial': 'industry', - - 'natural_peak':'mountain', - 'waterway_stream': 'waterway_stream', - 'waterway_river': 'waterway_river', - 'waterway_canal': 'waterway_river', - 'waterway_riverbank': 'waterway_river', - 'landuse_reservoir': 'landuse_reservoir', - 'natural_water': 'natural_water', - 'natural_spring': 'water' - } - - function iconUrl(icon) { - return "qrc:/images/poi/" + icon + ".svg"; - } - - function typeIcon(type) { - if (typeof iconMapping[type] === 'undefined') { - if (type.length > 0) - console.log("Can't find icon for type \"" + type + "\""); - return iconUrl(unknownTypeIcon); - } - return iconUrl(iconMapping[type]); - } - - source: typeIcon(poiType) -} diff --git a/gui/controls2_509/components/PhoneLink.qml b/gui/controls2_509/components/PhoneLink.qml deleted file mode 100644 index 16600932..00000000 --- a/gui/controls2_509/components/PhoneLink.qml +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.2 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Item { - property string phone: "" - property color foregroundColor: styleMap.view.primaryColor - property color highlightedColor: styleMap.view.highlightedColor - - visible: phone != "" - height: visible ? row.implicitHeight : 0 - width: row.implicitWidth - - Row { - id: row - MapIcon { - id: phoneIcon - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/dialer.svg" - color: foregroundColor - width: units.gu(4) - height: units.gu(4) - } - Label { - id: phoneLabel - anchors.verticalCenter: parent.verticalCenter - text: phone - color: highlightedColor - elide: Text.ElideRight - font.pointSize: units.fs("medium") - } - } - - MouseArea { - anchors.fill: row - onClicked: Qt.openUrlExternally("tel:%1".arg(phone)) - } -} diff --git a/gui/controls2_509/components/PopInfo.qml b/gui/controls2_509/components/PopInfo.qml deleted file mode 100644 index 1d6c12b7..00000000 --- a/gui/controls2_509/components/PopInfo.qml +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Item { - property string message: "" - property color backgroundColor: "red" - property color foregroundColor: "white" - property real edgeMargins: 0.0 - property real backgroundRadius: 0.0 - property real backgroundOpacity: 1.0 - property real contentEdgeMargins: units.gu(0.5) - property alias font: label.font - - height: area.visible ? label.paintedHeight + 3 * contentEdgeMargins : 0 - z: 99 - - MouseArea { - id: area - anchors.fill: parent - visible: false - enabled: visible - anchors.topMargin: edgeMargins - anchors.leftMargin: edgeMargins - anchors.rightMargin: edgeMargins - - // background - Rectangle { - id: popinfo - anchors.fill: parent - color: backgroundColor - opacity: backgroundOpacity - radius: backgroundRadius - } - - // message - Label { - id: label - text: message - anchors.verticalCenter: parent.verticalCenter - anchors.left:parent.left - anchors.right: parent.right - anchors.topMargin: contentEdgeMargins / 2 - anchors.bottomMargin: contentEdgeMargins / 2 - anchors.leftMargin: 2 * contentEdgeMargins - anchors.rightMargin: 2 * contentEdgeMargins - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignJustify - maximumLineCount: 4 - wrapMode: Text.Wrap - color: foregroundColor - font.pointSize: units.fs("small") - font.weight: Font.Normal - } - - onClicked: { - if (timer.running) - timer.stop(); - visible = false; - } - } - - // auto closing - Timer { - id: timer - interval: 5000 - onTriggered: { - close(); - } - } - - function open(msgtxt, bg, fg) { - message = msgtxt; - popinfo.color = (bg !== undefined ? bg : backgroundColor); - label.color = (fg !== undefined ? fg : foregroundColor) - if (area.visible) { - timer.restart(); - } else { - area.visible = true; - timer.interval = 1000 * (5 + Math.floor(msgtxt.length / 10)); - timer.start() - } - } - - function close() { - area.visible = false; - message = ""; - } -} diff --git a/gui/controls2_509/components/PopOver.qml b/gui/controls2_509/components/PopOver.qml deleted file mode 100644 index d3669b84..00000000 --- a/gui/controls2_509/components/PopOver.qml +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import "../../toolbox.js" as ToolBox - -Item { - property string title: "" - property color backgroundColor: styleMap.popover.backgroundColor - property color foregroundColor: styleMap.popover.foregroundColor - property real edgeMargins: 0.0 - property real backgroundRadius: 0.0 - property real backgroundOpacity: 1.0 - readonly property real contentTopMargin: units.gu(7) // title bar + 1 - property real contentEdgeMargins: units.gu(2) - property real contentSpacing: units.gu(1) - readonly property real minimumHeight: units.gu(7) - - signal show - signal close // triggered on button close pressed - - property bool keyBackEnabled: true - - // qmlproperty list contents - // Content will be put inside a column in the foreround of the pop. - default property alias contents: contentsColumn.data - - z: 99 - focus: true - height: minimumHeight - - // background - Rectangle { - id: popover - anchors.fill: parent - anchors.margins: edgeMargins - color: backgroundColor - opacity: backgroundOpacity - radius: backgroundRadius - } - - Flickable { - id: body - anchors.fill: popover - anchors.topMargin: contentTopMargin - anchors.leftMargin: contentEdgeMargins - anchors.rightMargin: contentEdgeMargins - anchors.bottomMargin: contentEdgeMargins - contentHeight: contentsColumn.height - boundsBehavior: Flickable.StopAtBounds - clip: true - - Column { - id: contentsColumn - spacing: contentSpacing - width: parent.width - onWidthChanged: updateChildrenWidths(); - - onChildrenChanged: updateChildrenWidths() - - function updateChildrenWidths() { - for (var i = 0; i < children.length; i++) { - children[i].width = contentsColumn.width; - } - } - } - } - - // title - Text { - anchors.verticalCenter: closeButton.verticalCenter - anchors.left: popover.left - anchors.right: popover.right - anchors.leftMargin: closeButton.width - anchors.rightMargin: closeButton.width - horizontalAlignment: Text.AlignHCenter - text: title - font.pointSize: units.fs("large") - color: foregroundColor - wrapMode: Text.Wrap - visible: (text !== "") - } - - // close button - MapIcon { - id: closeButton - source: "qrc:/images/close.svg" - height: units.gu(5) - anchors.top: popover.top - anchors.right: popover.right - anchors.rightMargin: units.gu(0.5) - anchors.topMargin: units.gu(0.5) - anchors.bottomMargin: units.gu(0.5) - color: foregroundColor - onClicked: { - console.log("close popover"); - close(); - } - } - - function onKeyBack() { - console.log("onKeyBack: close " + title); - close(); - } - onShow: { - if (keyBackEnabled) - ToolBox.connectOnce(mainView.keyBackPressed, onKeyBack); - } -} diff --git a/gui/controls2_509/components/RouteOverview.qml b/gui/controls2_509/components/RouteOverview.qml deleted file mode 100644 index c2a5c03f..00000000 --- a/gui/controls2_509/components/RouteOverview.qml +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2021 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import Osmin 1.0 - -Item { - id: routeOverview - - property RoutingListModel routingModel - - function show(step) { - var d = step.distance; - for (var i = 0; i < routingModel.count; ++i) { - if (routingModel.get(i).distance === d) { - stepsView.thisStep = i; - break; - } - } - } - - ListView { - id: stepsView - anchors.fill: parent - spacing: units.gu(1) - model: routingModel - clip: true - - property int thisStep: 0 - - onThisStepChanged: { - positionViewAtIndex(thisStep, ListView.Beginning); - } - - delegate: Row { - id: row - spacing: units.gu(2) - width: parent.width - height: Math.max(stepInfo.implicitHeight, icon.height) - - WAYIcon { - id: icon - anchors.verticalCenter: parent.verticalCenter - color: (index === stepsView.thisStep ? styleMap.popover.highlightedColor : styleMap.popover.foregroundColor) - stepType: model.type - roundaboutExit: model.roundaboutExit - roundaboutClockwise: model.roundaboutClockwise - width: units.gu(7) - height: width - } - Column { - id: stepInfo - anchors.verticalCenter: parent.verticalCenter - width: parent.width - icon.width - units.gu(3) - Label { - id: distance - width: parent.width - color: styleMap.popover.foregroundColor - text: { - return settings.routeStepDelta - ? Converter.panelDistance(model.distanceDelta) + " ~ " + Converter.panelDurationHM(model.timeDelta) + " Δ" - : Converter.panelDistance(model.distance) + " ~ " + Converter.panelDurationHM(model.time) - } - font.pointSize: units.fs("small") - horizontalAlignment: Label.AlignRight - MouseArea { - anchors.fill: parent - onClicked: { - settings.routeStepDelta = (settings.routeStepDelta ? false : true); - } - } - } - Label { - id: entryDescription - width: parent.width - color: (index === stepsView.thisStep ? styleMap.popover.highlightedColor : styleMap.popover.foregroundColor) - text: model.description - font.pointSize: units.fs("small") - wrapMode: Text.Wrap - } - } - } - } -} diff --git a/gui/controls2_509/components/ScaleIndicator.qml b/gui/controls2_509/components/ScaleIndicator.qml deleted file mode 100644 index f13afa09..00000000 --- a/gui/controls2_509/components/ScaleIndicator.qml +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Item { - id: scaleIndicator - - readonly property double maxSize: units.gu(10) - property double pixelSize: 0 // meters - property double indicatorWidth: 0 - property string label: "" - property color color: "black" - - height: caption.height + units.gu(1) - onPixelSizeChanged: updateIndicator() - - function updateIndicator() { - // 1,2,5,10,20,50,100,200,500 - var _label = ""; - var _width = 0.0; - var area = maxSize * pixelSize; - var base = Math.floor(Math.log(area) / Math.LN10); - if (base > 6) { - scaleIndicator.label = ""; - scaleIndicator.indicatorWidth = 0; - } - var m = area / Math.pow(10, base); - var s = (m < 2 ? 1 : m < 5 ? 2 : 5); - if (base < 3) { - var sm = s * Math.pow(10, base); - scaleIndicator.label = sm.toFixed() + "m"; - scaleIndicator.width = sm / pixelSize; - } else { - var skm = s * Math.pow(10, base - 3); - scaleIndicator.label = skm.toFixed() + "km"; - scaleIndicator.width = skm * 1000 / pixelSize; - } - } - - Rectangle{ - id: bar - width: parent.width - height: units.gu(0.25) - color: parent.color - anchors.bottom: parent.bottom - } - - Rectangle{ - id: borderLeft - width: units.gu(0.25) - height: units.gu(1) - color: parent.color - anchors.right: bar.left - anchors.verticalCenter: bar.verticalCenter - } - - Rectangle{ - id: borderRight - width: units.gu(0.25) - height: units.gu(1) - color: parent.color - anchors.left: bar.right - anchors.verticalCenter: bar.verticalCenter - } - - Label{ - id: caption - text: scaleIndicator.label - font.pointSize: units.fs("small") - color: parent.color - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/gui/controls2_509/components/SearchField.qml b/gui/controls2_509/components/SearchField.qml deleted file mode 100644 index bdf4fffe..00000000 --- a/gui/controls2_509/components/SearchField.qml +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQml 2.2 - -Rectangle { - id: filter - visible: true - height: visible ? units.gu(6) : 0 - color: "transparent" - - property alias displayText: field.displayText - property alias fieldFocus: field.focus - - function forceActiveFocus() { - field.forceActiveFocus(); - } - - function fill(text) { - field.text = text; - } - - function clear() { - field.clear(); - } - - signal accepted(string text) - - RowLayout { - spacing: 0 - anchors.fill: parent - anchors.leftMargin: units.gu(2) - anchors.rightMargin: units.gu(1) - - TextField { - id: field - Layout.fillWidth: true - font.pointSize: units.fs("large") - inputMethodHints: Qt.ImhNoPredictiveText - placeholderText: qsTr("Search") - EnterKey.type: Qt.EnterKeySearch - onAccepted: { - filter.accepted(displayText.trim()); - } - } - Item { - width: units.gu(6) - height: width - - MapIcon { - width: units.gu(5) - height: width - anchors.centerIn: parent - source: "qrc:/images/edit-clear.svg" - onClicked: { - field.clear(); - } - } - } - } - - onVisibleChanged: { - if (visible) { - field.enabled = true; - field.forceActiveFocus(); - } else { - field.clear(); - field.enabled = false; - } - } -} diff --git a/gui/controls2_509/components/SimpleListItem.qml b/gui/controls2_509/components/SimpleListItem.qml deleted file mode 100644 index 88999b61..00000000 --- a/gui/controls2_509/components/SimpleListItem.qml +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 -import QtQml.Models 2.3 -import "../" - -MouseArea { - id: area - - property color color: styleMap.view.backgroundColor - property color colorAlt: styleMap.view.backgroundAltColor - property color highlightedColor: styleMap.view.highlightedColor - property bool highlighted: false - property bool alternate: false - - property double paddingLeft: 0 - property double paddingRight: 0 - property alias column: row.column - property alias action1: row.action1 - property alias action2: row.action2 - property alias menuVisible: row.menuVisible - property alias menuItems: row.menuItems - - //anchors { left: parent.left; right: parent.right } - //Qt5.15: Fix parent null on init - Component.onCompleted: { - anchors.left = parent.left; - anchors.right = parent.right; - } - - Rectangle { - id: content - anchors.fill: parent - - color: (area.alternate ? area.colorAlt : area.color) - - // highlight the current position - Rectangle { - anchors.fill: parent - visible: area.highlighted - color: area.highlightedColor - opacity: 0.2 - } - - SimpleRow { - id: row - anchors.fill: parent - anchors.leftMargin: paddingLeft - anchors.rightMargin: paddingRight - - // Animate margin changes so it isn't noticible - Behavior on anchors.leftMargin { - NumberAnimation { - - } - } - - Behavior on anchors.rightMargin { - NumberAnimation { - - } - } - } - } -} diff --git a/gui/controls2_509/components/SimpleRow.qml b/gui/controls2_509/components/SimpleRow.qml deleted file mode 100644 index 5b497f83..00000000 --- a/gui/controls2_509/components/SimpleRow.qml +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Item { - property alias column: columnComponent.sourceComponent - property alias action1: action1 - property alias action2: action2 - property bool menuVisible: false - property alias menuItems: optionsMenu.contentData - - anchors.fill: parent - - Loader { - id: columnComponent - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - right: action2.left - } - width: parent.width - parent.spacing - - onSourceComponentChanged: { - for (var i=0; i < item.children.length; i++) { - // binds to width so it is updated when screen size changes - item.children[i].width = Qt.binding(function () { return width; }) - } - } - } - - MapIcon { - id: action2 - anchors.right: action1.left - anchors.verticalCenter: parent.verticalCenter - visible: false - width: visible ? units.gu(5) : 0 - height: width - } - - MapIcon { - id: action1 - anchors.right: menu.left - anchors.rightMargin: units.gu(1) - anchors.verticalCenter: parent.verticalCenter - visible: false - width: visible ? units.gu(5) : 0 - height: width - } - - MapIcon { - id: menu - anchors.right: parent.right - anchors.rightMargin: units.gu(1) - anchors.verticalCenter: parent.verticalCenter - visible: menuVisible - width: visible ? units.gu(5) : 0 - height: width - source: "qrc:/images/contextual-menu.svg" - onClicked: optionsMenu.open() - - Menu { - id: optionsMenu - width: implicitWidth * units.scaleFactor - x: parent.width - width - transformOrigin: Menu.TopRight - } - } -} - diff --git a/gui/controls2_509/components/StyleLight.qml b/gui/controls2_509/components/StyleLight.qml deleted file mode 100644 index 1be6ec40..00000000 --- a/gui/controls2_509/components/StyleLight.qml +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQml 2.2 -import QtQuick.Controls 2.2 - -QtObject { - property QtObject view: QtObject { - property color foregroundColor: palette.text - property color backgroundColor: palette.base - property color backgroundAltColor: Qt.darker(palette.base, 1.05) - property color highlightedColor: palette.highlight - property color labelColor: palette.text - property color primaryColor: palette.text - property color secondaryColor: palette.text - property color linkColor: palette.link - property color footerColor: backgroundColor - property color headerColor: backgroundColor - } - - property QtObject dialog: QtObject { - property color backgroundColor: palette.base - property color foregroundColor: palette.text - property color labelColor: palette.text - property color confirmButtonColor: "green" - property color confirmRemoveButtonColor: "red" - property color cancelButtonColor: palette.button - } - - property QtObject card: QtObject { - property color backgroundColor: "grey" - property color foregroundColor: palette.text - property color borderColor: backgroundColor - } - - property QtObject popover: QtObject { - property color backgroundColor: palette.base // "black" - property color foregroundColor: palette.text // "white" - property color highlightedColor: "deepskyblue" - } - - property QtObject tooltip: QtObject { - property color backgroundColor: palette.toolTipBase // "black" - property color foregroundColor: palette.toolTipText // "white" - } -} diff --git a/gui/controls2_509/components/Units.qml b/gui/controls2_509/components/Units.qml deleted file mode 100644 index 95dae9a8..00000000 --- a/gui/controls2_509/components/Units.qml +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQml 2.2 - -QtObject { - property real scaleFactor: 1.0 - property real fontScaleFactor: 1.0 - property real gridUnit: 8.0 * scaleFactor - - function dp(p) { - return scaleFactor * p; - } - - function gu(u) { - return gridUnit * u; - } - - function fs(s) { - if (Android) { - if (s === "x-small") - return 10.0 * scaleFactor * fontScaleFactor; - if (s === "small") - return 12.0 * scaleFactor * fontScaleFactor; - if (s === "medium") - return 14.0 * scaleFactor * fontScaleFactor; - if (s === "large") - return 18.0 * scaleFactor * fontScaleFactor; - if (s === "x-large") - return 22.0 * scaleFactor * fontScaleFactor; - } else { - if (s === "x-small") - return 9.0 * scaleFactor * fontScaleFactor; - if (s === "small") - return 10.0 * scaleFactor * fontScaleFactor; - if (s === "medium") - return 12.0 * scaleFactor * fontScaleFactor; - if (s === "large") - return 14.0 * scaleFactor * fontScaleFactor; - if (s === "x-large") - return 16.0 * scaleFactor * fontScaleFactor; - } - return 0.0; - } - -} diff --git a/gui/controls2_509/components/WAYIcon.qml b/gui/controls2_509/components/WAYIcon.qml deleted file mode 100644 index a5e7bd3a..00000000 --- a/gui/controls2_509/components/WAYIcon.qml +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -MapIcon { - id: wayIcon - - property string stepType: "unknown" - property string unknownTypeIcon: "information" - property int roundaboutExit: -1 - property bool roundaboutClockwise: false - - /* - * This is mapping libosmscout route step types and step icons. - */ - property variant iconMapping: { - 'information': 'information', - - 'start': 'start', - 'drive-along': 'drive-along', - 'target': 'target', - - 'turn': 'turn', - 'turn-sharp-left': 'turn-sharp-left', - 'turn-left': 'turn-left', - 'turn-slightly-left': 'turn-slightly-left', - 'continue-straight-on': 'continue-straight-on', - 'turn-slightly-right': 'turn-slightly-right', - 'turn-right': 'turn-right', - 'turn-sharp-right': 'turn-sharp-right', - - 'enter-roundabout': 'enter-roundabout', - 'leave-roundabout-1': 'leave-roundabout-1', - 'leave-roundabout-2': 'leave-roundabout-2', - 'leave-roundabout-3': 'leave-roundabout-3', - 'leave-roundabout-4': 'leave-roundabout-4', - - 'enter-roundabout-lhd': 'enter-roundabout-lhd', - 'leave-roundabout-1-lhd': 'leave-roundabout-1-lhd', - 'leave-roundabout-2-lhd': 'leave-roundabout-2-lhd', - 'leave-roundabout-3-lhd': 'leave-roundabout-3-lhd', - 'leave-roundabout-4-lhd': 'leave-roundabout-4-lhd', - - 'enter-motorway': 'enter-motorway', - - 'change-motorway': 'leave-motorway', - 'change-motorway-left': 'leave-motorway-left', - 'change-motorway-right': 'leave-motorway-right', - - 'leave-motorway': 'leave-motorway', - 'leave-motorway-left': 'leave-motorway-left', - 'leave-motorway-right': 'leave-motorway-right', - - 'name-change': 'information' - } - - function iconUrl(icon) { - return "qrc:/images/way/" + icon + ".svg"; - } - - function typeIcon(type) { - if (type === "leave-roundabout") { - type += "-" + Math.max(1, Math.min(roundaboutExit, 4)); - if (roundaboutClockwise) { - type += "-lhd" - } - } - if (type === "enter-roundabout" && roundaboutClockwise) { - type += "-lhd" - } - if (typeof iconMapping[type] === 'undefined') { - if (type.length > 0) - console.log("Can't find icon for type \"" + type + "\""); - return iconUrl(unknownTypeIcon); - } - return iconUrl(iconMapping[type]); - } - - source: typeIcon(stepType) -} diff --git a/gui/controls2_509/components/WebLink.qml b/gui/controls2_509/components/WebLink.qml deleted file mode 100644 index 055a9bc6..00000000 --- a/gui/controls2_509/components/WebLink.qml +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 2.2 -import QtQuick.Controls 2.2 -import QtQml 2.2 - -Item { - property string url: "" - property color foregroundColor: styleMap.view.primaryColor - property color highlightedColor: styleMap.view.highlightedColor - - visible: url != "" - height: visible ? row.implicitHeight : 0 - width: row.implicitWidth - - Row { - id: row - MapIcon { - id: urlIcon - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/images/region.svg" - color: foregroundColor - width: units.gu(4) - height: units.gu(4) - } - Label { - id: urlLabel - anchors.verticalCenter: parent.verticalCenter - text: { - var str = url; - var proto = str.indexOf("://"); - if (proto > 0) - str = str.substring(proto + 3); - if (str.lastIndexOf("/") === (str.length-1)) - str = str.substring(0, str.length-1); - return str; - } - color: highlightedColor - elide: Text.ElideRight - font.pointSize: units.fs("medium") - } - } - - MouseArea { - anchors.fill: row - onClicked: Qt.openUrlExternally(url); - } -} diff --git a/gui/controls2_509/osmin.qml b/gui/controls2_509/osmin.qml deleted file mode 100644 index b28f3dc4..00000000 --- a/gui/controls2_509/osmin.qml +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Copyright (C) 2020 - * Jean-Luc Barriere - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick 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 QtGraphicalEffects 1.0 -import Osmin 1.0 as Osmin -import "../toolbox.js" as ToolBox -import "./components" - -ApplicationWindow { - id: mainView - visible: true - - // Design stuff - width: 360 - height: 640 - - Settings { - id: settings - // General settings - property string style: "Material" - property int theme: 0 - property real scaleFactor: 1.0 - property real fontScaleFactor: 1.0 - property bool firstRun: true - property int tabIndex: -1 - property int widthGU: Math.round(mainView.width / units.gridUnit) - property int heightGU: Math.round(mainView.height / units.gridUnit) - - // Navigation settings - property string systemOfUnits: "SI" - property bool hillShadesEnabled: false - property bool renderingTypeTiled: false - property string lastVehicle: "car" - property int maximumRouteStep: 255 - property int courseId: 0 - property real magneticDip: 0.0 - property string voiceName: "" - property bool routeStepDelta: false - - // Tracker settings - property string trackerRecording: "" - - // Extra settings - property string styleFlags: "[]" - } - - Material.accent: Material.Grey - Universal.accent: "grey" - - //@FIXME: declare the property 'palette' that is missing in QtQuick.controls 2.2 (Qt-5.9) - Item { - id: palette - property color base: { - if (settings.style === "Material") { - return Material.background - } else if (settings.style === "Universal") { - return Universal.background - } else return "white" - } - property color text: { - if (settings.style === "Material") { - return Material.foreground - } else if (settings.style === "Universal") { - return Universal.foreground - } else return "black" - } - property color highlight: "gray" - property color shadow: "black" - property color brightText: "dimgray" - property color button: "darkgray" - property color link: "green" - property color toolTipBase: "black" - property color toolTipText: "white" - } - - StyleLight { - id: styleMap - } - - Universal.theme: settings.theme - Material.theme: settings.theme - - Units { - id: units - scaleFactor: settings.scaleFactor - fontScaleFactor: settings.fontScaleFactor - } - - // Variables - property int debugLevel: 2 // My debug level - property bool startup: true // is running the cold startup ? - - // Property to store the state of the application (active or suspended) - property bool applicationSuspended: false - - // setting alias to check first run - property alias firstRun: settings.firstRun - - // 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 - readonly property real minSizeGU: 44 - - minimumHeight: units.gu(minSizeGU) - minimumWidth: units.gu(minSizeGU) - - Connections { - target: Qt.application - onStateChanged: { - switch (Qt.application.state) { - case Qt.ApplicationSuspended: - case Qt.ApplicationInactive: - if (!applicationSuspended) { - console.log("Application state changed to suspended"); - applicationSuspended = true; - } - break; - case Qt.ApplicationHidden: - case Qt.ApplicationActive: - if (applicationSuspended) { - console.log("Application state changed to active"); - applicationSuspended = false; - } - break; - } - } - } - - - //////////////////////////////////////////////////////////////////////////// - //// - //// Application main view - //// - - header: Rectangle { - id: mainToolBar - Material.foreground: styleMap.view.foregroundColor - Material.background: styleMap.view.backgroundColor - height: units.gu(6) - width: parent.width - color: styleMap.view.backgroundColor - visible: stackView.currentItem && stackView.currentItem.showHeader ? true : false - - state: "default" - states: [ - State { - name: "default" - } - ] - - RowLayout { - spacing: 0 - anchors.fill: parent - - Item { - width: units.gu(6) - height: width - - MapIcon { - width: units.gu(5) - height: width - anchors.centerIn: parent - source: { - if (stackView.depth > 1) { - if (stackView.currentItem.isRoot) - "qrc:/images/go-previous.svg" - else - "qrc:/images/go-up.svg" - } else { - "qrc:/images/navigation-menu.svg" - } - } - - onClicked: { - if (stackView.depth > 1) { - if (stackView.currentItem.isRoot) { - stackView.currentItem.popped(); - stackView.pop(); - } else - stackView.currentItem.goUpClicked(); - } else { - //drawer.open(); - } - } - - visible: !mainView.noZone - enabled: !mainView.jobRunning - } - } - - Label { - id: titleLabel - text: stackView.currentItem != null ? stackView.currentItem.pageTitle : "" - font.pointSize: units.fs("large") - elide: Label.ElideRight - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - Layout.fillWidth: true - } - - Item { - width: units.gu(6) - height: width - - MapIcon { - width: units.gu(5) - height: width - anchors.centerIn: parent - source: "qrc:/images/home.svg" - - onClicked: { - stackView.pop() - } - - visible: (stackView.currentItem != null && !stackView.currentItem.isRoot) - enabled: visible - } - - MapIcon { - width: units.gu(5) - height: width - anchors.centerIn: parent - source: "qrc:/images/contextual-menu.svg" - - visible: (stackView.currentItem == null || stackView.currentItem.isRoot) - enabled: visible - - onClicked: optionsMenu.open() - - Menu { - id: optionsMenu - x: parent.width - width - transformOrigin: Menu.TopRight - - MenuItem { - text: qsTr("About") - font.pointSize: units.fs("medium") - onTriggered: dialogAbout.open() - } - } - } - } - } - - PopInfo { - id: mainInfo - anchors.fill: parent - backgroundRadius: 0 - edgeMargins: 0 - font.pointSize: units.fs("medium"); - backgroundColor: styleMap.view.backgroundColor - foregroundColor: styleMap.view.foregroundColor - } - } - - property alias stackView: stackView - - StackView { - id: stackView - anchors { - bottom: parent.bottom - fill: undefined - left: parent.left - right: parent.right - top: parent.top - } - initialItem: "qrc:/controls2/Banner.qml" - } - - property var mapPage: null - property var hillshadeProvider: null - property int launcherMode: 0 - - Component.onCompleted: { - // resize main view according to user settings - if (!Android) { - mainView.width = (settings.widthGU >= minSizeGU ? units.gu(settings.widthGU) : units.gu(minSizeGU)); - mainView.height = (settings.heightGU >= minSizeGU ? units.gu(settings.heightGU) : units.gu(minSizeGU)); - } - // setup hillshade provider - try { - var hsprovider = JSON.parse(HillshadeProvider); - if (hsprovider.id) - hillshadeProvider = hsprovider; - } catch(e) { - console.log("HillshadeProvider: " + e.name); - } - // setup Converter - Osmin.Converter.meters = qsTr("meters"); - Osmin.Converter.km = qsTr("km"); - Osmin.Converter.feet = qsTr("feet"); - Osmin.Converter.miles = qsTr("miles"); - Osmin.Converter.north = qsTr("north"); - Osmin.Converter.south = qsTr("south"); - Osmin.Converter.west = qsTr("west"); - Osmin.Converter.east = qsTr("east"); - Osmin.Converter.northwest = qsTr("northwest"); - Osmin.Converter.northeast = qsTr("northeast"); - Osmin.Converter.southwest = qsTr("southwest"); - Osmin.Converter.southeast = qsTr("southeast"); - Osmin.Converter.system = settings.systemOfUnits; - positionSource.active = true; - launcher.start(); - } - - // The initial stacked page (banner) will set the startup mode. - // I don't want use a signal for that, so we just loop until the change. - Timer { - id: launcher - interval: 500 - onTriggered: { - if (launcherMode === 0) - restart(); - else { - stackView.clear(); - mapPage = stackView.push("qrc:/controls2/MapView.qml"); - if (launcherMode === 1) { - stackView.push("qrc:/controls2/Welcome.qml"); - } - stop(); - } - } - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Global keyboard shortcuts - //// - - // Child can connect this signal to handle the event - signal keyBackPressed - - Timer { - id: postponeKeyBackPressed - interval: 100 - onTriggered: keyBackPressed() - } - - // On android catch the signal 'closing' - onClosing: { - if (Android) { - close.accepted = false; - if (stackView.depth > 1) { - if (stackView.currentItem.isRoot) - stackView.pop(); - else - stackView.currentItem.goUpClicked(); - } else { - // don't trigger any op synchronously - postponeKeyBackPressed.start(); - } - } - } - - // On desktop catch the key 'ESC' - Shortcut { - sequences: ["Esc"] - onActivated: { - if (stackView.depth > 1) { - if (stackView.currentItem.isRoot) - stackView.pop(); - else - stackView.currentItem.goUpClicked(); - } else { - postponeKeyBackPressed.start(); - } - } - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Global requests - //// - - // Add a new favorite - function createFavorite(lat, lon, label, type) { - var index = Osmin.FavoritesModel.append(); - var id = Osmin.FavoritesModel.data(index, Osmin.FavoritesModel.IdRole) - Osmin.FavoritesModel.setData(index, lat, Osmin.FavoritesModel.LatRole); - Osmin.FavoritesModel.setData(index, lon, Osmin.FavoritesModel.LonRole); - Osmin.FavoritesModel.setData(index, 0.0, Osmin.FavoritesModel.AltRole); - Osmin.FavoritesModel.setData(index, new Date(), Osmin.FavoritesModel.TimestampRole); - Osmin.FavoritesModel.setData(index, label, Osmin.FavoritesModel.LabelRole); - if (type) // optional - Osmin.FavoritesModel.setData(index, type, Osmin.FavoritesModel.TypeRole); - if (Osmin.FavoritesModel.storeData()) - return id; - mainInfo.open(qsTr("Saving change failed")); - Osmin.FavoritesModel.remove(id); - return 0; - } - - // Remove a favorite - function removeFavorite(id) { - Osmin.FavoritesModel.remove(id); - if (Osmin.FavoritesModel.storeData()) - return true; - mainInfo.open(qsTr("Saving change failed")); - return false; - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Dialog - //// - - DialogAbout { - id: dialogAbout - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Spinner - //// - - property bool jobRunning: false - - ActivitySpinner { - id: spinner - visible: jobRunning - } - - //////////////////////////////////////////////////////////////////////////// - //// - //// Map - //// - - Osmin.Settings { - id: mapSettings - //double mapDPI - //bool onlineTiles - //QString onlineTileProviderId - //bool offlineMap - //QString styleSheetFile - //bool renderSea - //QString fontName - //double fontSize - //bool showAltLanguage - //QString units metrics|imperial - offlineMap: true - onlineTiles: false - } - - MapPosition { - id: positionSource - } - - CompassSensor { - id: compass - active: false - magneticDip: settings.magneticDip - signal polled(real azimuth, real rotation) - onAzimuthChanged: { - if (!poll.running) poll.start(); - } - Timer { - id: poll - interval: 500 - onTriggered: { - compass.polled(compass.azimuth, (360 - compass.azimuth) * Math.PI / 180.0); - } - } - } - - MapVoice { - id: mapVoice - Component.onCompleted: { - // bind the setting - settings.voiceName = Qt.binding(function foo(){return voiceName;}); - } - } -} diff --git a/gui/controls2_509/qtquickcontrols2.conf b/gui/controls2_509/qtquickcontrols2.conf deleted file mode 100644 index f9906706..00000000 --- a/gui/controls2_509/qtquickcontrols2.conf +++ /dev/null @@ -1,8 +0,0 @@ -[Material] -Primary=#41cd52 -Accent=#41cd52 -Theme=System - -[Universal] -Accent=#41cd52 -Theme=System diff --git a/gui/osmin_controls2_509.qrc b/gui/osmin_controls2_509.qrc deleted file mode 100644 index db36f30c..00000000 --- a/gui/osmin_controls2_509.qrc +++ /dev/null @@ -1,281 +0,0 @@ - - - controls2_509/qtquickcontrols2.conf - controls2_509/components/ActivitySpinner.qml - controls2_509/components/PopInfo.qml - controls2_509/components/StyleLight.qml - controls2_509/components/Units.qml - controls2_509/Welcome.qml - controls2_509/components/MapIcon.qml - controls2_509/MapView.qml - controls2_509/components/MapPage.qml - controls2_509/MapDownloads.qml - controls2_509/components/SimpleListItem.qml - controls2_509/components/SimpleRow.qml - controls2_509/components/MapListView.qml - controls2_509/components/ScaleIndicator.qml - controls2_509/components/PopOver.qml - controls2_509/MainMenu.qml - controls2_509/ConfigureMap.qml - controls2_509/components/MapCheckBox.qml - controls2_509/LocationInfo.qml - controls2_509/components/POIIcon.qml - controls2_509/components/PhoneLink.qml - controls2_509/components/WebLink.qml - controls2_509/Routing.qml - controls2_509/components/WAYIcon.qml - controls2_509/components/Navigator.qml - controls2_509/components/MapRotator.qml - controls2_509/components/NavigatorInfo.qml - controls2_509/osmin.qml - controls2_509/components/MapPosition.qml - controls2_509/SearchPlace.qml - controls2_509/components/SearchField.qml - controls2_509/Favorites.qml - controls2_509/components/DialogBase.qml - toolbox.js - controls2_509/DialogAbout.qml - controls2_509/Settings.qml - controls2_509/TrackCollection.qml - controls2_509/components/CompassSensor.qml - controls2_509/Tracking.qml - controls2_509/Banner.qml - i18n/osmin_en.qm - i18n/osmin_fr.qm - i18n/osmin_nl.qm - i18n/osmin_de.qm - i18n/osmin_es.qm - controls2_509/components/MapVoice.qml - controls2_509/ConfigureVoice.qml - controls2_509/components/OverlayManager.qml - controls2_509/components/RouteOverview.qml - controls2_509/components/NavigatorRouting.qml - controls2_509/components/DialogMarkPosition.qml - controls2_509/components/DialogAction.qml - controls2_509/components/DialogAlert.qml - controls2_509/components/DialogEnter.qml - images/poi/aerialway.svg - images/poi/airfield.svg - images/poi/airport.svg - images/poi/alcohol-shop.svg - images/poi/america-football.svg - images/poi/amusement-park.svg - images/poi/aquarium.svg - images/poi/art-gallery.svg - images/poi/attraction.svg - images/poi/bakery.svg - images/poi/bank.svg - images/poi/bar.svg - images/poi/baseball.svg - images/poi/basketball.svg - images/poi/beer.svg - images/poi/bicycle-share.svg - images/poi/bicycle.svg - images/poi/blood-bank.svg - images/poi/buddhism.svg - images/poi/building.svg - images/poi/bus.svg - images/poi/cafe.svg - images/poi/campsite.svg - images/poi/car.svg - images/poi/castle.svg - images/poi/cemetery.svg - images/poi/central-building.svg - images/poi/cinema.svg - images/poi/circle-stroked.svg - images/poi/circle.svg - images/poi/city.svg - images/poi/clothing-store.svg - images/poi/college.svg - images/poi/commercial.svg - images/poi/cricket.svg - images/poi/cross.svg - images/poi/dam.svg - images/poi/danger.svg - images/poi/dentist.svg - images/poi/doctor.svg - images/poi/dog-park.svg - images/poi/drinking-water.svg - images/poi/embassy.svg - images/poi/entrance.svg - images/poi/farm.svg - images/poi/fast-food.svg - images/poi/ferry.svg - images/poi/fire-station.svg - images/poi/fuel.svg - images/poi/gaming.svg - images/poi/garden-center.svg - images/poi/garden.svg - images/poi/gift.svg - images/poi/golf.svg - images/poi/grocery.svg - images/poi/hairdresser.svg - images/poi/hamlet.svg - images/poi/harbor.svg - images/poi/heart.svg - images/poi/heliport.svg - images/poi/highway_residential.svg - images/poi/highway_tertiary.svg - images/poi/hospital.svg - images/poi/ice-cream.svg - images/poi/industry.svg - images/poi/information.svg - images/poi/karaoke.svg - images/poi/landmark.svg - images/poi/landuse_reservoir.svg - images/poi/laundry.svg - images/poi/library.svg - images/poi/LICENSE - images/poi/lighthouse.svg - images/poi/lodging.svg - images/poi/marker.svg - images/poi/monument.svg - images/poi/mountain.svg - images/poi/museum.svg - images/poi/music.svg - images/poi/natural_water.svg - images/poi/park.svg - images/poi/parking-garage.svg - images/poi/parking.svg - images/poi/pharmacy.svg - images/poi/picnic-site.svg - images/poi/pitch.svg - images/poi/place-of-worship.svg - images/poi/playground.svg - images/poi/police.svg - images/poi/post.svg - images/poi/prison.svg - images/poi/pub.svg - images/poi/rail-light.svg - images/poi/rail-metro.svg - images/poi/rail.svg - images/poi/ranger-station.svg - images/poi/religious-christian.svg - images/poi/religious-jewish.svg - images/poi/religious-muslim.svg - images/poi/residential-community.svg - images/poi/restaurant.svg - images/poi/roadblock.svg - images/poi/rocket.svg - images/poi/school.svg - images/poi/shelter.svg - images/poi/shop.svg - images/poi/skiing.svg - images/poi/soccer.svg - images/poi/square-stroked.svg - images/poi/square.svg - images/poi/stadium.svg - images/poi/star-stroked.svg - images/poi/star.svg - images/poi/suitcase.svg - images/poi/sushi.svg - images/poi/swimming.svg - images/poi/teahouse.svg - images/poi/telephone.svg - images/poi/tennis.svg - images/poi/theatre.svg - images/poi/toilet.svg - images/poi/town-hall.svg - images/poi/triangle-stroked.svg - images/poi/triangle.svg - images/poi/veterinary.svg - images/poi/volcano.svg - images/poi/warehouse.svg - images/poi/waste-basket.svg - images/poi/water.svg - images/poi/waterway_river.svg - images/poi/waterway_stream.svg - images/poi/wetland.svg - images/poi/wheelchair.svg - images/poi/zoo.svg - images/trip/ascent.svg - images/trip/bike.svg - images/trip/bus.svg - images/trip/car.svg - images/trip/compass.svg - images/trip/descent.svg - images/trip/directions.svg - images/trip/elevation.svg - images/trip/favourite.svg - images/trip/finish.svg - images/trip/here.svg - images/trip/home.svg - images/trip/info.svg - images/trip/location-idle.svg - images/trip/location.svg - images/trip/marker.svg - images/trip/measuring.svg - images/trip/navigation.svg - images/trip/navigator.svg - images/trip/noname.svg - images/trip/pin.svg - images/trip/route.svg - images/trip/search.svg - images/trip/segment.svg - images/trip/track.svg - images/trip/vehicle.svg - images/trip/walk.svg - images/way/continue-straight-on.svg - images/way/drive-along.svg - images/way/enter-motorway.svg - images/way/enter-roundabout-lhd.svg - images/way/enter-roundabout.svg - images/way/information.svg - images/way/invalid-straight.svg - images/way/leave-motorway-left.svg - images/way/leave-motorway-right.svg - images/way/leave-motorway.svg - images/way/leave-roundabout-1-lhd.svg - images/way/leave-roundabout-1.svg - images/way/leave-roundabout-2-lhd.svg - images/way/leave-roundabout-2.svg - images/way/leave-roundabout-3-lhd.svg - images/way/leave-roundabout-3.svg - images/way/leave-roundabout-4-lhd.svg - images/way/leave-roundabout-4.svg - images/way/start.svg - images/way/target.svg - images/way/turn-left.svg - images/way/turn-right.svg - images/way/turn-sharp-left.svg - images/way/turn-sharp-right.svg - images/way/turn-slightly-left.svg - images/way/turn-slightly-right.svg - images/way/turn.svg - images/add.svg - images/close.svg - images/cogs.svg - images/compass.svg - images/contextual-menu.svg - images/day-night.svg - images/delete.svg - images/dialer.svg - images/download.svg - images/edit-clear.svg - images/find.svg - images/font-scalling.svg - images/go-down.svg - images/go-next.svg - images/go-previous.svg - images/go-up.svg - images/graphic-scalling.svg - images/help.svg - images/home.svg - images/location-idle.svg - images/location.svg - images/map.svg - images/navigation-menu.svg - images/osmin.png - images/osmin.svg - images/record.svg - images/region.svg - images/reload.svg - images/reset.svg - images/save.svg - images/sync.svg - images/view-fullscreen.svg - images/voice.svg - images/zoomin.svg - images/zoomout.svg - -