Fixed issue #397. Added UpdateWindowTitle

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2015-11-04 07:06:44 +02:00
parent 5b9914f409
commit aba82baa98
2 changed files with 54 additions and 28 deletions

View File

@ -360,14 +360,6 @@ bool MainWindow::LoadMeasurements(const QString &path)
} }
return false; return false;
} }
QString shownName = strippedName(curFile);
if (curFile.isEmpty())
{
shownName = tr("untitled.val");
}
shownName += "[*]";
shownName += " [" + strippedName(path) + "[*]]";
setWindowTitle(shownName);
return true; return true;
} }
@ -1121,6 +1113,8 @@ void MainWindow::LoadIndividual()
ui->actionShowM->setEnabled(true); ui->actionShowM->setEnabled(true);
helpLabel->setText(tr("Measurements loaded")); helpLabel->setText(tr("Measurements loaded"));
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
UpdateWindowTitle();
} }
} }
} }
@ -1148,6 +1142,8 @@ void MainWindow::LoadStandard()
ui->actionShowM->setEnabled(true); ui->actionShowM->setEnabled(true);
helpLabel->setText(tr("Measurements loaded")); helpLabel->setText(tr("Measurements loaded"));
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
UpdateWindowTitle();
} }
} }
} }
@ -1170,13 +1166,7 @@ void MainWindow::UnloadMeasurements()
ui->actionUnloadMeasurements->setDisabled(true); ui->actionUnloadMeasurements->setDisabled(true);
helpLabel->setText(tr("Measurements unloaded")); helpLabel->setText(tr("Measurements unloaded"));
QString shownName = strippedName(curFile); UpdateWindowTitle();
if (curFile.isEmpty())
{
shownName = tr("untitled.val");
}
shownName += "[*]";
setWindowTitle(shownName);
} }
else else
{ {
@ -2810,12 +2800,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
curFile = fileName; curFile = fileName;
qApp->getUndoStack()->setClean(); qApp->getUndoStack()->setClean();
QString shownName = StrippedName(curFile); if (not curFile.isEmpty())
if (curFile.isEmpty())
{
shownName = tr("untitled.val");
}
else
{ {
qCDebug(vMainWindow, "Updating recent file list."); qCDebug(vMainWindow, "Updating recent file list.");
VSettings *settings = qApp->ValentinaSettings(); VSettings *settings = qApp->ValentinaSettings();
@ -2836,14 +2821,8 @@ void MainWindow::setCurrentFile(const QString &fileName)
restoreFiles.prepend(fileName); restoreFiles.prepend(fileName);
settings->SetRestoreFileList(restoreFiles); settings->SetRestoreFileList(restoreFiles);
} }
shownName+="[*]";
QString path = AbsoluteMPath(fileName, doc->MPath()); UpdateWindowTitle();
if(not path.isEmpty())
{
shownName += " [" + strippedName(path) + "[*]]";
}
setWindowTitle(shownName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3889,3 +3868,45 @@ void MainWindow::ProcessCMD()
qApp->exit(V_EX_OK);// close program after processing in console mode 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);
}

View File

@ -310,6 +310,11 @@ private:
void SetSize(const QString &text); void SetSize(const QString &text);
void SetHeight(const QString & text); void SetHeight(const QString & text);
QString GetPatternFileName();
QString GetMeasurementFileName();
void UpdateWindowTitle();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H