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:
parent
9da82a978c
commit
6bcb6ceb8d
@ -55,8 +55,9 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
; Set output path to the installation directory.
|
; Set output path to the installation directory.
|
||||||
SetOutPath $INSTDIR
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
; Put file there
|
; Put the files there
|
||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
|
File "maps.txt"
|
||||||
|
|
||||||
; Write the installation path into the registry
|
; Write the installation path into the registry
|
||||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||||
|
@ -14,6 +14,5 @@
|
|||||||
<file>icons/arrow-left-double.png</file>
|
<file>icons/arrow-left-double.png</file>
|
||||||
<file>icons/arrow-right-double.png</file>
|
<file>icons/arrow-right-double.png</file>
|
||||||
<file>lang/gpxsee_cs.qm</file>
|
<file>lang/gpxsee_cs.qm</file>
|
||||||
<file>maps.txt</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
24
src/config.h
24
src/config.h
@ -1,6 +1,8 @@
|
|||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#define APP_NAME "GPXSee"
|
#define APP_NAME "GPXSee"
|
||||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||||
#define APP_VERSION "2.10"
|
#define APP_VERSION "2.10"
|
||||||
@ -8,13 +10,25 @@
|
|||||||
#define FONT_FAMILY "Arial"
|
#define FONT_FAMILY "Arial"
|
||||||
#define FONT_SIZE 12
|
#define FONT_SIZE 12
|
||||||
|
|
||||||
|
#define MAP_FILE QString("maps.txt")
|
||||||
|
#define POI_DIR QString("POI")
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
#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
|
#else
|
||||||
#define APP_DIR ".gpxsee"
|
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
|
||||||
|
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
||||||
#endif
|
#endif
|
||||||
#define POI_DIR APP_DIR"/POI"
|
|
||||||
#define TILES_DIR APP_DIR"/tiles"
|
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||||
#define MAP_LIST_FILE APP_DIR"/maps.txt"
|
#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 */
|
#endif /* CONFIG_H */
|
||||||
|
28
src/gui.cpp
28
src/gui.cpp
@ -44,7 +44,8 @@ static QString timeSpan(qreal time)
|
|||||||
|
|
||||||
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||||
{
|
{
|
||||||
loadFiles();
|
loadMaps();
|
||||||
|
loadPOIs();
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
createMenus();
|
createMenus();
|
||||||
@ -85,16 +86,19 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
|||||||
resize(600, 800);
|
resize(600, 800);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::loadFiles()
|
void GUI::loadMaps()
|
||||||
{
|
{
|
||||||
// Maps
|
_maps = MapList::load(this, USER_MAP_FILE);
|
||||||
_maps = MapList::load(this, QString("%1/" MAP_LIST_FILE)
|
_maps += MapList::load(this, GLOBAL_MAP_FILE);
|
||||||
.arg(QDir::homePath()));
|
}
|
||||||
_maps += MapList::load(this, ":/maps.txt");
|
|
||||||
|
|
||||||
// POI files
|
void GUI::loadPOIs()
|
||||||
QDir dir(QString("%1/" POI_DIR).arg(QDir::homePath()));
|
{
|
||||||
QFileInfoList list = dir.entryInfoList(QStringList(), QDir::Files);
|
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)
|
for (int i = 0; i < list.size(); ++i)
|
||||||
_poi.loadFile(list.at(i).absoluteFilePath());
|
_poi.loadFile(list.at(i).absoluteFilePath());
|
||||||
}
|
}
|
||||||
@ -433,8 +437,7 @@ void GUI::dataSources()
|
|||||||
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
|
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
|
||||||
+ tr("Map (tiles) source URLs are read on program startup from the "
|
+ tr("Map (tiles) source URLs are read on program startup from the "
|
||||||
"following file:")
|
"following file:")
|
||||||
+ QString("</p><p><code>") + QDir::homePath()
|
+ QString("</p><p><code>") + USER_MAP_FILE + QString("</code></p><p>")
|
||||||
+ QString("/" MAP_LIST_FILE "</code></p><p>")
|
|
||||||
+ tr("The file format is one map entry per line, consisting of the map "
|
+ 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 "
|
"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 "
|
"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>")
|
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
|
||||||
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
||||||
"the file to the following directory:")
|
"the file to the following directory:")
|
||||||
+ QString("</p><p><code>") + QDir::homePath()
|
+ QString("</p><p><code>") + USER_POI_DIR + QString("</code></p>")
|
||||||
+ QString("/" POI_DIR "</code></p>")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
@ -59,7 +59,8 @@ private slots:
|
|||||||
void setImperialUnits();
|
void setImperialUnits();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadFiles();
|
void loadMaps();
|
||||||
|
void loadPOIs();
|
||||||
void closeFiles();
|
void closeFiles();
|
||||||
|
|
||||||
QAction *createPOIFileAction(int index);
|
QAction *createPOIFileAction(int index);
|
||||||
|
@ -15,7 +15,7 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
|
|||||||
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
||||||
SLOT(emitLoaded()));
|
SLOT(emitLoaded()));
|
||||||
|
|
||||||
QString path = QString(TILES_DIR"/") + _name;
|
QString path = TILES_DIR + QString("/") + _name;
|
||||||
if (!QDir::home().mkpath(path))
|
if (!QDir::home().mkpath(path))
|
||||||
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(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) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
Tile &t = list[i];
|
Tile &t = list[i];
|
||||||
QString file = QString("%1/" TILES_DIR "/%2/%3-%4-%5")
|
QString file = TILES_DIR + QString("/%1/%2-%3-%4")
|
||||||
.arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx())
|
.arg(_name).arg(t.zoom()).arg(t.xy().rx()).arg(t.xy().ry());
|
||||||
.arg(t.xy().ry());
|
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
|
||||||
if (fi.exists()) {
|
if (fi.exists()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user