summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-16 06:04:34 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-16 06:04:34 -0700
commit0fa0eb2879bf72654a7febf8b977b0ba6f515658 (patch)
treec5bcdba3579ef86b342cc9671faa71a7ed5bb766 /qt-ui/mainwindow.cpp
parentc593dea119b4c5fa77a8b2cc129d048d7d56afa4 (diff)
downloadsubsurface-0fa0eb2879bf72654a7febf8b977b0ba6f515658.tar.gz
Code cleanup: implement window title update via signal
This seems quite convoluted to me but I can't seem to make a more straight forward implementation work. The idea is that core code should never directly call into the UI. So instead the core code (this is C code) calls a helper function. That helper function calls a member function of a class which in return emits a signal. The UI code connects to that signal and acts accordingly when it is received. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index de7cdbdc1..4e35ad9ee 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -39,6 +39,7 @@
#include "usersurvey.h"
#include "divesitehelpers.h"
#include "locationinformation.h"
+#include "windowtitleupdate.h"
#ifndef NO_USERMANUAL
#include "usermanual.h"
#endif
@@ -148,7 +149,8 @@ MainWindow::MainWindow() : QMainWindow(),
connect(locationInformation, SIGNAL(startEditDiveSite(uint32_t)), globeGps, SLOT(prepareForGetDiveCoordinates()));
connect(locationInformation, SIGNAL(endEditDiveSite()), globeGps, SLOT(prepareForGetDiveCoordinates()));
connect(information(), SIGNAL(diveSiteChanged(uint32_t)), globeGps, SLOT(centerOnDiveSite(uint32_t)));
-
+ wtu = new WindowTitleUpdate();
+ connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle()));
#ifdef NO_PRINTING
plannerDetails->printPlan()->hide();
ui.menuFile->removeAction(ui.actionPrint);
@@ -1439,6 +1441,11 @@ QString MainWindow::displayedFilename(QString fullFilename)
return fileName;
}
+void MainWindow::setAutomaticTitle()
+{
+ setTitle();
+}
+
void MainWindow::setTitle(enum MainWindowTitleFormat format)
{
switch (format) {