summaryrefslogtreecommitdiffstats
path: root/qt-ui/globe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/globe.cpp')
-rw-r--r--qt-ui/globe.cpp33
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);