From ae2c132a267932892d5c3f7965517194d38d962a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 30 May 2013 04:59:38 +0900 Subject: 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 --- qt-ui/globe.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'qt-ui') 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 #include #include +#include #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); -- cgit v1.2.3-70-g09d2