summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-30 04:59:38 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-30 14:00:55 +0900
commitae2c132a267932892d5c3f7965517194d38d962a (patch)
treebead6185d791ca355127c06de001069390cf0f5b
parent7b75cfa8082b97fedcea8df577e9f426037a7965 (diff)
downloadsubsurface-ae2c132a267932892d5c3f7965517194d38d962a.tar.gz
Do a better job finding Marble Google Sat files
First try if Google Sat is already installed as a provider (and just use it if it is). Then use the executable path to make an educated guess where these files might be found as part of Subsurface. We now install the necessary directory tree under $(DESTDIR)/usr/share/subsurface/marbledata Still far from perfect - but this should work at least on Linux. MacOS will need a different modifier for the path and Windows I haven't even thought about, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--Configure.mk1
-rw-r--r--Makefile1
-rw-r--r--Rules.mk4
-rw-r--r--qt-ui/globe.cpp33
4 files changed, 36 insertions, 3 deletions
diff --git a/Configure.mk b/Configure.mk
index ff003fd75..a09fcbbf1 100644
--- a/Configure.mk
+++ b/Configure.mk
@@ -8,6 +8,7 @@ XSLCONFIG=xslt-config
QMAKE=qmake
MOC=moc
UIC=uic
+TAR=tar
CONFIGFILE = config.cache
ifeq ($(CONFIGURING),1)
diff --git a/Makefile b/Makefile
index 46d5d0096..eedf1a7b8 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,7 @@ ICONPATH = $(DATADIR)/icons/hicolor
ICONDIR = $(ICONPATH)/scalable/apps
MANDIR = $(DATADIR)/man/man1
XSLTDIR = $(DATADIR)/$(NAME)/xslt
+MARBLEDIR = marbledata/maps/earth/googlesat
gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH)
ICONFILE = $(NAME)-icon.svg
diff --git a/Rules.mk b/Rules.mk
index cd6d686ff..a3eff13cd 100644
--- a/Rules.mk
+++ b/Rules.mk
@@ -70,6 +70,10 @@ install: all
$(INSTALL) -d -m 755 $(XSLTDIR); \
$(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \
fi
+ @-if test ! -z "$(MARBLEDIR)"; then \
+ $(INSTALL) -d -m 755 $(DATADIR)/$(NAME)/$(MARBLEDIR); \
+ $(TAR) cf - $(MARBLEDIR) | ( cd $(DATADIR)/$(NAME); $(TAR) xf - ); \
+ fi
for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \
$(INSTALL) -d $(prefix)/$$LOC; \
$(INSTALL) -m 644 $$LOC/$(NAME).mo $(prefix)/$$LOC/$(NAME).mo; \
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index c1abd082f..8662b2fcb 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -9,6 +9,7 @@
#include <marble/GeoDataDocument.h>
#include <marble/MarbleModel.h>
#include <marble/MarbleDirs.h>
+#include <marble/MapThemeManager.h>
#if INCOMPLETE_MARBLE
#include "marble/GeoDataTreeModel.h"
#else
@@ -19,9 +20,35 @@
GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
{
- // this will find the Google maps when running from your build directory
- // TODO: all the magic to find the install path (and actually install/bundle these files)
- MarbleDirs::setMarbleDataPath(QDir("./marbledata").absolutePath());
+ // check if Google Sat Maps are installed
+ // if not, check if they are in a known location
+ MapThemeManager mtm;
+ QStringList list = mtm.mapThemeIds();
+ QString theme, execdir;
+ QDir marble;
+ bool foundGoogleMap = false;
+ Q_FOREACH(theme, list)
+ if (theme == "earth/googlesat/googlesat.dgml")
+ foundGoogleMap = true;
+ if (!foundGoogleMap) {
+ // first check if we are running from the build directory
+ execdir = QCoreApplication::applicationDirPath();
+ marble = QDir(execdir.append("/marbledata"));
+ if (marble.exists()) {
+ MarbleDirs::setMarbleDataPath(marble.absolutePath());
+ foundGoogleMap = true;
+ }
+ }
+ if (!foundGoogleMap) {
+ // next check if we can guess an installed location by replacing
+ // "bin" with "share/subsurface" - so /usr/local/bin/subsurface would
+ // have us check /usr/local/share/subsurface/marbledata
+ marble = execdir.replace("bin", "share/subsurface");
+ if (marble.exists()) {
+ MarbleDirs::setMarbleDataPath(marble.absolutePath());
+ foundGoogleMap = true;
+ }
+ }
messageWidget = new KMessageWidget(this);
messageWidget->setCloseButtonVisible(false);
messageWidget->setHidden(true);