diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 9 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 3 | ||||
-rw-r--r-- | qthelper.cpp | 5 | ||||
-rw-r--r-- | windowtitleupdate.cpp | 31 | ||||
-rw-r--r-- | windowtitleupdate.h | 20 |
6 files changed, 63 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f5322b8e2..3222876ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,6 +274,7 @@ set(SUBSURFACE_CORE_LIB_SRCS configuredivecomputer.cpp configuredivecomputerthreads.cpp divesitehelpers.cpp + windowtitleupdate.cpp ${SUBSURFACE_PRINTING_SRCS} ${PLATFORM_SRC} ) 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) { diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 8469f5737..0d9f61098 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -14,6 +14,7 @@ #include "ui_mainwindow.h" #include "notificationwidget.h" +#include "windowtitleupdate.h" struct DiveList; class QSortFilterProxyModel; @@ -171,6 +172,7 @@ slots: void on_actionConfigure_Dive_Computer_triggered(); void enableDiveSiteEdit(uint32_t id); void setDefaultState(); + void setAutomaticTitle(); protected: void closeEvent(QCloseEvent *); @@ -228,6 +230,7 @@ private: }; QHash<QByteArray, WidgetForQuadrant> applicationState; QByteArray currentApplicationState; + WindowTitleUpdate *wtu; }; #endif // MAINWINDOW_H diff --git a/qthelper.cpp b/qthelper.cpp index 9d907edf9..350692cdb 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -1073,11 +1073,6 @@ extern "C" bool canReachCloudServer() return CheckCloudConnection::checkServer(); } -extern "C" void updateWindowTitle() -{ - MainWindow::instance()->setTitle(); -} - extern "C" void subsurface_mkdir(const char *dir) { QDir directory; diff --git a/windowtitleupdate.cpp b/windowtitleupdate.cpp new file mode 100644 index 000000000..a22fee779 --- /dev/null +++ b/windowtitleupdate.cpp @@ -0,0 +1,31 @@ +#include "windowtitleupdate.h" + +WindowTitleUpdate *WindowTitleUpdate::m_instance = NULL; + +WindowTitleUpdate::WindowTitleUpdate(QObject *parent) : QObject(parent) +{ + Q_ASSERT_X(m_Instance == NULL, "WindowTitleUpdate", "WindowTitleUpdate recreated!"); + + m_instance = this; +} + +WindowTitleUpdate *WindowTitleUpdate::instance() +{ + return m_instance; +} + +WindowTitleUpdate::~WindowTitleUpdate() +{ + m_instance = NULL; +} + +void WindowTitleUpdate::emitSignal() +{ + emit updateTitle(); +} + +extern "C" void updateWindowTitle() +{ + WindowTitleUpdate *wt = WindowTitleUpdate::instance(); + wt->emitSignal(); +} diff --git a/windowtitleupdate.h b/windowtitleupdate.h new file mode 100644 index 000000000..8650e5868 --- /dev/null +++ b/windowtitleupdate.h @@ -0,0 +1,20 @@ +#ifndef WINDOWTITLEUPDATE_H +#define WINDOWTITLEUPDATE_H + +#include <QObject> + +class WindowTitleUpdate : public QObject +{ + Q_OBJECT +public: + explicit WindowTitleUpdate(QObject *parent = 0); + ~WindowTitleUpdate(); + static WindowTitleUpdate *instance(); + void emitSignal(); +signals: + void updateTitle(); +private: + static WindowTitleUpdate *m_instance; +}; + +#endif // WINDOWTITLEUPDATE_H |