summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--helpers.h1
-rw-r--r--qt-gui.cpp26
-rw-r--r--qt-ui/globe.cpp32
-rw-r--r--qt-ui/mainwindow.cpp11
4 files changed, 41 insertions, 29 deletions
diff --git a/helpers.h b/helpers.h
index 04fcd8309..57b5aa6f7 100644
--- a/helpers.h
+++ b/helpers.h
@@ -17,5 +17,6 @@ QString get_volume_string(volume_t volume, bool showunit);
QString get_pressure_string(pressure_t pressure, bool showunit);
void set_default_dive_computer(const char *vendor, const char *product);
void set_default_dive_computer_device(const char *name);
+QString getSubsurfaceDataPath(QString folderToFind);
#endif /* HELPER_H */
diff --git a/qt-gui.cpp b/qt-gui.cpp
index 2d5e409b3..1d9f9cad3 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -263,4 +263,30 @@ void set_default_dive_computer_device(const char *name)
s.endGroup();
}
+QString getSubsurfaceDataPath(QString folderToFind)
+{
+ QString execdir;
+ QDir folder;
+
+ // first check if we are running in the build dir, so this
+ // is just subdirectory of the current directory
+ execdir = QCoreApplication::applicationDirPath();
+ folder = QDir(execdir.append(QDir::separator()).append(folderToFind));
+ if (folder.exists())
+ return folder.absolutePath();
+
+ // next check for the Linux typical $(prefix)/share/subsurface
+ execdir = QCoreApplication::applicationDirPath();
+ folder = QDir(execdir.replace("bin", "share/subsurface/").append(folderToFind));
+ if (folder.exists())
+ return folder.absolutePath();
+
+ // then look for the usual location on a Mac
+ execdir = QCoreApplication::applicationDirPath();
+ folder = QDir(execdir.append("/../Resources/share/").append(folderToFind));
+ if (folder.exists())
+ return folder.absolutePath();
+ return QString("");
+}
+
#include "qt-gui.moc"
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 4b065c12d..bf2369862 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -1,6 +1,7 @@
#include "globe.h"
#include "kmessagewidget.h"
#include "../dive.h"
+#include "../helpers.h"
#include <QDebug>
@@ -24,39 +25,16 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
// if not, check if they are in a known location
MapThemeManager mtm;
QStringList list = mtm.mapThemeIds();
- QString theme, execdir;
+ QString theme, subsurfaceDataPath;
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;
- }
- }
- if (!foundGoogleMap) {
- // then check if we're running as an app on MacOSX
- execdir = QCoreApplication::applicationDirPath();
- marble = QDir(execdir.append("/../Resources/share/marbledata"));
- if (marble.exists()) {
- MarbleDirs::setMarbleDataPath(marble.absolutePath());
- foundGoogleMap = true;
- }
+ subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
+ if (subsurfaceDataPath != "")
+ MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
}
messageWidget = new KMessageWidget(this);
messageWidget->setCloseButtonVisible(false);
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index b70bb1ab9..d3cd951d8 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -23,6 +23,7 @@
#include "../dive.h"
#include "../divelist.h"
#include "../pref.h"
+#include "../helpers.h"
#include "modeldelegates.h"
#include "models.h"
#include "downloadfromdivecomputer.h"
@@ -267,7 +268,13 @@ void MainWindow::on_actionUserManual_triggered()
if(!helpView){
helpView = new QTextBrowser();
}
- helpView->setText(tr("HTML of Help menu here."));
+ QString searchPath = getSubsurfaceDataPath("Documentation");
+ if (searchPath != "") {
+ QUrl url(searchPath.append("/user-manual.html"));
+ helpView->setSource(url);
+ } else {
+ helpView->setText(tr("Cannot find the Subsurface manual"));
+ }
helpView->show();
}
@@ -500,7 +507,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
helpView->close();
helpView->deleteLater();
}
-
+
if (unsaved_changes() && (askSaveChanges() == FALSE)) {
event->ignore();
return;