Changeset 4ac5b9c in subsurface


Ignore:
Timestamp:
Dec 11, 2017, 9:10:09 PM (6 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
c12e14a, ec8aeb8
Parents:
931bcc1
git-author:
Berthold Stoeger <bstoeger@…> (12/11/17 08:43:53)
git-committer:
Dirk Hohndel <dirk@…> (12/11/17 21:10:09)
Message:

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@…>

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • desktop-widgets/mainwindow.cpp

    r931bcc1 r4ac5b9c  
    611611        if (!parse_file(fileNamePtr.data())) {
    612612                set_filename(fileNamePtr.data());
    613                 setTitle(MWTF_FILENAME);
     613                setTitle();
    614614        }
    615615        getNotificationWidget()->hideNotification();
     
    642642
    643643        set_filename(filename.toUtf8().data());
    644         setTitle(MWTF_FILENAME);
     644        setTitle();
    645645        mark_divelist_changed(false);
    646646}
     
    693693        MapWidget::instance()->reload();
    694694        if (!existing_filename)
    695                 setTitle(MWTF_DEFAULT);
     695                setTitle();
    696696        disableShortcuts();
    697697}
     
    16551655
    16561656        set_filename(filename.toUtf8().data());
    1657         setTitle(MWTF_FILENAME);
     1657        setTitle();
    16581658        mark_divelist_changed(false);
    16591659        addRecentFile(filename, true);
     
    17261726}
    17271727
    1728 void MainWindow::setTitle(enum MainWindowTitleFormat format)
    1729 {
    1730         switch (format) {
    1731         case MWTF_DEFAULT:
     1728void MainWindow::setTitle()
     1729{
     1730        if (!existing_filename || !existing_filename[0]) {
    17321731                setWindowTitle("Subsurface");
    1733                 break;
    1734         case MWTF_FILENAME:
    1735                 if (!existing_filename) {
    1736                         setTitle(MWTF_DEFAULT);
    1737                         return;
    1738                 }
    1739                 QString unsaved = (unsaved_changes() ? " *" : "");
    1740                 setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
    1741                 break;
    1742         }
     1732                return;
     1733        }
     1734
     1735        QString unsaved = (unsaved_changes() ? " *" : "");
     1736        setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
    17431737}
    17441738
     
    18021796                        set_filename(fileNamePtr.data());
    18031797                        addRecentFile(fileNamePtr, false);
    1804                         setTitle(MWTF_FILENAME);
     1798                        setTitle();
    18051799                }
    18061800        }
  • desktop-widgets/mainwindow.h

    ra9703628 r4ac5b9c  
    4242typedef QVector<WidgetProperty> PropertyList;
    4343
    44 enum MainWindowTitleFormat {
    45         MWTF_DEFAULT,
    46         MWTF_FILENAME
    47 };
    48 
    4944class MainWindow : public QMainWindow {
    5045        Q_OBJECT
     
    7570        PlannerSettingsWidget *divePlannerSettingsWidget();
    7671        LocationInformationWidget *locationInformationWidget();
    77         void setTitle(enum MainWindowTitleFormat format = MWTF_FILENAME);
     72        void setTitle();
    7873
    7974        void loadFiles(const QStringList files);
  • subsurface-desktop-helper.cpp

    rbde7caa6 r4ac5b9c  
    3434
    3535        window = new MainWindow();
    36         if (existing_filename && existing_filename[0] != '\0')
    37                 window->setTitle(MWTF_FILENAME);
    38         else
    39                 window->setTitle(MWTF_DEFAULT);
     36        window->setTitle();
    4037}
    4138
Note: See TracChangeset for help on using the changeset viewer.