Resolved issue #927. Freeze prefix language on pattern/project creation.
--HG-- branch : develop
This commit is contained in:
parent
63db1f4d7d
commit
5cb31f77f4
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<int>::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<QString>(ui->comboBoxLabelLanguage->currentData()));
|
||||
|
||||
descriptionChanged = false;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>655</width>
|
||||
<height>547</height>
|
||||
<width>726</width>
|
||||
<height>681</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -80,6 +80,46 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Label language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxLabelLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="spacing">
|
||||
|
|
|
@ -74,13 +74,15 @@
|
|||
#endif /* Q_CC_MSVC */
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
<file>schema/pattern/v0.7.11.xsd</file>
|
||||
<file>schema/pattern/v0.7.12.xsd</file>
|
||||
<file>schema/pattern/v0.7.13.xsd</file>
|
||||
<file>schema/pattern/v0.8.0.xsd</file>
|
||||
<file>schema/standard_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.1.xsd</file>
|
||||
|
|
1099
src/libs/ifc/schema/pattern/v0.8.0.xsd
Normal file
1099
src/libs/ifc/schema/pattern/v0.8.0.xsd
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -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,18 +229,17 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ApplyPatches()
|
||||
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user