Browse Source

Add MapBox API key setting. Default to osm maps on Linux on Qt 5.15.13 and above.

chirpmodem-v8.1.0
Jon Beniston 4 weeks ago
parent
commit
d45dcfdc2a
  1. 6
      plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp
  2. 54
      plugins/channelrx/demodadsb/adsbdemoddisplaydialog.ui
  3. 6
      plugins/channelrx/demodadsb/adsbdemodgui.cpp
  4. 18
      plugins/channelrx/demodadsb/adsbdemodsettings.cpp
  5. 1
      plugins/channelrx/demodadsb/adsbdemodsettings.h
  6. 3
      plugins/channelrx/demodadsb/readme.md
  7. 11
      plugins/feature/map/mapsettings.cpp
  8. 2
      plugins/feature/map/readme.md
  9. 6
      plugins/feature/vorlocalizer/CMakeLists.txt
  10. 2
      plugins/feature/vorlocalizer/readme.md
  11. 67
      plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.cpp
  12. 42
      plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.h
  13. 111
      plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.ui
  14. 46
      plugins/feature/vorlocalizer/vorlocalizergui.cpp
  15. 1
      plugins/feature/vorlocalizer/vorlocalizergui.h
  16. 14
      plugins/feature/vorlocalizer/vorlocalizergui.ui
  17. 19
      plugins/feature/vorlocalizer/vorlocalizersettings.cpp
  18. 1
      plugins/feature/vorlocalizer/vorlocalizersettings.h

6
plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp

@ -70,6 +70,7 @@ ADSBDemodDisplayDialog::ADSBDemodDisplayDialog(ADSBDemodSettings *settings, QWid @@ -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() @@ -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();

54
plugins/channelrx/demodadsb/adsbdemoddisplaydialog.ui

@ -277,14 +277,14 @@ @@ -277,14 +277,14 @@
</item>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="aircraftMinZoomLabel">
<property name="text">
<string>Zoom level for aircraft scaling</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QSpinBox" name="aircraftMinZoom">
<property name="toolTip">
<string>When map zoom (0 min zoom - 15 max zoom) is higher than this value, aircraft icon size will be scaled</string>
@ -294,14 +294,14 @@ @@ -294,14 +294,14 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="airportSizeLabel">
<property name="text">
<string>Display airports with size</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="airportSize">
<property name="toolTip">
<string>Sets the minimum airport size that will be displayed on the map</string>
@ -323,14 +323,14 @@ @@ -323,14 +323,14 @@
</item>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="heliportsLabel">
<property name="text">
<string>Display heliports</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QCheckBox" name="heliports">
<property name="toolTip">
<string>When checked, heliports are displayed on the map</string>
@ -340,14 +340,14 @@ @@ -340,14 +340,14 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="airportRangeLabel">
<property name="text">
<string>Airport display distance (km)</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QSpinBox" name="airportRange">
<property name="toolTip">
<string>Displays airports within the specified distance in kilometres from My Position</string>
@ -357,14 +357,14 @@ @@ -357,14 +357,14 @@
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="airspacesLabel">
<property name="text">
<string>Airspaces to display</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QListWidget" name="airspaces">
<property name="toolTip">
<string>Airspace categories to display</string>
@ -521,14 +521,14 @@ @@ -521,14 +521,14 @@
</item>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="airspaceRangeLabel">
<property name="text">
<string>Airspace display distance (km)</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QSpinBox" name="airspaceRange">
<property name="toolTip">
<string>Displays airspace within the specified distance in kilometres from My Position</string>
@ -538,14 +538,14 @@ @@ -538,14 +538,14 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="displayNavAids">
<property name="text">
<string>Display NAVAIDs</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QCheckBox" name="navAids">
<property name="toolTip">
<string>Display NAVAIDs such as VORs and NDBs</string>
@ -555,7 +555,7 @@ @@ -555,7 +555,7 @@
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QCheckBox" name="atcCallsigns">
<property name="toolTip">
<string>Use ATC callsigns (SPEEDBIRD) rather than ICAO (BAW) for aircraft labels on map</string>
@ -565,21 +565,21 @@ @@ -565,21 +565,21 @@
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="atcCallsignsLabel">
<property name="text">
<string>Use ATC callsigns on map</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QComboBox" name="flightPathPalette">
<property name="toolTip">
<string>Colour palette to use for aircraft flight paths</string>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLabel" name="flightPathPaletteLabel">
<property name="text">
<string>Flight path palette</string>
@ -617,14 +617,28 @@ @@ -617,14 +617,28 @@
</property>
</widget>
</item>
<item row="13" column="0">
<item row="4" column="0">
<widget class="QLabel" name="mapBoxAPIKeyLabel">
<property name="text">
<string>Mapbox API key</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="mapBoxAPIKey">
<property name="toolTip">
<string>API key for Mapbox (https://www.mapbox.com), required for the mapboxgl map provider</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="useLiveryIconsLabel">
<property name="text">
<string>Livery aircraft icons</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QCheckBox" name="useLiveryIcons">
<property name="toolTip">
<string>Display aircraft icons showing airline liveries, matched from the aircraft type and operator, instead of black icons</string>

6
plugins/channelrx/demodadsb/adsbdemodgui.cpp

@ -2360,6 +2360,11 @@ void ADSBDemodGUI::applyMapSettings() @@ -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) @@ -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)

18
plugins/channelrx/demodadsb/adsbdemodsettings.cpp

@ -84,6 +84,7 @@ void ADSBDemodSettings::resetToDefaults() @@ -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() @@ -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 @@ -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) @@ -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 @@ -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 @@ -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();
}

1
plugins/channelrx/demodadsb/adsbdemodsettings.h

@ -198,6 +198,7 @@ struct ADSBDemodSettings @@ -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;

3
plugins/channelrx/demodadsb/readme.md

@ -99,9 +99,10 @@ Map: @@ -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.

11
plugins/feature/map/mapsettings.cpp

@ -276,7 +276,7 @@ MapSettings::~MapSettings() @@ -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) @@ -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());

2
plugins/feature/map/readme.md

@ -322,7 +322,7 @@ For the 2D map, the settings include: @@ -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:

6
plugins/feature/vorlocalizer/CMakeLists.txt

@ -28,16 +28,22 @@ if(NOT SERVER_MODE) @@ -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()

2
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 @@ -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)
<h2>Attribution</h2>

67
plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.cpp

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifdef QT_LOCATION_FOUND
#include <QGeoServiceProvider>
#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();
}

42
plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.h

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#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

111
plugins/feature/vorlocalizer/vorlocalizerdisplaydialog.ui

@ -0,0 +1,111 @@ @@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VORLocalizerDisplayDialog</class>
<widget class="QDialog" name="VORLocalizerDisplayDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>120</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Display Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="mapLayout">
<item row="0" column="0">
<widget class="QLabel" name="mapProviderLabel">
<property name="text">
<string>Map provider</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mapProvider">
<property name="toolTip">
<string>Mapping service provider</string>
</property>
<item>
<property name="text">
<string>osm</string>
</property>
</item>
<item>
<property name="text">
<string>mapboxgl</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mapBoxAPIKeyLabel">
<property name="text">
<string>Mapbox API key</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mapBoxAPIKey">
<property name="toolTip">
<string>API key for Mapbox (https://www.mapbox.com), required for the mapboxgl map provider</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>VORLocalizerDisplayDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>VORLocalizerDisplayDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

46
plugins/feature/vorlocalizer/vorlocalizergui.cpp

@ -29,6 +29,9 @@ @@ -29,6 +29,9 @@
#include <QQmlProperty>
#include <QMessageBox>
#include <QAction>
#ifdef QT_LOCATION_FOUND
#include <QGeoServiceProvider>
#endif
#include "feature/featureuiset.h"
#include "dsp/dspcommands.h"
@ -46,6 +49,7 @@ @@ -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) @@ -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() @@ -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() @@ -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);
}

1
plugins/feature/vorlocalizer/vorlocalizergui.h

@ -297,6 +297,7 @@ private slots: @@ -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();

14
plugins/feature/vorlocalizer/vorlocalizergui.ui

@ -119,6 +119,20 @@ @@ -119,6 +119,20 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="displaySettings">
<property name="toolTip">
<string>Open display settings dialog</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/listing.png</normaloff>:/listing.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">

19
plugins/feature/vorlocalizer/vorlocalizersettings.cpp

@ -44,11 +44,12 @@ void VORLocalizerSettings::resetToDefaults() @@ -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 @@ -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) @@ -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) @@ -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 @@ -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 @@ -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"))
{

1
plugins/feature/vorlocalizer/vorlocalizersettings.h

@ -79,6 +79,7 @@ struct VORLocalizerSettings @@ -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;

Loading…
Cancel
Save