mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
931bcc1966
commit
4ac5b9c965
3 changed files with 13 additions and 27 deletions
|
@ -610,7 +610,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
|
||||||
QByteArray fileNamePtr = QFile::encodeName(filename);
|
QByteArray fileNamePtr = QFile::encodeName(filename);
|
||||||
if (!parse_file(fileNamePtr.data())) {
|
if (!parse_file(fileNamePtr.data())) {
|
||||||
set_filename(fileNamePtr.data());
|
set_filename(fileNamePtr.data());
|
||||||
setTitle(MWTF_FILENAME);
|
setTitle();
|
||||||
}
|
}
|
||||||
getNotificationWidget()->hideNotification();
|
getNotificationWidget()->hideNotification();
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
|
@ -641,7 +641,7 @@ void MainWindow::on_actionCloudstoragesave_triggered()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
set_filename(filename.toUtf8().data());
|
set_filename(filename.toUtf8().data());
|
||||||
setTitle(MWTF_FILENAME);
|
setTitle();
|
||||||
mark_divelist_changed(false);
|
mark_divelist_changed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ void MainWindow::cleanUpEmpty()
|
||||||
dive_list()->reload(DiveTripModel::TREE);
|
dive_list()->reload(DiveTripModel::TREE);
|
||||||
MapWidget::instance()->reload();
|
MapWidget::instance()->reload();
|
||||||
if (!existing_filename)
|
if (!existing_filename)
|
||||||
setTitle(MWTF_DEFAULT);
|
setTitle();
|
||||||
disableShortcuts();
|
disableShortcuts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1654,7 +1654,7 @@ int MainWindow::file_save_as(void)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
set_filename(filename.toUtf8().data());
|
set_filename(filename.toUtf8().data());
|
||||||
setTitle(MWTF_FILENAME);
|
setTitle();
|
||||||
mark_divelist_changed(false);
|
mark_divelist_changed(false);
|
||||||
addRecentFile(filename, true);
|
addRecentFile(filename, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1725,21 +1725,15 @@ void MainWindow::setAutomaticTitle()
|
||||||
setTitle();
|
setTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setTitle(enum MainWindowTitleFormat format)
|
void MainWindow::setTitle()
|
||||||
{
|
{
|
||||||
switch (format) {
|
if (!existing_filename || !existing_filename[0]) {
|
||||||
case MWTF_DEFAULT:
|
|
||||||
setWindowTitle("Subsurface");
|
setWindowTitle("Subsurface");
|
||||||
break;
|
return;
|
||||||
case MWTF_FILENAME:
|
|
||||||
if (!existing_filename) {
|
|
||||||
setTitle(MWTF_DEFAULT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QString unsaved = (unsaved_changes() ? " *" : "");
|
|
||||||
setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString unsaved = (unsaved_changes() ? " *" : "");
|
||||||
|
setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::importFiles(const QStringList fileNames)
|
void MainWindow::importFiles(const QStringList fileNames)
|
||||||
|
@ -1801,7 +1795,7 @@ void MainWindow::loadFiles(const QStringList fileNames)
|
||||||
if (!parse_file(fileNamePtr.data())) {
|
if (!parse_file(fileNamePtr.data())) {
|
||||||
set_filename(fileNamePtr.data());
|
set_filename(fileNamePtr.data());
|
||||||
addRecentFile(fileNamePtr, false);
|
addRecentFile(fileNamePtr, false);
|
||||||
setTitle(MWTF_FILENAME);
|
setTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
|
|
|
@ -41,11 +41,6 @@ class LocationInformationWidget;
|
||||||
typedef std::pair<QByteArray, QVariant> WidgetProperty;
|
typedef std::pair<QByteArray, QVariant> WidgetProperty;
|
||||||
typedef QVector<WidgetProperty> PropertyList;
|
typedef QVector<WidgetProperty> PropertyList;
|
||||||
|
|
||||||
enum MainWindowTitleFormat {
|
|
||||||
MWTF_DEFAULT,
|
|
||||||
MWTF_FILENAME
|
|
||||||
};
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -74,7 +69,7 @@ public:
|
||||||
DivePlannerWidget *divePlannerWidget();
|
DivePlannerWidget *divePlannerWidget();
|
||||||
PlannerSettingsWidget *divePlannerSettingsWidget();
|
PlannerSettingsWidget *divePlannerSettingsWidget();
|
||||||
LocationInformationWidget *locationInformationWidget();
|
LocationInformationWidget *locationInformationWidget();
|
||||||
void setTitle(enum MainWindowTitleFormat format = MWTF_FILENAME);
|
void setTitle();
|
||||||
|
|
||||||
void loadFiles(const QStringList files);
|
void loadFiles(const QStringList files);
|
||||||
void importFiles(const QStringList importFiles);
|
void importFiles(const QStringList importFiles);
|
||||||
|
|
|
@ -33,10 +33,7 @@ void init_ui()
|
||||||
PluginManager::instance().loadPlugins();
|
PluginManager::instance().loadPlugins();
|
||||||
|
|
||||||
window = new MainWindow();
|
window = new MainWindow();
|
||||||
if (existing_filename && existing_filename[0] != '\0')
|
window->setTitle();
|
||||||
window->setTitle(MWTF_FILENAME);
|
|
||||||
else
|
|
||||||
window->setTitle(MWTF_DEFAULT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_ui()
|
void run_ui()
|
||||||
|
|
Loading…
Add table
Reference in a new issue