diff --git a/.appveyor.yml b/.appveyor.yml index 96cc627d..a14a9800 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -version: 6.3.{build} +version: 7.0.{build} configuration: Release platform: Any CPU environment: diff --git a/gpxsee.pro b/gpxsee.pro index ccf25897..fe9c90d6 100644 --- a/gpxsee.pro +++ b/gpxsee.pro @@ -1,5 +1,5 @@ TARGET = GPXSee -VERSION = 6.3 +VERSION = 7.0 QT += core \ gui \ @@ -13,7 +13,7 @@ lessThan(QT_MAJOR_VERSION, 5) {QT += opengl} equals(QT_MAJOR_VERSION, 5) : lessThan(QT_MINOR_VERSION, 4) {QT += opengl} INCLUDEPATH += ./src -HEADERS += src/config.h \ +HEADERS += src/common/config.h \ src/common/staticassert.h \ src/common/coordinates.h \ src/common/range.h \ @@ -22,6 +22,8 @@ HEADERS += src/config.h \ src/common/util.h \ src/common/rtree.h \ src/common/kv.h \ + src/common/greatcircle.h \ + src/common/programpaths.h \ src/GUI/app.h \ src/GUI/icons.h \ src/GUI/gui.h \ @@ -74,6 +76,7 @@ HEADERS += src/config.h \ src/GUI/cpuarch.h \ src/GUI/searchpointer.h \ src/GUI/mapview.h \ + src/GUI/font.h \ src/map/projection.h \ src/map/ellipsoid.h \ src/map/datum.h \ @@ -114,6 +117,15 @@ HEADERS += src/config.h \ src/map/crs.h \ src/map/coordinatesystem.h \ src/map/pointd.h \ + src/map/rectd.h \ + src/map/geocentric.h \ + src/map/mercator.h \ + src/map/jnxmap.h \ + src/map/krovak.h \ + src/map/geotiffmap.h \ + src/map/image.h \ + src/map/mbtilesmap.h \ + src/map/osm.h \ src/data/graph.h \ src/data/poi.h \ src/data/waypoint.h \ @@ -133,23 +145,15 @@ HEADERS += src/config.h \ src/data/igcparser.h \ src/data/nmeaparser.h \ src/data/oziparsers.h \ - src/map/rectd.h \ - src/map/geocentric.h \ - src/map/mercator.h \ - src/map/jnxmap.h \ - src/map/krovak.h \ src/data/locparser.h \ - src/data/slfparser.h \ - src/map/geotiffmap.h \ - src/map/image.h \ - src/common/greatcircle.h \ - src/map/mbtilesmap.h \ - src/map/osm.h + src/data/slfparser.h SOURCES += src/main.cpp \ src/common/coordinates.cpp \ src/common/rectc.cpp \ src/common/range.cpp \ src/common/util.cpp \ + src/common/greatcircle.cpp \ + src/common/programpaths.cpp \ src/GUI/app.cpp \ src/GUI/gui.cpp \ src/GUI/axisitem.cpp \ @@ -227,6 +231,15 @@ SOURCES += src/main.cpp \ src/map/wms.cpp \ src/map/crs.cpp \ src/map/coordinatesystem.cpp \ + src/map/geocentric.cpp \ + src/map/mercator.cpp \ + src/map/jnxmap.cpp \ + src/map/krovak.cpp \ + src/map/map.cpp \ + src/map/geotiffmap.cpp \ + src/map/image.cpp \ + src/map/mbtilesmap.cpp \ + src/map/osm.cpp \ src/data/data.cpp \ src/data/poi.cpp \ src/data/track.cpp \ @@ -240,19 +253,8 @@ SOURCES += src/main.cpp \ src/data/igcparser.cpp \ src/data/nmeaparser.cpp \ src/data/oziparsers.cpp \ - src/map/geocentric.cpp \ - src/map/mercator.cpp \ - src/map/jnxmap.cpp \ - src/map/krovak.cpp \ - src/map/map.cpp \ src/data/locparser.cpp \ - src/data/slfparser.cpp \ - src/map/geotiffmap.cpp \ - src/map/image.cpp \ - src/common/greatcircle.cpp \ - src/map/mbtilesmap.cpp \ - src/map/osm.cpp - + src/data/slfparser.cpp RESOURCES += gpxsee.qrc TRANSLATIONS = lang/gpxsee_en.ts \ lang/gpxsee_cs.ts \ diff --git a/pkg/gpxsee.nsi b/pkg/gpxsee.nsi index da648256..562376d5 100644 --- a/pkg/gpxsee.nsi +++ b/pkg/gpxsee.nsi @@ -7,7 +7,7 @@ ; The name of the installer Name "GPXSee" ; Program version -!define VERSION "6.3" +!define VERSION "7.0" ; The file to write OutFile "GPXSee-${VERSION}.exe" diff --git a/pkg/gpxsee64.nsi b/pkg/gpxsee64.nsi index 18c5d640..58ed5be0 100644 --- a/pkg/gpxsee64.nsi +++ b/pkg/gpxsee64.nsi @@ -7,7 +7,7 @@ ; The name of the installer Name "GPXSee" ; Program version -!define VERSION "6.3" +!define VERSION "7.0" ; The file to write OutFile "GPXSee-${VERSION}_x64.exe" diff --git a/src/GUI/app.cpp b/src/GUI/app.cpp index 9d67a3db..d9573dad 100644 --- a/src/GUI/app.cpp +++ b/src/GUI/app.cpp @@ -6,13 +6,14 @@ #include #include #include +#include "common/programpaths.h" +#include "common/config.h" #include "map/downloader.h" #include "map/ellipsoid.h" #include "map/gcs.h" #include "map/pcs.h" #include "opengl.h" #include "gui.h" -#include "config.h" #include "settings.h" #include "app.h" @@ -20,13 +21,21 @@ App::App(int &argc, char **argv) : QApplication(argc, argv), _argc(argc), _argv(argv) { +#if defined(Q_OS_WIN32) || defined(Q_OS_MAC) + setApplicationName(APP_NAME); +#else + setApplicationName(QString(APP_NAME).toLower()); +#endif + setApplicationVersion(APP_VERSION); + QTranslator *gpxsee = new QTranslator(this); - gpxsee->load(QLocale::system(), "gpxsee", "_", TRANSLATIONS_DIR); + gpxsee->load(QLocale::system(), "gpxsee", "_", + ProgramPaths::translationsDir()); installTranslator(gpxsee); QTranslator *qt = new QTranslator(this); #if defined(Q_OS_WIN32) || defined(Q_OS_MAC) - qt->load(QLocale::system(), "qt", "_", TRANSLATIONS_DIR); + qt->load(QLocale::system(), "qt", "_", ProgramPaths::translationsDir()); #else // Q_OS_WIN32 || Q_OS_MAC qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location( QLibraryInfo::TranslationsPath)); @@ -65,14 +74,15 @@ App::~App() delete _gui; } -void App::run() +int App::run() { _gui->show(); - for (int i = 1; i < _argc; i++) - _gui->openFile(QString::fromLocal8Bit(_argv[i])); + QStringList args(arguments()); + for (int i = 1; i < args.count(); i++) + _gui->openFile(args.at(i)); - exec(); + return exec(); } bool App::event(QEvent *event) @@ -87,41 +97,27 @@ bool App::event(QEvent *event) void App::loadDatums() { - QString ef, df; + QString ellipsoidsFile(ProgramPaths::ellipsoidsFile()); + QString gcsFile(ProgramPaths::gcsFile()); - if (QFile::exists(USER_ELLIPSOID_FILE)) - ef = USER_ELLIPSOID_FILE; - else if (QFile::exists(GLOBAL_ELLIPSOID_FILE)) - ef = GLOBAL_ELLIPSOID_FILE; - else + if (ellipsoidsFile.isNull()) qWarning("No ellipsoids file found."); + if (gcsFile.isNull()) + qWarning("No GCS file found."); - if (QFile::exists(USER_GCS_FILE)) - df = USER_GCS_FILE; - else if (QFile::exists(GLOBAL_GCS_FILE)) - df = GLOBAL_GCS_FILE; - else - qWarning("No datums file found."); - - if (!ef.isNull() && !df.isNull()) { - Ellipsoid::loadList(ef); - GCS::loadList(df); + if (!ellipsoidsFile.isNull() && !gcsFile.isNull()) { + Ellipsoid::loadList(ellipsoidsFile); + GCS::loadList(gcsFile); } else qWarning("Maps based on a datum different from WGS84 won't work."); } void App::loadPCSs() { - QString file; + QString pcsFile(ProgramPaths::pcsFile()); - if (QFile::exists(USER_PCS_FILE)) - file = USER_PCS_FILE; - else if (QFile::exists(GLOBAL_PCS_FILE)) - file = GLOBAL_PCS_FILE; - else { + if (pcsFile.isNull()) qWarning("No PCS file found."); - return; - } - - PCS::loadList(file); + else + PCS::loadList(pcsFile); } diff --git a/src/GUI/app.h b/src/GUI/app.h index 9166ff73..52e73a34 100644 --- a/src/GUI/app.h +++ b/src/GUI/app.h @@ -12,7 +12,7 @@ class App : QApplication public: App(int &argc, char **argv); ~App(); - void run(); + int run(); protected: bool event(QEvent *event); diff --git a/src/GUI/axisitem.cpp b/src/GUI/axisitem.cpp index 4e4ec8a7..49d56409 100644 --- a/src/GUI/axisitem.cpp +++ b/src/GUI/axisitem.cpp @@ -1,7 +1,7 @@ #include #include #include "common/util.h" -#include "config.h" +#include "font.h" #include "axisitem.h" diff --git a/src/GUI/elevationgraph.cpp b/src/GUI/elevationgraph.cpp index e377dee4..678d4059 100644 --- a/src/GUI/elevationgraph.cpp +++ b/src/GUI/elevationgraph.cpp @@ -1,7 +1,6 @@ #include #include #include "data/data.h" -#include "config.h" #include "tooltip.h" #include "elevationgraphitem.h" #include "elevationgraph.h" diff --git a/src/GUI/font.h b/src/GUI/font.h new file mode 100644 index 00000000..702ee598 --- /dev/null +++ b/src/GUI/font.h @@ -0,0 +1,7 @@ +#ifndef FONT_H +#define FONT_H + +#define FONT_FAMILY "Arial" +#define FONT_SIZE 12 // px + +#endif // FONT_H diff --git a/src/GUI/graphview.cpp b/src/GUI/graphview.cpp index c2c468c2..00e85e96 100644 --- a/src/GUI/graphview.cpp +++ b/src/GUI/graphview.cpp @@ -8,7 +8,6 @@ #include #include "data/graph.h" #include "opengl.h" -#include "config.h" #include "axisitem.h" #include "slideritem.h" #include "sliderinfoitem.h" diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 38501837..5865e5f6 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -1,4 +1,4 @@ -#include "config.h" +#include "common/config.h" #include #include #include @@ -28,6 +28,7 @@ #include #endif // ENABLE_HIDPI #include +#include "common/programpaths.h" #include "data/data.h" #include "data/poi.h" #include "map/maplist.h" @@ -108,14 +109,9 @@ GUI::GUI() void GUI::loadMaps() { _ml = new MapList(this); - QString dir; + QString mapDir(ProgramPaths::mapDir()); - if (QFile::exists(USER_MAP_DIR)) - dir = USER_MAP_DIR; - else if (QFile::exists(GLOBAL_MAP_DIR)) - dir = GLOBAL_MAP_DIR; - - if (!dir.isNull() && !_ml->loadDir(dir)) + if (!mapDir.isNull() && !_ml->loadDir(mapDir)) qWarning("%s", qPrintable(_ml->errorString())); _map = new EmptyMap(this); @@ -124,14 +120,9 @@ void GUI::loadMaps() void GUI::loadPOIs() { _poi = new POI(this); - QString dir; + QString poiDir(ProgramPaths::poiDir()); - if (QFile::exists(USER_POI_DIR)) - dir = USER_POI_DIR; - else if (QFile::exists(GLOBAL_POI_DIR)) - dir = GLOBAL_POI_DIR; - - if (!dir.isNull() && !_poi->loadDir(dir)) + if (!poiDir.isNull() && !_poi->loadDir(poiDir)) qWarning("%s", qPrintable(_poi->errorString())); } @@ -702,19 +693,13 @@ void GUI::paths() msgBox.setWindowTitle(tr("Paths")); msgBox.setText("

" + tr("Paths") + "

"); msgBox.setInformativeText( - "

" - + tr("Global") + "

" + tr("Map directory:") - + "" + QDir::cleanPath(GLOBAL_MAP_DIR) - + "
" + tr("POI directory:") + "" - + QDir::cleanPath(GLOBAL_POI_DIR) + "
" + "
" + + tr("Map directory:") + "" + + QDir::cleanPath(ProgramPaths::mapDir(true)) + "
" + + tr("POI directory:") + "" + + QDir::cleanPath(ProgramPaths::poiDir(true)) + "
" + tr("GCS/PCS directory:") + "" - + QDir::cleanPath(GLOBAL_CSV_DIR) + "
" - + "

" + tr("User-specific") + "

" - + tr("Map directory:") + "" + QDir::cleanPath(USER_MAP_DIR) - + "
" + tr("POI directory:") + "" - + QDir::cleanPath(USER_POI_DIR) + "
" - + tr("GCS/PCS directory:") + "" - + QDir::cleanPath(USER_CSV_DIR) + "
" + + QDir::cleanPath(ProgramPaths::csvDir(true)) + "
" ); msgBox.exec(); @@ -1615,7 +1600,7 @@ void GUI::dropEvent(QDropEvent *event) void GUI::writeSettings() { - QSettings settings(APP_NAME, APP_NAME); + QSettings settings(qApp->applicationName(), qApp->applicationName()); settings.clear(); settings.beginGroup(WINDOW_SETTINGS_GROUP); @@ -1810,7 +1795,7 @@ void GUI::writeSettings() void GUI::readSettings() { int value; - QSettings settings(APP_NAME, APP_NAME); + QSettings settings(qApp->applicationName(), qApp->applicationName()); settings.beginGroup(WINDOW_SETTINGS_GROUP); resize(settings.value(WINDOW_SIZE_SETTING, WINDOW_SIZE_DEFAULT).toSize()); diff --git a/src/GUI/infoitem.cpp b/src/GUI/infoitem.cpp index ed8e3547..a1afefb1 100644 --- a/src/GUI/infoitem.cpp +++ b/src/GUI/infoitem.cpp @@ -1,6 +1,6 @@ #include #include -#include "config.h" +#include "font.h" #include "infoitem.h" #define PADDING 10 diff --git a/src/GUI/mapview.h b/src/GUI/mapview.h index 675b14e3..14fbcc1b 100644 --- a/src/GUI/mapview.h +++ b/src/GUI/mapview.h @@ -6,12 +6,12 @@ #include #include #include "common/rectc.h" +#include "common/config.h" #include "data/waypoint.h" #include "searchpointer.h" #include "units.h" #include "format.h" #include "palette.h" -#include "config.h" class Data; class POI; diff --git a/src/GUI/optionsdialog.h b/src/GUI/optionsdialog.h index 242baab9..9c931e30 100644 --- a/src/GUI/optionsdialog.h +++ b/src/GUI/optionsdialog.h @@ -2,10 +2,9 @@ #define OPTIONSDIALOG_H #include +#include "common/config.h" #include "palette.h" #include "units.h" -#include "config.h" - class ColorBox; class StyleComboBox; diff --git a/src/GUI/scaleitem.cpp b/src/GUI/scaleitem.cpp index 6e375ef6..17dd2d23 100644 --- a/src/GUI/scaleitem.cpp +++ b/src/GUI/scaleitem.cpp @@ -1,7 +1,8 @@ #include +#include #include #include "common/util.h" -#include "config.h" +#include "font.h" #include "scaleitem.h" diff --git a/src/GUI/sliderinfoitem.cpp b/src/GUI/sliderinfoitem.cpp index e0c770ad..53f19d4c 100644 --- a/src/GUI/sliderinfoitem.cpp +++ b/src/GUI/sliderinfoitem.cpp @@ -1,5 +1,5 @@ #include -#include "config.h" +#include "font.h" #include "sliderinfoitem.h" diff --git a/src/GUI/speedgraph.cpp b/src/GUI/speedgraph.cpp index 30dc4550..e6eea358 100644 --- a/src/GUI/speedgraph.cpp +++ b/src/GUI/speedgraph.cpp @@ -1,6 +1,5 @@ #include #include "data/data.h" -#include "config.h" #include "tooltip.h" #include "format.h" #include "speedgraphitem.h" diff --git a/src/GUI/trackinfo.cpp b/src/GUI/trackinfo.cpp index 6a50cf57..c412ce28 100644 --- a/src/GUI/trackinfo.cpp +++ b/src/GUI/trackinfo.cpp @@ -1,6 +1,5 @@ #include #include -#include "config.h" #include "infoitem.h" #include "trackinfo.h" diff --git a/src/GUI/waypointitem.cpp b/src/GUI/waypointitem.cpp index 811e6754..65b218ee 100644 --- a/src/GUI/waypointitem.cpp +++ b/src/GUI/waypointitem.cpp @@ -1,6 +1,6 @@ #include #include -#include "config.h" +#include "font.h" #include "tooltip.h" #include "waypointitem.h" diff --git a/src/common/config.h b/src/common/config.h new file mode 100644 index 00000000..b7bb0bb8 --- /dev/null +++ b/src/common/config.h @@ -0,0 +1,17 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include + +#define APP_NAME "GPXSee" +#define APP_HOMEPAGE "http://www.gpxsee.org" + +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 1) +#define ENABLE_HTTP2 +#endif // QT >= 5.10.1 + +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) +#define ENABLE_HIDPI +#endif // QT >= 5.6 + +#endif /* CONFIG_H */ diff --git a/src/common/programpaths.cpp b/src/common/programpaths.cpp new file mode 100644 index 00000000..36825483 --- /dev/null +++ b/src/common/programpaths.cpp @@ -0,0 +1,165 @@ +#include +#include +#include "programpaths.h" + + +#define MAP_DIR "maps" +#define POI_DIR "POI" +#define CSV_DIR "csv" +#define TILES_DIR "tiles" +#define TRANSLATIONS_DIR "translations" +#define ELLIPSOID_FILE "ellipsoids.csv" +#define GCS_FILE "gcs.csv" +#define PCS_FILE "pcs.csv" + + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + +#include + +#if defined(Q_OS_WIN32) +#define USER_DIR QDir::homePath() + QString("/AppData/Roaming/") \ + + qApp->applicationName() +#define GLOBAL_DIR QApplication::applicationDirPath() +#elif defined(Q_OS_MAC) +#define USER_DIR QDir::homePath() \ + + QString("/Library/Application Support/") \ + + qApp->applicationName() +#define GLOBAL_DIR QApplication::applicationDirPath() \ + + QString("/../Resources") +#else +#define USER_DIR QDir::homePath() + QString("/.local/share/") \ + + qApp->applicationName() +#define GLOBAL_DIR QString("/usr/share/") + qApp->applicationName() +#endif + +static QString dir(const QString &dirName, bool writable = false) +{ + QDir userDir(QDir(USER_DIR).filePath(dirName)); + + if (writable || userDir.exists()) + return userDir.absolutePath(); + else { + QDir globalDir(QDir(GLOBAL_DIR).filePath(dirName)); + + if (globalDir.exists()) + return globalDir.absolutePath(); + else + return QString(); + } +} + +static QString file(const QString &path, const QString &fileName) +{ + if (path.isNull()) + return QString(); + + QFileInfo fi(QDir(path).filePath(fileName)); + return fi.exists() ? fi.absoluteFilePath() : QString(); +} + +QString ProgramPaths::mapDir(bool writable) +{ + return dir(MAP_DIR, writable); +} + +QString ProgramPaths::poiDir(bool writable) +{ + return dir(POI_DIR, writable); +} + +QString ProgramPaths::csvDir(bool writable) +{ + return dir(CSV_DIR, writable); +} + +QString ProgramPaths::tilesDir() +{ + return dir(TILES_DIR); +} + +QString ProgramPaths::translationsDir() +{ + return dir(TRANSLATIONS_DIR); +} + +QString ProgramPaths::ellipsoidsFile() +{ + return file(dir(CSV_DIR), ELLIPSOID_FILE); +} + +QString ProgramPaths::gcsFile() +{ + return file(dir(CSV_DIR), GCS_FILE); +} + +QString ProgramPaths::pcsFile() +{ + return file(dir(CSV_DIR), PCS_FILE); +} + +#else // QT_VERSION < 5 + +#include + +QString ProgramPaths::mapDir(bool writable) +{ + if (writable) + return QDir(QStandardPaths::writableLocation( + QStandardPaths::AppDataLocation)).filePath(MAP_DIR); + else + return QString(QStandardPaths::locate(QStandardPaths::AppDataLocation, + MAP_DIR, QStandardPaths::LocateDirectory)); +} + +QString ProgramPaths::poiDir(bool writable) +{ + if (writable) + return QDir(QStandardPaths::writableLocation( + QStandardPaths::AppDataLocation)).filePath(POI_DIR); + else + return QString(QStandardPaths::locate(QStandardPaths::AppDataLocation, + POI_DIR, QStandardPaths::LocateDirectory)); +} + +QString ProgramPaths::csvDir(bool writable) +{ + if (writable) + return QDir(QStandardPaths::writableLocation( + QStandardPaths::AppDataLocation)).filePath(CSV_DIR); + else + return QString(QStandardPaths::locate(QStandardPaths::AppDataLocation, + CSV_DIR, QStandardPaths::LocateDirectory)); +} + +QString ProgramPaths::tilesDir() +{ + return QString(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, + TILES_DIR, QStandardPaths::LocateDirectory)); +} + +QString ProgramPaths::translationsDir() +{ + return QString(QStandardPaths::locate(QStandardPaths::AppDataLocation, + TRANSLATIONS_DIR, QStandardPaths::LocateDirectory)); +} + +QString ProgramPaths::ellipsoidsFile() +{ + return QStandardPaths::locate(QStandardPaths::AppDataLocation, + CSV_DIR "/" ELLIPSOID_FILE, QStandardPaths::LocateFile); +} + +QString ProgramPaths::gcsFile() +{ + return QStandardPaths::locate(QStandardPaths::AppDataLocation, + CSV_DIR "/" GCS_FILE, QStandardPaths::LocateFile); +} + +QString ProgramPaths::pcsFile() +{ + return QStandardPaths::locate(QStandardPaths::AppDataLocation, + CSV_DIR "/" PCS_FILE, QStandardPaths::LocateFile); +} + +#endif // QT_VERSION < 5 diff --git a/src/common/programpaths.h b/src/common/programpaths.h new file mode 100644 index 00000000..c8c9b35c --- /dev/null +++ b/src/common/programpaths.h @@ -0,0 +1,18 @@ +#ifndef PROGRAMPATHS_H +#define PROGRAMPATHS_H + +#include + +namespace ProgramPaths +{ + QString mapDir(bool writable = false); + QString poiDir(bool writable = false); + QString csvDir(bool writable = false); + QString tilesDir(); + QString translationsDir(); + QString ellipsoidsFile(); + QString gcsFile(); + QString pcsFile(); +} + +#endif // PROGRAMPATHS_H diff --git a/src/config.h b/src/config.h deleted file mode 100644 index 3f078f44..00000000 --- a/src/config.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#include -#include -#include -#include - -#define APP_NAME "GPXSee" -#define APP_HOMEPAGE "http://www.gpxsee.org" - -#define FONT_FAMILY "Arial" -#define FONT_SIZE 12 // px - -#define MAP_DIR QString("maps") -#define POI_DIR QString("POI") -#define CSV_DIR QString("csv") -#define ELLIPSOID_FILE QString("ellipsoids.csv") -#define GCS_FILE QString("gcs.csv") -#define PCS_FILE QString("pcs.csv") - -#if defined(Q_OS_WIN32) -#define USER_DIR QDir::homePath() + QString("/GPXSee") -#define GLOBAL_DIR QApplication::applicationDirPath() -#elif defined(Q_OS_MAC) -#define USER_DIR QDir::homePath() + QString("/.gpxsee") -#define GLOBAL_DIR QApplication::applicationDirPath() \ - + QString("/../Resources") -#else -#define USER_DIR QDir::homePath() + QString("/.gpxsee") -#define GLOBAL_DIR QString("/usr/share/gpxsee") -#endif - -#define USER_CSV_DIR USER_DIR + QString("/") + CSV_DIR -#define USER_ELLIPSOID_FILE USER_CSV_DIR + QString("/") + ELLIPSOID_FILE -#define USER_GCS_FILE USER_CSV_DIR + QString("/") + GCS_FILE -#define USER_PCS_FILE USER_CSV_DIR + QString("/") + PCS_FILE -#define USER_MAP_DIR USER_DIR + QString("/") + MAP_DIR -#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR -#define GLOBAL_CSV_DIR GLOBAL_DIR + QString("/") + CSV_DIR -#define GLOBAL_ELLIPSOID_FILE GLOBAL_CSV_DIR + QString("/") + ELLIPSOID_FILE -#define GLOBAL_GCS_FILE GLOBAL_CSV_DIR + QString("/") + GCS_FILE -#define GLOBAL_PCS_FILE GLOBAL_CSV_DIR + QString("/") + PCS_FILE -#define GLOBAL_MAP_DIR GLOBAL_DIR + QString("/") + MAP_DIR -#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR -#define TILES_DIR USER_DIR + QString("/tiles") -#define TRANSLATIONS_DIR GLOBAL_DIR + QString("/translations") - - -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 1) -#define ENABLE_HTTP2 -#endif // QT >= 5.10.1 - -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -#define ENABLE_HIDPI -#endif // QT >= 5.6 - -#endif /* CONFIG_H */ diff --git a/src/main.cpp b/src/main.cpp index 45cd957f..14878bac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ +#include "common/config.h" #include "GUI/app.h" -#include "config.h" int main(int argc, char *argv[]) { @@ -9,7 +9,5 @@ int main(int argc, char *argv[]) #endif // ENABLE_HIDPI App app(argc, argv); - app.run(); - - return 0; + return app.run(); } diff --git a/src/map/downloader.cpp b/src/map/downloader.cpp index 21964715..ebf4834d 100644 --- a/src/map/downloader.cpp +++ b/src/map/downloader.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "downloader.h" diff --git a/src/map/downloader.h b/src/map/downloader.h index 29d64ccf..3b696e01 100644 --- a/src/map/downloader.h +++ b/src/map/downloader.h @@ -7,7 +7,7 @@ #include #include #include -#include "config.h" +#include "common/config.h" class Download diff --git a/src/map/geotiffmap.cpp b/src/map/geotiffmap.cpp index bc756eb6..34a1d40f 100644 --- a/src/map/geotiffmap.cpp +++ b/src/map/geotiffmap.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "config.h" +#include "common/config.h" #include "geotiff.h" #include "image.h" #include "geotiffmap.h" diff --git a/src/map/image.cpp b/src/map/image.cpp index 72a086db..979a4c63 100644 --- a/src/map/image.cpp +++ b/src/map/image.cpp @@ -1,6 +1,6 @@ #include #include -#include "config.h" +#include "common/config.h" #include "image.h" diff --git a/src/map/jnxmap.cpp b/src/map/jnxmap.cpp index 52aac1cc..7970cca1 100644 --- a/src/map/jnxmap.cpp +++ b/src/map/jnxmap.cpp @@ -2,10 +2,10 @@ #include #include #include +#include "common/config.h" #include "rectd.h" #include "gcs.h" #include "pcs.h" -#include "config.h" #include "jnxmap.h" diff --git a/src/map/mapsource.cpp b/src/map/mapsource.cpp index 04901794..8fbad6d4 100644 --- a/src/map/mapsource.cpp +++ b/src/map/mapsource.cpp @@ -1,6 +1,6 @@ #include #include -#include "config.h" +#include "common/config.h" #include "onlinemap.h" #include "wmtsmap.h" #include "wmsmap.h" diff --git a/src/map/mbtilesmap.cpp b/src/map/mbtilesmap.cpp index 55a60e53..a9e7e430 100644 --- a/src/map/mbtilesmap.cpp +++ b/src/map/mbtilesmap.cpp @@ -5,8 +5,8 @@ #include #include #include "common/rectc.h" +#include "common/config.h" #include "osm.h" -#include "config.h" #include "mbtilesmap.h" diff --git a/src/map/onlinemap.cpp b/src/map/onlinemap.cpp index db84de39..77b92059 100644 --- a/src/map/onlinemap.cpp +++ b/src/map/onlinemap.cpp @@ -1,9 +1,10 @@ #include #include +#include #include "common/rectc.h" +#include "common/programpaths.h" #include "downloader.h" #include "osm.h" -#include "config.h" #include "onlinemap.h" @@ -16,7 +17,8 @@ OnlineMap::OnlineMap(const QString &name, const QString &url, _zoom(_zooms.max()), _deviceRatio(1.0), _tileRatio(tileRatio), _invertY(invertY) { - _tileLoader = new TileLoader(TILES_DIR + "/" + _name, this); + _tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name), + this); _tileLoader->setUrl(url); _tileLoader->setAuthorization(authorization); connect(_tileLoader, SIGNAL(finished()), this, SIGNAL(loaded())); diff --git a/src/map/ozimap.cpp b/src/map/ozimap.cpp index bf6e8e3b..7f5c5ac4 100644 --- a/src/map/ozimap.cpp +++ b/src/map/ozimap.cpp @@ -7,11 +7,11 @@ #include #include "common/coordinates.h" #include "common/rectc.h" +#include "common/config.h" #include "tar.h" #include "ozf.h" #include "image.h" #include "mapfile.h" -#include "config.h" #include "ozimap.h" diff --git a/src/map/wmsmap.cpp b/src/map/wmsmap.cpp index 12fc3f5d..73bf2b87 100644 --- a/src/map/wmsmap.cpp +++ b/src/map/wmsmap.cpp @@ -3,7 +3,7 @@ #include #include "common/wgs84.h" #include "common/rectc.h" -#include "config.h" +#include "common/programpaths.h" #include "downloader.h" #include "tileloader.h" #include "wmsmap.h" @@ -42,7 +42,7 @@ QString WMSMap::tileUrl(const QString &version) const QString WMSMap::tilesDir() const { - return QString(TILES_DIR + "/" + _name); + return QString(QDir(ProgramPaths::tilesDir()).filePath(_name)); } void WMSMap::computeZooms(const RangeF &scaleDenominator) diff --git a/src/map/wmtsmap.cpp b/src/map/wmtsmap.cpp index 05e9a7b3..5de61902 100644 --- a/src/map/wmtsmap.cpp +++ b/src/map/wmtsmap.cpp @@ -1,8 +1,9 @@ #include #include +#include #include "common/rectc.h" #include "common/wgs84.h" -#include "config.h" +#include "common/programpaths.h" #include "transform.h" #include "tileloader.h" #include "wmts.h" @@ -58,7 +59,7 @@ void WMTSMap::clearCache() QString WMTSMap::tilesDir() const { - return QString(TILES_DIR + "/" + _name); + return QString(QDir(ProgramPaths::tilesDir()).filePath(_name)); } double WMTSMap::sd2res(double scaleDenominator) const