1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Properly use the default positioning plugin as the default option

This commit is contained in:
Martin Tůma 2023-02-01 22:26:36 +01:00
parent 973abedf3e
commit d6d316676c
6 changed files with 47 additions and 10 deletions

View File

@ -263,6 +263,7 @@ SOURCES += src/main.cpp \
src/GUI/motioninfoitem.cpp \
src/GUI/navigationwidget.cpp \
src/GUI/pluginparameters.cpp \
src/GUI/settings.cpp \
src/common/coordinates.cpp \
src/common/rectc.cpp \
src/common/range.cpp \

View File

@ -2641,8 +2641,8 @@ void GUI::writeSettings()
settings.setValue(DEM_USERNAME_SETTING, _options.demUsername);
if (_options.demPassword != DEM_PASSWORD_DEFAULT)
settings.setValue(DEM_PASSWORD_SETTING, _options.demPassword);
// the plugins order is random so always store the value
settings.setValue(POSITION_PLUGIN_SETTING, _options.plugin);
if (_options.plugin != POSITION_PLUGIN_DEFAULT)
settings.setValue(POSITION_PLUGIN_SETTING, _options.plugin);
index = 0;
for (QMap<QString, QVariantMap>::const_iterator it
= _options.pluginParams.constBegin();

View File

@ -2,6 +2,7 @@
#define MARKERINFOITEM_H
#include <QGraphicsItem>
#include <QFont>
#include "format.h"
class Coordinates;

22
src/GUI/settings.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <QGeoPositionInfoSource>
#include "settings.h"
static QString defaultPlugin()
{
QString source;
QGeoPositionInfoSource *ps = QGeoPositionInfoSource::createDefaultSource(0);
if (!ps)
return source;
source = ps->sourceName();
delete ps;
return source;
}
const QString &Settings::positionPlugin()
{
static QString plugin(defaultPlugin());
return plugin;
}

View File

@ -1,14 +1,21 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QtGlobal>
#include <QLocale>
#include <QDir>
#include <QPageLayout>
#include <QPageSize>
#include "common/config.h"
#include "common/util.h"
#include "data/graph.h"
#include "format.h"
#include "units.h"
#include "timetype.h"
#include "markerinfoitem.h"
#define IMPERIAL_UNITS() \
(QLocale::system().measurementSystem() == QLocale::ImperialSystem)
#define POSITION_PLUGIN() \
(QGeoPositionInfoSource::availableSources().isEmpty() \
? "" : QGeoPositionInfoSource::availableSources().first())
#define CURRENT_PATH(filename) \
QDir::current().filePath(filename)
@ -214,7 +221,7 @@
#define DEM_PASSWORD_SETTING "demPassword"
#define DEM_PASSWORD_DEFAULT ""
#define POSITION_PLUGIN_SETTING "positionPlugin"
#define POSITION_PLUGIN_DEFAULT POSITION_PLUGIN()
#define POSITION_PLUGIN_DEFAULT Settings::positionPlugin()
#define POSITION_PLUGIN_PARAMS_PREFIX "pluginParameters"
#define POSITION_PLUGIN_PARAMS_PLUGIN "plugin"
#define POSITION_PLUGIN_PARAMS_PARAM "parameters"
@ -255,10 +262,15 @@
#define HIDPI_MAP_SETTING "HiDPIMap"
#define HIDPI_MAP_DEFAULT true
#define DATA_PATH_SETTING "dataPath"
#define DATA_PATH_DEFAULT QString()
#define DATA_PATH_DEFAULT ""
#define MAPS_PATH_SETTING "mapsPath"
#define MAPS_PATH_DEFAULT QString()
#define MAPS_PATH_DEFAULT ""
#define POI_PATH_SETTING "poiPath"
#define POI_PATH_DEFAULT QString()
#define POI_PATH_DEFAULT ""
namespace Settings
{
const QString &positionPlugin();
}
#endif // SETTINGS_H

View File

@ -3,6 +3,7 @@
#include <QList>
#include <QVector>
#include <QColor>
#include <QDebug>
#include <cmath>