From ef95bd9a2784db7468df01bebf0166f73179e7a4 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 12 Jun 2015 06:48:51 -0700 Subject: Indicate that there are unsaved changes with a '*' in the window title This seems to be a fairly common way to indicate this property. Signed-off-by: Dirk Hohndel --- divelist.c | 2 ++ qt-ui/mainwindow.cpp | 3 ++- qt-ui/mainwindow.h | 2 +- qthelper.cpp | 6 ++++++ qthelperfromc.h | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/divelist.c b/divelist.c index 773f52713..468373591 100644 --- a/divelist.c +++ b/divelist.c @@ -43,6 +43,7 @@ #include "divelist.h" #include "display.h" #include "planner.h" +#include "qthelperfromc.h" static short dive_list_changed = false; @@ -920,6 +921,7 @@ void combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b) void mark_divelist_changed(int changed) { dive_list_changed = changed; + updateWindowTitle(); } int unsaved_changes() diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 80f9fc9f1..571eb15f1 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -1429,7 +1429,8 @@ void MainWindow::setTitle(enum MainWindowTitleFormat format) QFile f(existing_filename); QFileInfo fileInfo(f); QString fileName(fileInfo.fileName()); - setWindowTitle("Subsurface: " + fileName); + QString unsaved = (unsaved_changes() ? " *" : ""); + setWindowTitle("Subsurface: " + fileName + unsaved); break; } } diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 6a5f95921..9bed1d05f 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -72,7 +72,7 @@ public: DivePlannerWidget *divePlannerWidget(); PlannerSettingsWidget *divePlannerSettingsWidget(); LocationInformationWidget *locationInformationWidget(); - void setTitle(enum MainWindowTitleFormat format); + void setTitle(enum MainWindowTitleFormat format = MWTF_FILENAME); // Some shortcuts like "change DC" or "copy/paste dive components" // should only be enabled when the profile's visible. diff --git a/qthelper.cpp b/qthelper.cpp index e476df429..5434bcd20 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -34,6 +34,7 @@ #include #include "divepicturewidget.h" #include "subsurfacewebservices.h" +#include "mainwindow.h" #include @@ -1057,3 +1058,8 @@ extern "C" bool canReachCloudServer() { return CheckCloudConnection::checkServer(); } + +extern "C" void updateWindowTitle() +{ + MainWindow::instance()->setTitle(); +} diff --git a/qthelperfromc.h b/qthelperfromc.h index 039d9252d..d7ba6f1b7 100644 --- a/qthelperfromc.h +++ b/qthelperfromc.h @@ -3,5 +3,6 @@ bool getProxyString(char **buffer); bool canReachCloudServer(); +void updateWindowTitle(); #endif // QTHELPERFROMC_H -- cgit v1.2.3-70-g09d2