Resolved issue #569. Tape app. Options that open new file open new instance

even if a user doesn't want this.
(grafted from a74c6d9fac8dd6920d7d0914e68770b893920380)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-09-27 12:27:52 +03:00
parent 014ce1e45e
commit de1c7cd9f3
2 changed files with 41 additions and 59 deletions

View File

@ -62,7 +62,8 @@
- [#543] Detail loses details.
- [#548] Bug Detail tool. Case when seam allowance is wrong.
- Called the main app in console mode doesn't show opening file error in some cases.
- [#553] Tape.exe crash. Issue with the Search field.
- [#553] Tape.exe crash. Issue with the Search field.
- [#569] Tape app. Options that open new file open new instance even if a user doesn't want this.
# Version 0.4.4 April 12, 2016
- Updated measurement templates with all measurements. Added new template Aldrich/Women measurements.

View File

@ -384,79 +384,57 @@ void TMainWindow::FileNew()
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::OpenIndividual()
{
if (m == nullptr)
{
const QString filter = tr("Individual measurements (*.vit);;Standard measurements (*.vst);;All files (*.*)");
//Use standard path to individual measurements
const QString pathTo = qApp->TapeSettings()->GetPathIndividualMeasurements();
Open(pathTo, filter);
}
else
{
qApp->NewMainWindow();
qApp->MainWindow()->OpenIndividual();
}
const QString filter = tr("Individual measurements (*.vit);;Standard measurements (*.vst);;All files (*.*)");
//Use standard path to individual measurements
const QString pathTo = qApp->TapeSettings()->GetPathIndividualMeasurements();
Open(pathTo, filter);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::OpenStandard()
{
if (m == nullptr)
{
const QString filter = tr("Standard measurements (*.vst);;Individual measurements (*.vit);;All files (*.*)");
//Use standard path to standard measurements
const QString pathTo = qApp->TapeSettings()->GetPathStandardMeasurements();
Open(pathTo, filter);
}
else
{
qApp->NewMainWindow();
qApp->MainWindow()->OpenStandard();
}
const QString filter = tr("Standard measurements (*.vst);;Individual measurements (*.vit);;All files (*.*)");
//Use standard path to standard measurements
const QString pathTo = qApp->TapeSettings()->GetPathStandardMeasurements();
Open(pathTo, filter);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::OpenTemplate()
{
if (m == nullptr)
{
const QString filter = tr("Measurements (*.vst *.vit);;All files (*.*)");
//Use standard path to template files
const QString pathTo = qApp->TapeSettings()->GetPathTemplate();
Open(pathTo, filter);
const QString filter = tr("Measurements (*.vst *.vit);;All files (*.*)");
//Use standard path to template files
const QString pathTo = qApp->TapeSettings()->GetPathTemplate();
if (m != nullptr)
{// The file was opened.
SetCurrentFile(""); // Force user to to save new file
lock.reset();// remove lock from template
}
}
else
{
qApp->NewMainWindow();
qApp->MainWindow()->OpenTemplate();
Open(pathTo, filter);
if (m != nullptr)
{// The file was opened.
SetCurrentFile(""); // Force user to to save new file
lock.reset();// remove lock from template
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::CreateFromExisting()
{
if (m == nullptr)
{
const QString filter = tr("Individual measurements (*.vit)");
//Use standard path to standard measurements
const QString pathTo = qApp->TapeSettings()->GetPathIndividualMeasurements();
const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), pathTo, filter);
const QString filter = tr("Individual measurements (*.vit)");
//Use standard path to standard measurements
const QString pathTo = qApp->TapeSettings()->GetPathIndividualMeasurements();
const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), pathTo, filter);
if (not mPath.isEmpty())
if (not mPath.isEmpty())
{
if (m == nullptr)
{
LoadFromExistingFile(mPath);
}
}
else
{
qApp->NewMainWindow();
qApp->MainWindow()->CreateFromExisting();
else
{
qApp->NewMainWindow()->CreateFromExisting();
}
}
}
@ -2522,13 +2500,16 @@ void TMainWindow::Open(const QString &pathTo, const QString &filter)
{
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), pathTo, filter);
if (mPath.isEmpty())
if (not mPath.isEmpty())
{
return;
}
else
{
LoadFile(mPath);
if (m == nullptr)
{
LoadFile(mPath);
}
else
{
qApp->NewMainWindow()->LoadFile(mPath);
}
}
}