From 474f788d403d0751454f1af7455bd4e40073603a Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 7 Jul 2015 00:53:24 +0200 Subject: [PATCH] code for generation of window title has been outsourced to the Qt utilities library --- gui/mainwindow.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 17d3937..1e6e381 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -8,6 +8,7 @@ #include #include +#include #include @@ -589,24 +590,17 @@ void MainWindow::updateUiStatus() */ void MainWindow::updateWindowTitle() { - if(m_file.path().empty()) { - if(m_file.hasRootEntry()) { - if(m_somethingChanged) { - setWindowTitle(QStringLiteral("*Unsaved - %1").arg(QApplication::applicationName())); - } else { - setWindowTitle(QStringLiteral("Unsaved - %1").arg(QApplication::applicationName())); - } + Dialogs::DocumentStatus docStatus; + if(m_file.hasRootEntry()) { + if(m_somethingChanged) { + docStatus = Dialogs::DocumentStatus::Unsaved; } else { - setWindowTitle(QApplication::applicationName()); + docStatus = Dialogs::DocumentStatus::Saved; } } else { - QFileInfo file = QString::fromStdString(m_file.path()); - if(m_somethingChanged) { - setWindowTitle(QStringLiteral("*%1 - %2 - %3").arg(file.fileName(), file.dir().path(), QApplication::applicationName())); - } else { - setWindowTitle(QStringLiteral("%1 - %2 - %3").arg(file.fileName(), file.dir().path(), QApplication::applicationName())); - } + docStatus = Dialogs::DocumentStatus::NoDocument; } + setWindowTitle(Dialogs::generateWindowTitle(docStatus, QString::fromStdString(m_file.path()))); } void MainWindow::applyDefaultExpanding(const QModelIndex &parent)