summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-06-26 15:13:06 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-27 07:23:12 +0800
commitab95da8fd2024a408b3136708071c85058bbe872 (patch)
treed7fc82f285d95e51bd731c730f10ea368f6343c1 /qt-ui/mainwindow.cpp
parentc92cf925bd3ea4c04666155ad8c446f94235a88d (diff)
downloadsubsurface-ab95da8fd2024a408b3136708071c85058bbe872.tar.gz
Update main window title depending of current file state
If a file has been opened from the command line or via the File menu the main window title becomes "Subsurface: filename.ext". Title also updates if 'File->Save As' is called. "Subsurface" only is displayed when no active file is present or post 'File->New' or 'File->Close'. To make this work a new public method is added - MainWindow::setTitle() and also an enum type MainWindowTitleFormat, which should allow more complicated formatting, such as showing the selected dives or the total number of dives (e.g. MWTF_FILENAME_N_DIVES). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 6036b3cd1..0655e7a40 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -120,6 +120,7 @@ void MainWindow::on_actionOpen_triggered()
char *error = NULL;
parse_file(fileNamePtr.data(), &error);
set_filename(fileNamePtr.data(), TRUE);
+ setTitle(MWTF_FILENAME);
if (error != NULL) {
showError(error);
@@ -164,6 +165,7 @@ void MainWindow::on_actionClose_triggered()
ui->ProfileWidget->clear();
ui->ListWidget->reload(DiveTripModel::TREE);
ui->globe->reload();
+ setTitle(MWTF_DEFAULT);
clear_events();
}
@@ -673,6 +675,7 @@ void MainWindow::file_save_as(void)
if (!filename.isNull() && !filename.isEmpty()) {
save_dives(filename.toUtf8().data());
set_filename(filename.toUtf8().data(), TRUE);
+ setTitle(MWTF_FILENAME);
mark_divelist_changed(FALSE);
}
}
@@ -705,3 +708,18 @@ void MainWindow::showError(QString message)
ui->mainErrorMessage->setMessageType(KMessageWidget::Error);
ui->mainErrorMessage->animatedShow();
}
+
+void MainWindow::setTitle(enum MainWindowTitleFormat format)
+{
+ switch (format) {
+ case MWTF_DEFAULT:
+ setWindowTitle("Subsurface");
+ break;
+ case MWTF_FILENAME:
+ QFile f(existing_filename);
+ QFileInfo fileInfo(f);
+ QString fileName(fileInfo.fileName());
+ setWindowTitle("Subsurface: " + fileName);
+ break;
+ }
+}