[PATCH 1/5] Introduce NO_MARBLE define, make GlobeGPS a dummy

Anton Lundin glance at acc.umu.se
Wed Mar 26 15:08:56 PDT 2014


Some users have requested a way to build subsurface without marble.

This hides all traces in the ui and creates a GlobeGPS-dummy thats
just a QLabel saying that marble is disabled, in case its shown
somehow. The dummy is there so we can just ignore the fact that marble
is disabled in the rest of the code.

Fixes #394

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 qt-ui/globe.cpp          | 10 ++++++++++
 qt-ui/globe.h            | 18 ++++++++++++++++++
 qt-ui/mainwindow.cpp     |  4 ++++
 subsurface-configure.pri |  6 ++++--
 4 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 4c67437..961e0db 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -1,4 +1,5 @@
 #include "globe.h"
+#ifndef NO_MARBLE
 #include "kmessagewidget.h"
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
@@ -295,3 +296,12 @@ void GlobeGPS::resizeEvent(QResizeEvent *event)
 		messageWidget->setGeometry(5, 5, size - 10, 0);
 	messageWidget->setMaximumHeight(500);
 }
+#else
+
+GlobeGPS::GlobeGPS(QWidget* parent) { setText("MARBLE DISABLED AT BUILD TIME"); }
+void GlobeGPS::repopulateLabels() {}
+void GlobeGPS::centerOn(dive* dive) {}
+bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev) {}
+void GlobeGPS::prepareForGetDiveCoordinates() {}
+void GlobeGPS::reload() {}
+#endif
diff --git a/qt-ui/globe.h b/qt-ui/globe.h
index 80d9613..f5a1e40 100644
--- a/qt-ui/globe.h
+++ b/qt-ui/globe.h
@@ -1,5 +1,6 @@
 #ifndef GLOBE_H
 #define GLOBE_H
+#ifndef NO_MARBLE
 
 #include <marble/MarbleWidget.h>
 #include <marble/GeoDataCoordinates.h>
@@ -41,4 +42,21 @@ slots:
 	void prepareForGetDiveCoordinates();
 };
 
+#else // NO_MARBLE
+/* Dummy widget for when we don't have MarbleWidget */
+#include <QLabel>
+
+class GlobeGPS : public QLabel {
+	Q_OBJECT
+public:
+	GlobeGPS(QWidget *parent);
+	void reload();
+	void repopulateLabels();
+	void centerOn(struct dive* dive);
+	bool eventFilter(QObject*, QEvent*);
+public slots:
+	void prepareForGetDiveCoordinates();
+};
+
+#endif // NO_MARBLE
 #endif // GLOBE_H
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index e77fa6b..e1b9d3e 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -81,6 +81,10 @@ MainWindow::MainWindow() : QMainWindow(),
 #ifndef ENABLE_PLANNER
 	ui.menuLog->removeAction(ui.actionDivePlanner);
 #endif
+#ifdef NO_MARBLE
+	ui.layoutWidget->hide();
+	ui.menuView->removeAction(ui.actionViewGlobe);
+#endif
 }
 
 MainWindow::~MainWindow()
diff --git a/subsurface-configure.pri b/subsurface-configure.pri
index c01af7a..84e2599 100644
--- a/subsurface-configure.pri
+++ b/subsurface-configure.pri
@@ -144,8 +144,10 @@ link_pkgconfig: packagesExist(libiconv): PKGCONFIG += libiconv
 # Before Marble 4.9, the GeoDataTreeModel.h header wasn't installed
 # Check if it's present by trying to compile
 # ### FIXME: implement that
-win32: CONFIG(debug, debug|release): LIBS += -lmarblewidgetd
-else: LIBS += -lmarblewidget
+!contains(DEFINES, NO_MARBLE) {
+	win32: CONFIG(debug, debug|release): LIBS += -lmarblewidgetd
+	else: LIBS += -lmarblewidget
+}
 
 libgit21-api {
 	DEFINES += USE_LIBGIT21_API
-- 
1.8.3.2



More information about the subsurface mailing list