diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-30 04:59:38 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-30 14:00:55 +0900 |
commit | ae2c132a267932892d5c3f7965517194d38d962a (patch) | |
tree | bead6185d791ca355127c06de001069390cf0f5b /qt-ui/globe.cpp | |
parent | 7b75cfa8082b97fedcea8df577e9f426037a7965 (diff) | |
download | subsurface-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>
Diffstat (limited to 'qt-ui/globe.cpp')
-rw-r--r-- | qt-ui/globe.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
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); |