From d45dcfdc2a5378e29cc058808a6c622d48aafb8f Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Tue, 27 Oct 2026 14:32:58 +0000 Subject: [PATCH] Add MapBox API key setting. Default to osm maps on Linux on Qt 5.15.13 and above. --- .../demodadsb/adsbdemoddisplaydialog.cpp | 6 + .../demodadsb/adsbdemoddisplaydialog.ui | 54 +++++---- plugins/channelrx/demodadsb/adsbdemodgui.cpp | 6 + .../channelrx/demodadsb/adsbdemodsettings.cpp | 18 ++- .../channelrx/demodadsb/adsbdemodsettings.h | 1 + plugins/channelrx/demodadsb/readme.md | 3 +- plugins/feature/map/mapsettings.cpp | 11 +- plugins/feature/map/readme.md | 2 +- plugins/feature/vorlocalizer/CMakeLists.txt | 6 + plugins/feature/vorlocalizer/readme.md | 2 + .../vorlocalizerdisplaydialog.cpp | 67 +++++++++++ .../vorlocalizer/vorlocalizerdisplaydialog.h | 42 +++++++ .../vorlocalizer/vorlocalizerdisplaydialog.ui | 111 ++++++++++++++++++ .../feature/vorlocalizer/vorlocalizergui.cpp | 46 +++++++- .../feature/vorlocalizer/vorlocalizergui.h | 1 + .../feature/vorlocalizer/vorlocalizergui.ui | 14 +++ .../vorlocalizer/vorlocalizersettings.cpp | 19 ++- .../vorlocalizer/vorlocalizersettings.h | 1 + 18 files changed, 377 insertions(+), 33 deletions(-) create mode 100644 plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.cpp create mode 100644 plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.h create mode 100644 plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.ui diff --git a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp index e161c60c7..86cccb6fe 100644 --- a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp +++ b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp @@ -70,6 +70,7 @@ ADSBDemodDisplayDialog::ADSBDemodDisplayDialog(ADSBDemodSettings *settings, QWid ui->mapType->setCurrentIndex((int)settings->m_mapType); ui->maptilerAPIKey->setText(m_settings->m_maptilerAPIKey); ui->cartoDBAPIKey->setText(m_settings->m_cartoDBAPIKey); + ui->mapBoxAPIKey->setText(m_settings->m_mapBoxAPIKey); ui->navAids->setChecked(settings->m_displayNavAids); ui->atcCallsigns->setChecked(settings->m_atcCallsigns); ui->photos->setChecked(settings->m_displayPhotos); @@ -171,6 +172,11 @@ void ADSBDemodDisplayDialog::accept() m_settings->m_cartoDBAPIKey = ui->cartoDBAPIKey->text(); m_settingsKeys.append("cartoDBAPIKey"); } + if (m_settings->m_mapBoxAPIKey != ui->mapBoxAPIKey->text()) + { + m_settings->m_mapBoxAPIKey = ui->mapBoxAPIKey->text(); + m_settingsKeys.append("mapBoxAPIKey"); + } if (m_settings->m_displayNavAids != ui->navAids->isChecked()) { m_settings->m_displayNavAids = ui->navAids->isChecked(); diff --git a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.ui b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.ui index 53ae0bb34..a74842294 100644 --- a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.ui +++ b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.ui @@ -277,14 +277,14 @@ - + Zoom level for aircraft scaling - + When map zoom (0 min zoom - 15 max zoom) is higher than this value, aircraft icon size will be scaled @@ -294,14 +294,14 @@ - + Display airports with size - + Sets the minimum airport size that will be displayed on the map @@ -323,14 +323,14 @@ - + Display heliports - + When checked, heliports are displayed on the map @@ -340,14 +340,14 @@ - + Airport display distance (km) - + Displays airports within the specified distance in kilometres from My Position @@ -357,14 +357,14 @@ - + Airspaces to display - + Airspace categories to display @@ -521,14 +521,14 @@ - + Airspace display distance (km) - + Displays airspace within the specified distance in kilometres from My Position @@ -538,14 +538,14 @@ - + Display NAVAIDs - + Display NAVAIDs such as VORs and NDBs @@ -555,7 +555,7 @@ - + Use ATC callsigns (SPEEDBIRD) rather than ICAO (BAW) for aircraft labels on map @@ -565,21 +565,21 @@ - + Use ATC callsigns on map - + Colour palette to use for aircraft flight paths - + Flight path palette @@ -617,14 +617,28 @@ - + + + + Mapbox API key + + + + + + + API key for Mapbox (https://www.mapbox.com), required for the mapboxgl map provider + + + + Livery aircraft icons - + Display aircraft icons showing airline liveries, matched from the aircraft type and operator, instead of black icons diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.cpp b/plugins/channelrx/demodadsb/adsbdemodgui.cpp index ec1c48cc0..1a8d99cfa 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodgui.cpp @@ -2360,6 +2360,11 @@ void ADSBDemodGUI::applyMapSettings() } else if (mapProvider == "mapboxgl") { + if (!m_settings.m_mapBoxAPIKey.isEmpty()) { + parameters["mapboxgl.access_token"] = m_settings.m_mapBoxAPIKey; + } else { + qWarning() << "ADSBDemodGUI::applyMapSettings - mapboxgl map provider requires a Mapbox API key"; + } switch (m_settings.m_mapType) { case ADSBDemodSettings::AVIATION_LIGHT: @@ -2907,6 +2912,7 @@ void ADSBDemodGUI::displaySettings(const QStringList& settingsKeys, bool force) enableSpeechIfNeeded(); if (settingsKeys.contains("mapProvider") + || settingsKeys.contains("mapBoxAPIKey") || settingsKeys.contains("aircraftMinZoom") || settingsKeys.contains("mapType") || force) diff --git a/plugins/channelrx/demodadsb/adsbdemodsettings.cpp b/plugins/channelrx/demodadsb/adsbdemodsettings.cpp index 18e83f429..204efe380 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsettings.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodsettings.cpp @@ -84,6 +84,7 @@ void ADSBDemodSettings::resetToDefaults() m_checkWXAPIKey = ""; m_maptilerAPIKey = ""; m_cartoDBAPIKey = ""; + m_mapBoxAPIKey = ""; for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) { m_columnIndexes[i] = i; @@ -93,7 +94,7 @@ void ADSBDemodSettings::resetToDefaults() m_logEnabled = false; m_airspaces = QStringList({"CTR"}); m_airspaceRange = 500.0f; -#ifdef LINUX +#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 15, 13)) m_mapProvider = "mapboxgl"; // osm maps do not work in some versions of Linux https://github.com/f4exb/sdrangel/issues/1169 & 1369 #else m_mapProvider = "osm"; @@ -219,6 +220,7 @@ QByteArray ADSBDemodSettings::serialize() const s.writeString(78, m_maptilerAPIKey); s.writeString(80, m_cartoDBAPIKey); + s.writeString(81, m_mapBoxAPIKey); s.writeBool(79, m_useLiveryIcons); for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) { @@ -368,14 +370,20 @@ bool ADSBDemodSettings::deserialize(const QByteArray& data) d.readString(78, &m_maptilerAPIKey, ""); d.readString(80, &m_cartoDBAPIKey, ""); + d.readString(81, &m_mapBoxAPIKey, ""); d.readBool(79, &m_useLiveryIcons, true); applyPalette(); -#ifdef LINUX +#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 15, 13)) if (m_mapProvider == "osm") { m_mapProvider = "mapboxgl"; } +#else + // mapboxgl doesn't work without a key + if ((m_mapProvider == "mapboxgl") && m_mapBoxAPIKey.isEmpty()) { + m_mapProvider = "osm"; + } #endif for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) { @@ -602,6 +610,9 @@ void ADSBDemodSettings::applySettings(const QStringList& settingsKeys, const ADS if (settingsKeys.contains("cartoDBAPIKey")) { m_cartoDBAPIKey = settings.m_cartoDBAPIKey; } + if (settingsKeys.contains("mapBoxAPIKey")) { + m_mapBoxAPIKey = settings.m_mapBoxAPIKey; + } if (settingsKeys.contains("logFilename")) { m_logFilename = settings.m_logFilename; } @@ -814,6 +825,9 @@ QString ADSBDemodSettings::getDebugString(const QStringList& settingsKeys, bool if (settingsKeys.contains("cartoDBAPIKey") || force) { ostr << " m_cartoDBAPIKey: " << m_cartoDBAPIKey.toStdString(); } + if (settingsKeys.contains("mapBoxAPIKey") || force) { + ostr << " m_mapBoxAPIKey: " << m_mapBoxAPIKey.toStdString(); + } if (settingsKeys.contains("logFilename") || force) { ostr << " m_logFilename: " << m_logFilename.toStdString(); } diff --git a/plugins/channelrx/demodadsb/adsbdemodsettings.h b/plugins/channelrx/demodadsb/adsbdemodsettings.h index 4636ebcfa..bf403e06d 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsettings.h +++ b/plugins/channelrx/demodadsb/adsbdemodsettings.h @@ -198,6 +198,7 @@ struct ADSBDemodSettings QString m_checkWXAPIKey; //!< checkwxapi.com API key QString m_maptilerAPIKey; //!< maptiler.com API key (for osm/satellite map) QString m_cartoDBAPIKey; //!< carto.com API key (for the aviation maps, which use CartoDB tiles without labels) + QString m_mapBoxAPIKey; //!< mapbox.com API key (for mapboxgl map provider) QString m_logFilename; bool m_logEnabled; diff --git a/plugins/channelrx/demodadsb/readme.md b/plugins/channelrx/demodadsb/readme.md index 0f14e1452..675878981 100644 --- a/plugins/channelrx/demodadsb/readme.md +++ b/plugins/channelrx/demodadsb/readme.md @@ -99,9 +99,10 @@ Map: ![ADS-B Demodulator map display settings](../../../doc/img/ADSBDemod_plugin_displaysettings_map.png) -* The map provider. This can be osm for OpenStreetMaps or mapboxgl for Mapbox. mapboxgl is not supported on Windows. mapboxgl should be used on Linux with Qt 5.15.3, as osm maps will cause SDRangel to hang, due to a bug in Qt. +* The map provider. This can be osm for OpenStreetMaps or mapboxgl for Mapbox. mapboxgl is not supported on Windows. mapboxgl should be used on Linux with Qt versions earlier than 5.15.13, as osm maps will cause SDRangel to hang, due to a bug in Qt. mapboxgl requires a Mapbox API key. * The type of map that will be displayed. This can either be a light or dark aviation map (with no place names to reduce clutter), a street map or satellite imagery. * A [Maptiler](https://www.maptiler.com/) API key can be entered in order to use satellite map imagery. Although you may be able to view satellite imagery without entering a key, if too many users do this, we may exceed our usage quota and then the imagery will be unavailable for all. +* A [Mapbox](https://www.mapbox.com/) API key must be entered in order to use the mapboxgl map provider. * The minimum zoom level (0 min zoom - 15 max zoom) at which aircraft icons will be scaled. * The minimum size airport that will be displayed on the map: small, medium or large. Use small to display GA airfields, medium for regional airports and large for international airports. * Whether or not to display heliports. diff --git a/plugins/feature/map/mapsettings.cpp b/plugins/feature/map/mapsettings.cpp index 44219308d..539ffc81a 100644 --- a/plugins/feature/map/mapsettings.cpp +++ b/plugins/feature/map/mapsettings.cpp @@ -276,7 +276,7 @@ MapSettings::~MapSettings() void MapSettings::resetToDefaults() { m_displayNames = true; -#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 15, 13)) m_mapProvider = "mapboxgl"; // osm maps do not work in some versions of Linux https://github.com/f4exb/sdrangel/issues/1169 & 1369 #else m_mapProvider = "osm"; @@ -479,12 +479,17 @@ bool MapSettings::deserialize(const QByteArray& data) d.readBool(1, &m_displayNames, true); d.readString(2, &m_mapProvider, "osm"); -#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + d.readString(3, &m_mapBoxAPIKey, ""); +#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 15, 13)) if (m_mapProvider == "osm") { m_mapProvider = "mapboxgl"; } +#else + // mapboxgl doesn't work without a key + if ((m_mapProvider == "mapboxgl") && m_mapBoxAPIKey.isEmpty()) { + m_mapProvider = "osm"; + } #endif - d.readString(3, &m_mapBoxAPIKey, ""); d.readString(4, &m_mapBoxStyles, ""); d.readString(8, &m_title, "Map"); d.readU32(9, &m_rgbColor, QColor(225, 25, 99).rgba()); diff --git a/plugins/feature/map/readme.md b/plugins/feature/map/readme.md index 45cf94679..da94395e0 100644 --- a/plugins/feature/map/readme.md +++ b/plugins/feature/map/readme.md @@ -322,7 +322,7 @@ For the 2D map, the settings include: or file:///opt/install/custom-map if using a map stored locally, such a map created with [QGIS](https://qgis.org/) using the "Generate XYZ tiles (Directory)" tool or [gdal2tiles](https://gdal.org/programs/gdal2tiles.html) or any other tool that creates map images compatible with Google Maps, OpenLayers and Leaflet. -* When MapboxGL is used as the provider, custom styles can be specified. +* When MapboxGL is used as the provider, custom styles can be specified. MapboxGL requires a Mapbox API key to be entered. * Whether aircraft are displayed using icons showing their airline's livery, instead of black icons. Livery icons are matched from the aircraft type and operator, in the same way as 3D models, so require the 3D models to have been downloaded. Aircraft without a matching livery icon are displayed with the plain icon sent by the source plugin. For the 3D map, the settings include: diff --git a/plugins/feature/vorlocalizer/CMakeLists.txt b/plugins/feature/vorlocalizer/CMakeLists.txt index a8eec9583..4b99eaba2 100644 --- a/plugins/feature/vorlocalizer/CMakeLists.txt +++ b/plugins/feature/vorlocalizer/CMakeLists.txt @@ -28,16 +28,22 @@ if(NOT SERVER_MODE) ${vor_SOURCES} vorlocalizergui.cpp vorlocalizergui.ui + vorlocalizerdisplaydialog.cpp + vorlocalizerdisplaydialog.ui vorlocalizermap.qrc vorlocalizericons.qrc ) set(vor_HEADERS ${vor_HEADERS} vorlocalizergui.h + vorlocalizerdisplaydialog.h ) set(TARGET_NAME ${PLUGINS_PREFIX}vorlocalizer) set(TARGET_LIB "Qt::Widgets" Qt::Quick Qt::QuickWidgets Qt::Positioning) + if(Qt${QT_DEFAULT_MAJOR_VERSION}Location_FOUND) + list(APPEND TARGET_LIB Qt::Location) + endif() set(TARGET_LIB_GUI "sdrgui") set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR}) else() diff --git a/plugins/feature/vorlocalizer/readme.md b/plugins/feature/vorlocalizer/readme.md index 45ea4257f..b7134d21d 100644 --- a/plugins/feature/vorlocalizer/readme.md +++ b/plugins/feature/vorlocalizer/readme.md @@ -82,6 +82,8 @@ Double clicking on a VOR will select and add it to the list of VORs to demodulat When a signal from a VOR is correctly being demodulated, a radial line will be drawn on the map, at the angle provided by the VOR demodulator or their average over the round robin turn if this is the case. Your receiver should be somewhere along this radial line. The length of the radial line is set according to the range of the VOR as recorded in the database, which is valid for aircraft at altitude. Range on the ground will be considerably less. An approximate position for the receiver is where the radial lines from two or more VORs intersect. +The display settings button (next to the Draw Radials Adjusted for Magnetic Declination button) opens a dialog to select the map provider. This can be osm for OpenStreetMaps or mapboxgl for Mapbox. mapboxgl should be used on Linux with Qt versions earlier than 5.15.13, as osm maps will cause SDRangel to hang, due to a bug in Qt. mapboxgl requires a [Mapbox](https://www.mapbox.com/) API key, which can be entered in the same dialog. + ![VOR Demodulator Map](../../../doc/img/VORDemod_plugin_map.png)

Attribution

diff --git a/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.cpp b/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.cpp new file mode 100644 index 000000000..929add091 --- /dev/null +++ b/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.cpp @@ -0,0 +1,67 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Jon Beniston, M7RCE // +// // +// 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 as version 3 of the License, or // +// (at your option) any later version. // +// // +// 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifdef QT_LOCATION_FOUND +#include +#endif + +#include "vorlocalizerdisplaydialog.h" + +VORLocalizerDisplayDialog::VORLocalizerDisplayDialog(VORLocalizerSettings *settings, QWidget* parent) : + QDialog(parent), + ui(new Ui::VORLocalizerDisplayDialog), + m_settings(settings) +{ + ui->setupUi(this); + +#ifdef QT_LOCATION_FOUND + QStringList mapProviders = QGeoServiceProvider::availableServiceProviders(); + if (!mapProviders.contains("osm")) { + ui->mapProvider->removeItem(ui->mapProvider->findText("osm")); + } + if (!mapProviders.contains("mapboxgl")) { + ui->mapProvider->removeItem(ui->mapProvider->findText("mapboxgl")); + } +#endif + + int idx = ui->mapProvider->findText(settings->m_mapProvider); + if (idx != -1) { + ui->mapProvider->setCurrentIndex(idx); + } + ui->mapBoxAPIKey->setText(settings->m_mapBoxAPIKey); +} + +VORLocalizerDisplayDialog::~VORLocalizerDisplayDialog() +{ + delete ui; +} + +void VORLocalizerDisplayDialog::accept() +{ + if (!ui->mapProvider->currentText().isEmpty() && (m_settings->m_mapProvider != ui->mapProvider->currentText())) + { + m_settings->m_mapProvider = ui->mapProvider->currentText(); + m_settingsKeys.append("mapProvider"); + } + if (m_settings->m_mapBoxAPIKey != ui->mapBoxAPIKey->text()) + { + m_settings->m_mapBoxAPIKey = ui->mapBoxAPIKey->text(); + m_settingsKeys.append("mapBoxAPIKey"); + } + + QDialog::accept(); +} diff --git a/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.h b/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.h new file mode 100644 index 000000000..ff2402117 --- /dev/null +++ b/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.h @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Jon Beniston, M7RCE // +// // +// 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 as version 3 of the License, or // +// (at your option) any later version. // +// // +// 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_VORLOCALIZERDISPLAYDIALOG_H +#define INCLUDE_VORLOCALIZERDISPLAYDIALOG_H + +#include "ui_vorlocalizerdisplaydialog.h" +#include "vorlocalizersettings.h" + +class VORLocalizerDisplayDialog : public QDialog { + Q_OBJECT + +public: + explicit VORLocalizerDisplayDialog(VORLocalizerSettings *settings, QWidget* parent = nullptr); + ~VORLocalizerDisplayDialog(); + + const QStringList& getSettingsKeys() const { return m_settingsKeys; }; + +private slots: + void accept(); + +private: + Ui::VORLocalizerDisplayDialog* ui; + VORLocalizerSettings *m_settings; + QStringList m_settingsKeys; +}; + +#endif // INCLUDE_VORLOCALIZERDISPLAYDIALOG_H diff --git a/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.ui b/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.ui new file mode 100644 index 000000000..ee687ccff --- /dev/null +++ b/plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.ui @@ -0,0 +1,111 @@ + + + VORLocalizerDisplayDialog + + + + 0 + 0 + 400 + 120 + + + + + 9 + + + + Display Settings + + + + + + + + Map provider + + + + + + + Mapping service provider + + + + osm + + + + + mapboxgl + + + + + + + + Mapbox API key + + + + + + + API key for Mapbox (https://www.mapbox.com), required for the mapboxgl map provider + + + + + + + + + Qt::Orientation::Horizontal + + + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + + + + + + + + buttonBox + accepted() + VORLocalizerDisplayDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + VORLocalizerDisplayDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.cpp b/plugins/feature/vorlocalizer/vorlocalizergui.cpp index bb4f8396b..d3d6cc9cc 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.cpp +++ b/plugins/feature/vorlocalizer/vorlocalizergui.cpp @@ -29,6 +29,9 @@ #include #include #include +#ifdef QT_LOCATION_FOUND +#include +#endif #include "feature/featureuiset.h" #include "dsp/dspcommands.h" @@ -46,6 +49,7 @@ #include "vorlocalizerreport.h" #include "vorlocalizersettings.h" #include "vorlocalizergui.h" +#include "vorlocalizerdisplaydialog.h" #include "SWGMapItem.h" @@ -990,6 +994,21 @@ void VORLocalizerGUI::onWidgetRolled(QWidget* widget, bool rollDown) rollupContents->saveState(m_rollupState); } +void VORLocalizerGUI::on_displaySettings_clicked() +{ + VORLocalizerDisplayDialog dialog(&m_settings); + new DialogPositioner(&dialog, true); + + if (dialog.exec() == QDialog::Accepted) + { + m_settingsKeys.append(dialog.getSettingsKeys()); + applySettings(); + if (dialog.getSettingsKeys().contains("mapProvider") || dialog.getSettingsKeys().contains("mapBoxAPIKey")) { + applyMapSettings(); + } + } +} + void VORLocalizerGUI::onMenuDialogCalled(const QPoint &p) { if (m_contextMenuType == ContextMenuType::ContextMenuChannelSettings) @@ -1065,14 +1084,34 @@ void VORLocalizerGUI::applyMapSettings() zoom = 10.0; } + // Check requested map provider is available - if not, try the other + QString mapProvider = m_settings.m_mapProvider; +#ifdef QT_LOCATION_FOUND + QStringList mapProviders = QGeoServiceProvider::availableServiceProviders(); + if ((mapProvider == "osm") && (!mapProviders.contains(mapProvider))) { + mapProvider = "mapboxgl"; + } + if ((mapProvider == "mapboxgl") && (!mapProviders.contains(mapProvider))) { + mapProvider = "osm"; + } +#endif + // Create the map using the specified provider - QQmlProperty::write(item, "mapProvider", m_settings.m_mapProvider); + QQmlProperty::write(item, "mapProvider", mapProvider); QVariantMap parameters; QString mapType; - if (m_settings.m_mapProvider == "osm") { + if (mapProvider == "osm") + { mapType = "Street Map"; - } else if (m_settings.m_mapProvider == "mapboxgl") { + } + else if (mapProvider == "mapboxgl") + { + if (!m_settings.m_mapBoxAPIKey.isEmpty()) { + parameters["mapboxgl.access_token"] = m_settings.m_mapBoxAPIKey; + } else { + qWarning() << "VORLocalizerGUI::applyMapSettings - mapboxgl map provider requires a Mapbox API key"; + } mapType = "mapbox://styles/mapbox/streets-v10"; } @@ -1423,6 +1462,7 @@ void VORLocalizerGUI::makeUIConnections() QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &VORLocalizerGUI::on_startStop_toggled); QObject::connect(ui->getOpenAIPVORDB, &QPushButton::clicked, this, &VORLocalizerGUI::on_getOpenAIPVORDB_clicked); QObject::connect(ui->magDecAdjust, &ButtonSwitch::toggled, this, &VORLocalizerGUI::on_magDecAdjust_toggled); + QObject::connect(ui->displaySettings, &QToolButton::clicked, this, &VORLocalizerGUI::on_displaySettings_clicked); QObject::connect(ui->rrTime, &QDial::valueChanged, this, &VORLocalizerGUI::on_rrTime_valueChanged); QObject::connect(ui->centerShift, &QDial::valueChanged, this, &VORLocalizerGUI::on_centerShift_valueChanged); } diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.h b/plugins/feature/vorlocalizer/vorlocalizergui.h index 9a1eda683..576cbdbaa 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.h +++ b/plugins/feature/vorlocalizer/vorlocalizergui.h @@ -297,6 +297,7 @@ private slots: void on_startStop_toggled(bool checked); void on_getOpenAIPVORDB_clicked(); void on_magDecAdjust_toggled(bool checked); + void on_displaySettings_clicked(); void on_rrTime_valueChanged(int value); void on_centerShift_valueChanged(int value); void channelsRefresh(); diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.ui b/plugins/feature/vorlocalizer/vorlocalizergui.ui index c40b6e57f..46b8eaf15 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.ui +++ b/plugins/feature/vorlocalizer/vorlocalizergui.ui @@ -119,6 +119,20 @@
+ + + + Open display settings dialog + + + ... + + + + :/listing.png:/listing.png + + + diff --git a/plugins/feature/vorlocalizer/vorlocalizersettings.cpp b/plugins/feature/vorlocalizer/vorlocalizersettings.cpp index 73ab1e25e..daba35ea6 100644 --- a/plugins/feature/vorlocalizer/vorlocalizersettings.cpp +++ b/plugins/feature/vorlocalizer/vorlocalizersettings.cpp @@ -44,11 +44,12 @@ void VORLocalizerSettings::resetToDefaults() m_reverseAPIFeatureSetIndex = 0; m_reverseAPIFeatureIndex = 0; m_workspaceIndex = 0; -#ifdef LINUX +#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 15, 13)) m_mapProvider = "mapboxgl"; // osm maps do not work in some versions of Linux https://github.com/f4exb/sdrangel/issues/1169 & 1369 #else m_mapProvider = "osm"; #endif + m_mapBoxAPIKey = ""; for (int i = 0; i < VORDEMOD_COLUMNS; i++) { @@ -79,6 +80,7 @@ QByteArray VORLocalizerSettings::serialize() const s.writeS32(20, m_workspaceIndex); s.writeBlob(21, m_geometryBytes); s.writeString(22, m_mapProvider); + s.writeString(23, m_mapBoxAPIKey); for (int i = 0; i < VORDEMOD_COLUMNS; i++) { s.writeS32(100 + i, m_columnIndexes[i]); @@ -117,7 +119,7 @@ bool VORLocalizerSettings::deserialize(const QByteArray& data) d.readString(15, &m_reverseAPIAddress, "127.0.0.1"); d.readU32(16, &utmp, 0); - if ((utmp > 1023) && (utmp < 65535)) { + if ((utmp > 1023) && (utmp <= 65535)) { m_reverseAPIPort = utmp; } else { m_reverseAPIPort = 8888; @@ -136,10 +138,15 @@ bool VORLocalizerSettings::deserialize(const QByteArray& data) d.readS32(20, &m_workspaceIndex, 0); d.readBlob(21, &m_geometryBytes); -#ifdef LINUX + d.readString(23, &m_mapBoxAPIKey, ""); +#if defined(LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 15, 13)) d.readString(22, &m_mapProvider, "mapboxgl"); #else d.readString(22, &m_mapProvider, "osm"); + // mapboxgl doesn't work without a key, as Mapbox rejects Qt's development token + if ((m_mapProvider == "mapboxgl") && m_mapBoxAPIKey.isEmpty()) { + m_mapProvider = "osm"; + } #endif for (int i = 0; i < VORDEMOD_COLUMNS; i++) { @@ -209,6 +216,9 @@ void VORLocalizerSettings::applySettings(const QStringList& settingsKeys, const if (settingsKeys.contains("mapProvider")) { m_mapProvider = settings.m_mapProvider; } + if (settingsKeys.contains("mapBoxAPIKey")) { + m_mapBoxAPIKey = settings.m_mapBoxAPIKey; + } if (settingsKeys.contains("columnIndexes")) { @@ -265,6 +275,9 @@ QString VORLocalizerSettings::getDebugString(const QStringList& settingsKeys, bo if (settingsKeys.contains("mapProvider") || force) { ostr << " m_mapProvider: " << m_mapProvider.toStdString(); } + if (settingsKeys.contains("mapBoxAPIKey") || force) { + ostr << " m_mapBoxAPIKey: " << m_mapBoxAPIKey.toStdString(); + } if (settingsKeys.contains("columnIndexes")) { diff --git a/plugins/feature/vorlocalizer/vorlocalizersettings.h b/plugins/feature/vorlocalizer/vorlocalizersettings.h index c359fd8bb..3729a6858 100644 --- a/plugins/feature/vorlocalizer/vorlocalizersettings.h +++ b/plugins/feature/vorlocalizer/vorlocalizersettings.h @@ -79,6 +79,7 @@ struct VORLocalizerSettings int m_workspaceIndex; QByteArray m_geometryBytes; QString m_mapProvider; + QString m_mapBoxAPIKey; //!< mapbox.com API key (for mapboxgl map provider) static const int VORDEMOD_COLUMNS = 10; static const int VOR_COL_NAME = 0;