1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Now using a file on the filesystem for default maps rather than the executable

This commit is contained in:
Martin Tůma 2016-03-24 19:34:46 +01:00
parent 9da82a978c
commit 6bcb6ceb8d
6 changed files with 46 additions and 30 deletions

View File

@ -55,8 +55,9 @@ Section "GPXSee (required)" SEC_APP
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
; Put the files there
File "gpxsee.exe"
File "maps.txt"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"

View File

@ -14,6 +14,5 @@
<file>icons/arrow-left-double.png</file>
<file>icons/arrow-right-double.png</file>
<file>lang/gpxsee_cs.qm</file>
<file>maps.txt</file>
</qresource>
</RCC>

View File

@ -1,6 +1,8 @@
#ifndef CONFIG_H
#define CONFIG_H
#include <QtGlobal>
#define APP_NAME "GPXSee"
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
#define APP_VERSION "2.10"
@ -8,13 +10,25 @@
#define FONT_FAMILY "Arial"
#define FONT_SIZE 12
#define MAP_FILE QString("maps.txt")
#define POI_DIR QString("POI")
#if defined(Q_OS_WIN32)
#define APP_DIR "GPXSee"
#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 APP_DIR ".gpxsee"
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
#define GLOBAL_DIR QString("/usr/share/gpxsee")
#endif
#define POI_DIR APP_DIR"/POI"
#define TILES_DIR APP_DIR"/tiles"
#define MAP_LIST_FILE APP_DIR"/maps.txt"
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
#define TILES_DIR USER_DIR + QString("/tiles")
#endif /* CONFIG_H */

View File

@ -44,7 +44,8 @@ static QString timeSpan(qreal time)
GUI::GUI(QWidget *parent) : QMainWindow(parent)
{
loadFiles();
loadMaps();
loadPOIs();
createActions();
createMenus();
@ -85,16 +86,19 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
resize(600, 800);
}
void GUI::loadFiles()
void GUI::loadMaps()
{
// Maps
_maps = MapList::load(this, QString("%1/" MAP_LIST_FILE)
.arg(QDir::homePath()));
_maps += MapList::load(this, ":/maps.txt");
_maps = MapList::load(this, USER_MAP_FILE);
_maps += MapList::load(this, GLOBAL_MAP_FILE);
}
// POI files
QDir dir(QString("%1/" POI_DIR).arg(QDir::homePath()));
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
void GUI::loadPOIs()
{
QDir userDir(USER_POI_DIR);
QDir globalDir(GLOBAL_POI_DIR);
QFileInfoList list = userDir.entryInfoList(QStringList(), QDir::Files)
+ globalDir.entryInfoList(QStringList(), QDir::Files);
for (int i = 0; i < list.size(); ++i)
_poi.loadFile(list.at(i).absoluteFilePath());
}
@ -433,8 +437,7 @@ void GUI::dataSources()
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
+ tr("Map (tiles) source URLs are read on program startup from the "
"following file:")
+ QString("</p><p><code>") + QDir::homePath()
+ QString("/" MAP_LIST_FILE "</code></p><p>")
+ QString("</p><p><code>") + USER_MAP_FILE + QString("</code></p><p>")
+ tr("The file format is one map entry per line, consisting of the map "
"name and tiles URL delimited by a TAB character. The tile X and Y "
"coordinates are replaced with $x and $y in the URL and the zoom "
@ -445,8 +448,7 @@ void GUI::dataSources()
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
+ tr("To make GPXSee load a POI file automatically on startup, add "
"the file to the following directory:")
+ QString("</p><p><code>") + QDir::homePath()
+ QString("/" POI_DIR "</code></p>")
+ QString("</p><p><code>") + USER_POI_DIR + QString("</code></p>")
);
msgBox.exec();

View File

@ -59,7 +59,8 @@ private slots:
void setImperialUnits();
private:
void loadFiles();
void loadMaps();
void loadPOIs();
void closeFiles();
QAction *createPOIFileAction(int index);

View File

@ -15,7 +15,7 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
connect(&Downloader::instance(), SIGNAL(finished()), this,
SLOT(emitLoaded()));
QString path = QString(TILES_DIR"/") + _name;
QString path = TILES_DIR + QString("/") + _name;
if (!QDir::home().mkpath(path))
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
}
@ -31,9 +31,8 @@ void Map::loadTiles(QList<Tile> &list)
for (int i = 0; i < list.size(); ++i) {
Tile &t = list[i];
QString file = QString("%1/" TILES_DIR "/%2/%3-%4-%5")
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
.arg(t.xy().ry());
QString file = TILES_DIR + QString("/%1/%2-%3-%4")
.arg(_name).arg(t.zoom()).arg(t.xy().rx()).arg(t.xy().ry());
QFileInfo fi(file);
if (fi.exists()) {