diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 3a6cd2d08..6cfc3c3a7 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -360,14 +360,6 @@ bool MainWindow::LoadMeasurements(const QString &path) } return false; } - QString shownName = strippedName(curFile); - if (curFile.isEmpty()) - { - shownName = tr("untitled.val"); - } - shownName += "[*]"; - shownName += " [" + strippedName(path) + "[*]]"; - setWindowTitle(shownName); return true; } @@ -1121,6 +1113,8 @@ void MainWindow::LoadIndividual() ui->actionShowM->setEnabled(true); helpLabel->setText(tr("Measurements loaded")); doc->LiteParseTree(Document::LiteParse); + + UpdateWindowTitle(); } } } @@ -1148,6 +1142,8 @@ void MainWindow::LoadStandard() ui->actionShowM->setEnabled(true); helpLabel->setText(tr("Measurements loaded")); doc->LiteParseTree(Document::LiteParse); + + UpdateWindowTitle(); } } } @@ -1170,13 +1166,7 @@ void MainWindow::UnloadMeasurements() ui->actionUnloadMeasurements->setDisabled(true); helpLabel->setText(tr("Measurements unloaded")); - QString shownName = strippedName(curFile); - if (curFile.isEmpty()) - { - shownName = tr("untitled.val"); - } - shownName += "[*]"; - setWindowTitle(shownName); + UpdateWindowTitle(); } else { @@ -2810,12 +2800,7 @@ void MainWindow::setCurrentFile(const QString &fileName) curFile = fileName; qApp->getUndoStack()->setClean(); - QString shownName = StrippedName(curFile); - if (curFile.isEmpty()) - { - shownName = tr("untitled.val"); - } - else + if (not curFile.isEmpty()) { qCDebug(vMainWindow, "Updating recent file list."); VSettings *settings = qApp->ValentinaSettings(); @@ -2836,14 +2821,8 @@ void MainWindow::setCurrentFile(const QString &fileName) restoreFiles.prepend(fileName); settings->SetRestoreFileList(restoreFiles); } - shownName+="[*]"; - QString path = AbsoluteMPath(fileName, doc->MPath()); - if(not path.isEmpty()) - { - shownName += " [" + strippedName(path) + "[*]]"; - } - setWindowTitle(shownName); + UpdateWindowTitle(); } //--------------------------------------------------------------------------------------------------------------------- @@ -3889,3 +3868,45 @@ void MainWindow::ProcessCMD() qApp->exit(V_EX_OK);// close program after processing in console mode } } + +//--------------------------------------------------------------------------------------------------------------------- +QString MainWindow::GetPatternFileName() +{ + QString shownName = tr("untitled.val"); + if(not curFile.isEmpty()) + { + shownName = StrippedName(curFile); + } + shownName += "[*]"; + return shownName; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString MainWindow::GetMeasurementFileName() +{ + if(doc->MPath().isEmpty()) + { + return ""; + } + else + { + QString shownName = " ["; + shownName += StrippedName(AbsoluteMPath(curFile, doc->MPath())); + + if(mChanges) + { + shownName += "[*]"; + } + + shownName += "]"; + return shownName; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::UpdateWindowTitle() +{ + QString shownName = GetPatternFileName(); + shownName += GetMeasurementFileName(); + setWindowTitle(shownName); +} diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 0650b337c..19c05e5fa 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -310,6 +310,11 @@ private: void SetSize(const QString &text); void SetHeight(const QString & text); + + QString GetPatternFileName(); + QString GetMeasurementFileName(); + + void UpdateWindowTitle(); }; #endif // MAINWINDOW_H