diff --git a/ChangeLog.txt b/ChangeLog.txt index 30d92d284..4d392008b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -6,6 +6,7 @@ - [#651] Improve feature: Layout orientation according to grainline. - New command line option --landscapeOrientation. - Added ability to search measurements by regex. +- [#927] Freeze prefix language on pattern/project creation. # Version 0.6.2 (unreleased) - [#903] Bug in tool Cut Spline path. diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 632723408..171c5b920 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -622,14 +622,14 @@ void VApplication::InitOptions() //--------------------------------------------------------------------------------------------------------------------- QStringList VApplication::LabelLanguages() { - QStringList list = QStringList() << "de" // German - << "en" // English - << "fr" // French - << "ru" // Russian - << "uk" // Ukrainian - << "hr" // Croatian - << "sr" // Serbian - << "bs"; // Bosnian + QStringList list {"de", // German + "en", // English + "fr", // French + "ru", // Russian + "uk", // Ukrainian + "hr", // Croatian + "sr", // Serbian + "bs"}; // Bosnian return list; } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index dee43f51d..28f93b6a2 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -108,6 +108,21 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat ui->pushButtonShowInExplorer->setText(tr("Show in Finder")); #endif //defined(Q_OS_MAC) + //----------------------- Label language + for (auto &name : VApplication::LabelLanguages()) + { + ui->comboBoxLabelLanguage->addItem(QLocale(name).nativeLanguageName(), name); + } + + int index = ui->comboBoxLabelLanguage->findData(qApp->ValentinaSettings()->GetLabelLanguage()); + if (index != -1) + { + ui->comboBoxLabelLanguage->setCurrentIndex(index); + } + + connect(ui->comboBoxLabelLanguage, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogPatternProperties::DescEdited); + ui->plainTextEditDescription->setPlainText(doc->GetDescription()); connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited); @@ -568,6 +583,7 @@ void DialogPatternProperties::SaveDescription() { doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); + doc->SetLabelPrefix(qvariant_cast(ui->comboBoxLabelLanguage->currentData())); descriptionChanged = false; } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index 3efd2099f..90117708f 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -6,8 +6,8 @@ 0 0 - 655 - 547 + 726 + 681 @@ -80,6 +80,46 @@ + + + + + + + 0 + 0 + + + + Label language: + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index be459b28e..cdb73f75f 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -73,14 +73,16 @@ #include #endif /* Q_CC_MSVC */ -const QString VPattern::AttrReadOnly = QStringLiteral("readOnly"); +const QString VPattern::AttrReadOnly = QStringLiteral("readOnly"); +const QString VPattern::AttrLabelPrefix = QStringLiteral("labelPrefix"); namespace { //--------------------------------------------------------------------------------------------------------------------- QString FileComment() { - return QString("Pattern created with Valentina v%1 (https://valentinaproject.bitbucket.io/).").arg(APP_VERSION_STR); + return QStringLiteral("Pattern created with Valentina v%1 (https://valentinaproject.bitbucket.io/).") + .arg(APP_VERSION_STR); } //--------------------------------------------------------------------------------------------------------------------- @@ -88,7 +90,18 @@ void GatherCount(int &count, const int nodes) { count += nodes; } + +//--------------------------------------------------------------------------------------------------------------------- +QString DefLabelLanguage() +{ + QString def = qApp->ValentinaSettings()->GetLabelLanguage(); + if (not VApplication::LabelLanguages().toSet().contains(def)) + { + def = QStringLiteral("en"); + } + return def; } +} // anonymous namespace //--------------------------------------------------------------------------------------------------------------------- VPattern::VPattern(VContainer *data, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, QObject *parent) @@ -106,6 +119,7 @@ void VPattern::CreateEmptyFile() { this->clear(); QDomElement patternElement = this->createElement(TagPattern); + SetAttribute(patternElement, AttrLabelPrefix, DefLabelLanguage()); patternElement.appendChild(createComment(FileComment())); @@ -1290,10 +1304,8 @@ void VPattern::ParseCurrentPP() //--------------------------------------------------------------------------------------------------------------------- QString VPattern::GetLabelBase(quint32 index) const { - const QStringList list = VApplication::LabelLanguages(); - const QString def = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); QStringList alphabet; - switch (list.indexOf(qApp->ValentinaSettings()->GetLabelLanguage())) + switch (VApplication::LabelLanguages().indexOf(GetLabelPrefix())) { case 0: // de { @@ -1335,7 +1347,8 @@ QString VPattern::GetLabelBase(quint32 index) const case 1: // en default: // en { - alphabet = def.split(QChar(',')); + const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); + alphabet = al.split(QChar(',')); break; } } @@ -4207,6 +4220,34 @@ void VPattern::SetReadOnly(bool rOnly) } } +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GetLabelPrefix() const +{ + const QDomElement pattern = documentElement(); + + if (pattern.isNull()) + { + return DefLabelLanguage(); + } + + return GetParametrString(pattern, AttrLabelPrefix, DefLabelLanguage()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetLabelPrefix(const QString &prefix) +{ + QDomElement pattern = documentElement(); + + if (not pattern.isNull()) + { + if (VApplication::LabelLanguages().toSet().contains(prefix)) + { + SetAttribute(pattern, AttrLabelPrefix, prefix); + modified = true; + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPattern::PrepareForParse(const Document &parse) { diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 75cd6d1ab..7bfb3fa40 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -108,9 +108,13 @@ public: bool IsReadOnly() const; void SetReadOnly(bool rOnly); + QString GetLabelPrefix() const; + void SetLabelPrefix(const QString &prefix); + void LiteParseIncrements(); static const QString AttrReadOnly; + static const QString AttrLabelPrefix; int ElementsToParse() const; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 794927d11..b93cd30d2 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -51,6 +51,7 @@ schema/pattern/v0.7.11.xsd schema/pattern/v0.7.12.xsd schema/pattern/v0.7.13.xsd + schema/pattern/v0.8.0.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.8.0.xsd b/src/libs/ifc/schema/pattern/v0.8.0.xsd new file mode 100644 index 000000000..6f753570e --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.8.0.xsd @@ -0,0 +1,1099 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 02951a01f..d3295e172 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -59,8 +59,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.13"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.13.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.0"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.0.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -229,17 +229,16 @@ QString VPatternConverter::XSDSchema(int ver) const std::make_pair(FORMAT_VERSION(0, 7, 10), QStringLiteral("://schema/pattern/v0.7.10.xsd")), std::make_pair(FORMAT_VERSION(0, 7, 11), QStringLiteral("://schema/pattern/v0.7.11.xsd")), std::make_pair(FORMAT_VERSION(0, 7, 12), QStringLiteral("://schema/pattern/v0.7.12.xsd")), - std::make_pair(FORMAT_VERSION(0, 7, 13), CurrentSchema) + std::make_pair(FORMAT_VERSION(0, 7, 13), QStringLiteral("://schema/pattern/v0.7.13.xsd")), + std::make_pair(FORMAT_VERSION(0, 8, 0), CurrentSchema) }; if (schemas.contains(ver)) { return schemas.value(ver); } - else - { - InvalidVersion(ver); - } + + InvalidVersion(ver); } //--------------------------------------------------------------------------------------------------------------------- @@ -448,6 +447,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 13)), m_convertedFileName); V_FALLTHROUGH case (FORMAT_VERSION(0, 7, 13)): + ToV0_8_0(); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 0)), m_convertedFileName); + V_FALLTHROUGH + case (FORMAT_VERSION(0, 8, 0)): break; default: InvalidVersion(m_ver); @@ -465,7 +468,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 7, 13), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 0), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -1025,6 +1028,16 @@ void VPatternConverter::ToV0_7_13() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_8_0() +{ + // TODO. Delete if minimal supported version is 0.8.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 0), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.8.0")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 8fc6f4e86..5efc09022 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4); - static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 7, 13); + static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 0); protected: virtual int MinVer() const override; @@ -122,6 +122,7 @@ private: void ToV0_7_11(); void ToV0_7_12(); void ToV0_7_13(); + void ToV0_8_0(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0();