diff --git a/gpxsee.pro b/gpxsee.pro index e23d3a93..872e31d6 100644 --- a/gpxsee.pro +++ b/gpxsee.pro @@ -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 \ diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index d1cb33ee..0e315f8f 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -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::const_iterator it = _options.pluginParams.constBegin(); diff --git a/src/GUI/markerinfoitem.h b/src/GUI/markerinfoitem.h index ba0f24b1..e3cc1a80 100644 --- a/src/GUI/markerinfoitem.h +++ b/src/GUI/markerinfoitem.h @@ -2,6 +2,7 @@ #define MARKERINFOITEM_H #include +#include #include "format.h" class Coordinates; diff --git a/src/GUI/settings.cpp b/src/GUI/settings.cpp new file mode 100644 index 00000000..efa4211d --- /dev/null +++ b/src/GUI/settings.cpp @@ -0,0 +1,22 @@ +#include +#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; +} diff --git a/src/GUI/settings.h b/src/GUI/settings.h index cc4fc5b4..1322d788 100644 --- a/src/GUI/settings.h +++ b/src/GUI/settings.h @@ -1,14 +1,21 @@ #ifndef SETTINGS_H #define SETTINGS_H -#include +#include +#include +#include +#include #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 diff --git a/src/data/graph.h b/src/data/graph.h index 7647b51e..7860ff13 100644 --- a/src/data/graph.h +++ b/src/data/graph.h @@ -3,6 +3,7 @@ #include #include +#include #include #include