diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-12-11 17:43:53 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-11 23:10:09 -0600 |
commit | 4ac5b9c9654e6d561c05451888f337de2d1b7cf7 (patch) | |
tree | 726d480ed8ca854b6d98e068fb04db0a0038a4fd | |
parent | 931bcc196644c79e1064a9cb1b9c80e82fe0ed06 (diff) | |
download | subsurface-4ac5b9c9654e6d561c05451888f337de2d1b7cf7.tar.gz |
Simplify mainwindow title logic: remove MainWindowTitleFormat enum
The MainWindow::setTitle() function was passed an enum, which depended
on whether existing_file is set or not. The check can be (and was!) done
directly in setTitle(). Therefore, remove the whole enum.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 28 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.h | 7 | ||||
-rw-r--r-- | subsurface-desktop-helper.cpp | 5 |
3 files changed, 13 insertions, 27 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 76e9b0615..7e608427c 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -610,7 +610,7 @@ void MainWindow::on_actionCloudstorageopen_triggered() QByteArray fileNamePtr = QFile::encodeName(filename); if (!parse_file(fileNamePtr.data())) { set_filename(fileNamePtr.data()); - setTitle(MWTF_FILENAME); + setTitle(); } getNotificationWidget()->hideNotification(); process_dives(false, false); @@ -641,7 +641,7 @@ void MainWindow::on_actionCloudstoragesave_triggered() return; set_filename(filename.toUtf8().data()); - setTitle(MWTF_FILENAME); + setTitle(); mark_divelist_changed(false); } @@ -692,7 +692,7 @@ void MainWindow::cleanUpEmpty() dive_list()->reload(DiveTripModel::TREE); MapWidget::instance()->reload(); if (!existing_filename) - setTitle(MWTF_DEFAULT); + setTitle(); disableShortcuts(); } @@ -1654,7 +1654,7 @@ int MainWindow::file_save_as(void) return -1; set_filename(filename.toUtf8().data()); - setTitle(MWTF_FILENAME); + setTitle(); mark_divelist_changed(false); addRecentFile(filename, true); return 0; @@ -1725,21 +1725,15 @@ void MainWindow::setAutomaticTitle() setTitle(); } -void MainWindow::setTitle(enum MainWindowTitleFormat format) +void MainWindow::setTitle() { - switch (format) { - case MWTF_DEFAULT: + if (!existing_filename || !existing_filename[0]) { setWindowTitle("Subsurface"); - break; - case MWTF_FILENAME: - if (!existing_filename) { - setTitle(MWTF_DEFAULT); - return; - } - QString unsaved = (unsaved_changes() ? " *" : ""); - setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved); - break; + return; } + + QString unsaved = (unsaved_changes() ? " *" : ""); + setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved); } void MainWindow::importFiles(const QStringList fileNames) @@ -1801,7 +1795,7 @@ void MainWindow::loadFiles(const QStringList fileNames) if (!parse_file(fileNamePtr.data())) { set_filename(fileNamePtr.data()); addRecentFile(fileNamePtr, false); - setTitle(MWTF_FILENAME); + setTitle(); } } hideProgressBar(); diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h index ca1bf8962..7c44cb425 100644 --- a/desktop-widgets/mainwindow.h +++ b/desktop-widgets/mainwindow.h @@ -41,11 +41,6 @@ class LocationInformationWidget; typedef std::pair<QByteArray, QVariant> WidgetProperty; typedef QVector<WidgetProperty> PropertyList; -enum MainWindowTitleFormat { - MWTF_DEFAULT, - MWTF_FILENAME -}; - class MainWindow : public QMainWindow { Q_OBJECT public: @@ -74,7 +69,7 @@ public: DivePlannerWidget *divePlannerWidget(); PlannerSettingsWidget *divePlannerSettingsWidget(); LocationInformationWidget *locationInformationWidget(); - void setTitle(enum MainWindowTitleFormat format = MWTF_FILENAME); + void setTitle(); void loadFiles(const QStringList files); void importFiles(const QStringList importFiles); diff --git a/subsurface-desktop-helper.cpp b/subsurface-desktop-helper.cpp index 8356b9fe8..924352c16 100644 --- a/subsurface-desktop-helper.cpp +++ b/subsurface-desktop-helper.cpp @@ -33,10 +33,7 @@ void init_ui() PluginManager::instance().loadPlugins(); window = new MainWindow(); - if (existing_filename && existing_filename[0] != '\0') - window->setTitle(MWTF_FILENAME); - else - window->setTitle(MWTF_DEFAULT); + window->setTitle(); } void run_ui() |