Changed default behaviour if path to multisize measurements or templates doesn't

exist.

If the path doesn't exist Valentina will create and return path to user
localized default folder.
(grafted from 722c37544c26fe3f406d222b7f344ddf7b3602a0)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-06-05 17:52:42 +03:00
parent 65c98f6a39
commit 7a9b2e34bd
7 changed files with 39 additions and 39 deletions

View File

@ -17,6 +17,7 @@
- [#697] Incomplete Internal Path for Waist Dart.
- [#698] Problem typing in new axis point for new piece.
- [#702] Valentina produces broken shortcut (.lnk) files on Windows.
- Changed default behaviour if path to multisize measurements or templates doesn't exist.
# Version 0.5.0 May 9, 2017
- [#581] User can now filter input lists by keyword in function wizard.

View File

@ -104,7 +104,7 @@ void TapePreferencesPathPage::EditPath()
break;
case 1: // standard measurements
path = qApp->TapeSettings()->GetPathStandardMeasurements();
VCommonSettings::PrepareStandardTables(path);
path = VCommonSettings::PrepareStandardTables(path);
break;
case 2: // templates
path = qApp->TapeSettings()->GetPathTemplate();

View File

@ -417,8 +417,8 @@ void TMainWindow::OpenStandard()
const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst);;") + tr("Individual measurements") +
QLatin1String(" (*.vit);;") + tr("All files") + QLatin1String(" (*.*)");
//Use standard path to standard measurements
const QString pathTo = qApp->TapeSettings()->GetPathStandardMeasurements();
VCommonSettings::PrepareStandardTables(pathTo);
QString pathTo = qApp->TapeSettings()->GetPathStandardMeasurements();
pathTo = VCommonSettings::PrepareStandardTables(pathTo);
Open(pathTo, filter);
}
@ -429,8 +429,8 @@ void TMainWindow::OpenTemplate()
const QString filter = tr("Measurements") + QLatin1String(" (*.vst *.vit);;") + tr("All files") +
QLatin1String(" (*.*)");
//Use standard path to template files
const QString pathTo = qApp->TapeSettings()->GetPathTemplate();
VCommonSettings::PrepareStandardTemplates(pathTo);
QString pathTo = qApp->TapeSettings()->GetPathTemplate();
pathTo = VCommonSettings::PrepareStandardTemplates(pathTo);
Open(pathTo, filter);
if (m != nullptr)
@ -826,7 +826,7 @@ bool TMainWindow::FileSaveAs()
else
{
dir = qApp->TapeSettings()->GetPathStandardMeasurements();
VCommonSettings::PrepareStandardTables(dir);
dir = VCommonSettings::PrepareStandardTables(dir);
}
}
else
@ -1342,8 +1342,8 @@ void TMainWindow::ImportFromPattern()
const QString filter(tr("Pattern files (*.val)"));
//Use standard path to individual measurements
const QString pathTo = qApp->TapeSettings()->GetPathTemplate();
VCommonSettings::PrepareStandardTemplates(pathTo);
QString pathTo = qApp->TapeSettings()->GetPathTemplate();
pathTo = VCommonSettings::PrepareStandardTemplates(pathTo);
const QString mPath = QFileDialog::getOpenFileName(this, tr("Import from a pattern"), pathTo, filter);
if (mPath.isEmpty())

View File

@ -114,7 +114,7 @@ void PreferencesPathPage::EditPath()
break;
case 1: // standard measurements
path = qApp->ValentinaSettings()->GetPathStandardMeasurements();
VCommonSettings::PrepareStandardTables(path);
path = VCommonSettings::PrepareStandardTables(path);
break;
case 2: // pattern path
path = qApp->ValentinaSettings()->GetPathPattern();

View File

@ -1521,8 +1521,8 @@ void MainWindow::LoadStandard()
const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst);;") + tr("Individual measurements") +
QLatin1String("(*.vit)");
//Use standard path to standard measurements
const QString path = qApp->ValentinaSettings()->GetPathStandardMeasurements();
VCommonSettings::PrepareStandardTables(path);
QString path = qApp->ValentinaSettings()->GetPathStandardMeasurements();
path = VCommonSettings::PrepareStandardTables(path);
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter);
if (not mPath.isEmpty())
@ -4472,8 +4472,8 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
{
const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst)");
//Use standard path to standard measurements
const QString path = qApp->ValentinaSettings()->GetPathStandardMeasurements();
VCommonSettings::PrepareStandardTables(path);
QString path = qApp->ValentinaSettings()->GetPathStandardMeasurements();
path = VCommonSettings::PrepareStandardTables(path);
mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter);
}
else if (patternType == MeasurementsType::Individual)
@ -4502,8 +4502,8 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
const QString filter = tr("Individual measurements") + QLatin1String(" (*.vit);;") +
tr("Multisize measurements") + QLatin1String(" (*.vst)");
//Use standard path to individual measurements
const QString path = qApp->ValentinaSettings()->GetPathIndividualMeasurements();
VCommonSettings::PrepareStandardTables(VCommonSettings::GetDefPathStandardMeasurements());
QString path = qApp->ValentinaSettings()->GetPathIndividualMeasurements();
path = VCommonSettings::PrepareStandardTables(VCommonSettings::GetDefPathStandardMeasurements());
bool usedNotExistedDir = false;
QDir directory(path);

View File

@ -153,6 +153,23 @@ void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool
SymlinkCopyDirRecursive(from, to, replaceOnConflit);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString PrepareStandardFiles(const QString &currentPath, const QString &standardPath, const QString &defPath)
{
QDir standardPathDir(standardPath);
QDir currentPathDir(currentPath);
if ((currentPath == defPath || not currentPathDir.exists()) && standardPathDir.exists())
{
const QDir localdata (defPath);
if (localdata.mkpath("."))
{
SymlinkCopyDirRecursive(standardPath, defPath, false);
}
return defPath;
}
return currentPath;
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -218,33 +235,15 @@ QString VCommonSettings::StandardTemplatesPath()
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::PrepareStandardTemplates(const QString & currentPath)
QString VCommonSettings::PrepareStandardTemplates(const QString & currentPath)
{
QDir standardPath(VCommonSettings::StandardTemplatesPath());
const QDir localdata (VCommonSettings::GetDefPathTemplate());
if (currentPath == VCommonSettings::GetDefPathTemplate() && standardPath.exists())
{
if (localdata.mkpath("."))
{
SymlinkCopyDirRecursive(VCommonSettings::StandardTemplatesPath(), VCommonSettings::GetDefPathTemplate(),
false);
}
}
return PrepareStandardFiles(currentPath, StandardTemplatesPath(), GetDefPathTemplate());
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::PrepareStandardTables(const QString &currentPath)
QString VCommonSettings::PrepareStandardTables(const QString &currentPath)
{
QDir standardPath(VCommonSettings::StandardTablesPath());
const QDir localdata (VCommonSettings::GetDefPathStandardMeasurements());
if (currentPath == VCommonSettings::GetDefPathStandardMeasurements() && standardPath.exists())
{
if (localdata.mkpath("."))
{
SymlinkCopyDirRecursive(VCommonSettings::StandardTablesPath(),
VCommonSettings::GetDefPathStandardMeasurements(), false);
}
}
return PrepareStandardFiles(currentPath, StandardTablesPath(), GetDefPathStandardMeasurements());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -51,8 +51,8 @@ public:
static QString StandardTablesPath();
static QString StandardTemplatesPath();
static void PrepareStandardTemplates(const QString &currentPath);
static void PrepareStandardTables(const QString &currentPath);
static QString PrepareStandardTemplates(const QString &currentPath);
static QString PrepareStandardTables(const QString &currentPath);
static QString GetDefPathIndividualMeasurements();
QString GetPathIndividualMeasurements() const;