[PATCH] MainWindow: fix setTitle() calls

Lubomir I. Ivanov neolit123 at gmail.com
Thu Dec 5 04:36:10 UTC 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

setTitle() works with an enum that can be fed different values,
and other we may have eventually. For example not only "app title",
or "app title: filename", but others, like dates, certain app status
and so on.

Patch fixes an issue where deleting a single dive in the divelist
resets the title to "Subsurface" only. clearUpEmpty() should only
call setTitle(MWTF_DEFAULT) if no file is currently open.

It also adds a safe-guard to revert back to MWTF_DEFAULT if
no file is open but setTitle is called with MWTF_FILENAME.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 qt-ui/mainwindow.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index e049179..e4415c6 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -134,7 +134,8 @@ void MainWindow::cleanUpEmpty()
 	ui.ProfileWidget->clear();
 	ui.ListWidget->reload(DiveTripModel::TREE);
 	ui.globe->reload();
-	setTitle(MWTF_DEFAULT);
+	if (!existing_filename)
+		setTitle(MWTF_DEFAULT);
 }
 
 void MainWindow::on_actionClose_triggered()
@@ -782,6 +783,8 @@ void MainWindow::setTitle(enum MainWindowTitleFormat format)
 		setWindowTitle("Subsurface");
 		break;
 	case MWTF_FILENAME:
+		if (!existing_filename)
+			setTitle(MWTF_DEFAULT);
 		QFile f(existing_filename);
 		QFileInfo fileInfo(f);
 		QString fileName(fileInfo.fileName());
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list