Fix the tape app importing of measurments from a pattern

When importing measurements from a pattern in the tape app, it
defaulted to the templates directory instead of the patterns
directory. The patterns directory was set as a setting in the
valentina settings (VSettings) instead of the common settings
(VCommonSettings). I refactored the the setting into the
VCommonSettings and made the tape app use the setting. I was
able to confirm that setting a new pattern directory resulted
in the same pattern directory being used in both Valentina and
tape.

--HG--
branch : develop
This commit is contained in:
Wren Turkal 2019-01-05 16:46:31 -08:00
parent 610538e070
commit 42b00c5c58
5 changed files with 27 additions and 28 deletions

View File

@ -1410,8 +1410,7 @@ void TMainWindow::ImportFromPattern()
const QString filter(tr("Pattern files (*.val)"));
//Use standard path to individual measurements
QString pathTo = qApp->TapeSettings()->GetPathTemplate();
pathTo = VCommonSettings::PrepareStandardTemplates(pathTo);
QString pathTo = qApp->TapeSettings()->GetPathPattern();
const QString mPath = QFileDialog::getOpenFileName(this, tr("Import from a pattern"), pathTo, filter);
if (mPath.isEmpty())

View File

@ -50,6 +50,7 @@ namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, (QLatin1String("paths/standard_measurements")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels")))
@ -353,6 +354,27 @@ void VCommonSettings::SetPathMultisizeMeasurements(const QString &value)
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetDefPathPattern()
{
return QDir::homePath() + QLatin1String("/valentina/") + tr("patterns");
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetPathPattern() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingPathsPattern, GetDefPathPattern()).toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetPathPattern(const QString &value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingPathsPattern, value);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetDefPathTemplate()
{

View File

@ -64,6 +64,10 @@ public:
QString GetPathMultisizeMeasurements() const;
void SetPathMultisizeMeasurements(const QString &value);
static QString GetDefPathPattern();
QString GetPathPattern() const;
void SetPathPattern(const QString &value);
static QString GetDefPathTemplate();
QString GetPathTemplate() const;
void SetPathTemplate(const QString &value);

View File

@ -71,7 +71,6 @@ namespace
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage,
(QLatin1String("configuration/label_language")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput")))
@ -135,27 +134,6 @@ void VSettings::SetLabelLanguage(const QString &value)
setValue(*settingConfigurationLabelLanguage, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetDefPathPattern()
{
return QDir::homePath() + QLatin1String("/valentina/") + tr("patterns");
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetPathPattern() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
return settings.value(*settingPathsPattern, GetDefPathPattern()).toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetPathPattern(const QString &value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
settings.setValue(*settingPathsPattern, value);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetDefPathLayout()
{

View File

@ -57,10 +57,6 @@ public:
QString GetLabelLanguage() const;
void SetLabelLanguage(const QString &value);
static QString GetDefPathPattern();
QString GetPathPattern() const;
void SetPathPattern(const QString &value);
static QString GetDefPathLayout();
QString GetPathLayout() const;
void SetPathLayout(const QString &value);