diff --git a/ChangeLog.txt b/ChangeLog.txt index f4cabec62..a0a051277 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -22,6 +22,7 @@ - Changed default behaviour if path to multisize measurements or templates doesn't exist. - [#703] Valentina warns about format rewriting for unsaved files. - [#704] Valentina crashes if click on detail. +- [#706] Default unit in preferences not changing new file unit. # Version 0.5.0 May 9, 2017 - [#581] User can now filter input lists by keyword in function wizard. diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index d0c57fc9c..7a27805a2 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -632,9 +632,7 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS if (not unitValue.isEmpty()) { - const QStringList units = QStringList() << VDomDocument::UnitMM - << VDomDocument::UnitCM - << VDomDocument::UnitINCH; + const QStringList units = QStringList() << unitMM << unitCM << unitINCH; if (units.contains(unitValue)) { flagUnit = true; diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index 015d3a0c4..349a96aa9 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -195,9 +195,9 @@ void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list) //--------------------------------------------------------------------------------------------------------------------- void PreferencesConfigurationPage::InitUnits() { - ui->unitCombo->addItem(tr("Centimeters"), "cm"); - ui->unitCombo->addItem(tr("Millimiters"), "mm"); - ui->unitCombo->addItem(tr("Inches"), "in"); + ui->unitCombo->addItem(tr("Centimeters"), unitCM); + ui->unitCombo->addItem(tr("Millimiters"), unitMM); + ui->unitCombo->addItem(tr("Inches"), unitINCH); // set default unit const qint32 indexUnit = ui->unitCombo->findData(qApp->ValentinaSettings()->GetUnit()); diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index cb4547176..e0a522b05 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -179,10 +179,6 @@ void MessageHandler::handleMessage(QtMsgType type, const QString &description, c Q_LOGGING_CATEGORY(vXML, "v.xml") const QString VDomDocument::AttrId = QStringLiteral("id"); -const QString VDomDocument::UnitMM = QStringLiteral("mm"); -const QString VDomDocument::UnitCM = QStringLiteral("cm"); -const QString VDomDocument::UnitINCH = QStringLiteral("inch"); -const QString VDomDocument::UnitPX = QStringLiteral("px"); const QString VDomDocument::TagVersion = QStringLiteral("version"); const QString VDomDocument::TagUnit = QStringLiteral("unit"); @@ -488,7 +484,7 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement) //--------------------------------------------------------------------------------------------------------------------- Unit VDomDocument::MUnit() const { - Unit unit = VDomDocument::StrToUnits(UniqueTagText(TagUnit, UnitCM)); + Unit unit = VDomDocument::StrToUnits(UniqueTagText(TagUnit, unitCM)); if (unit == Unit::Px) { @@ -655,7 +651,7 @@ void VDomDocument::setXMLContent(const QString &fileName) //--------------------------------------------------------------------------------------------------------------------- Unit VDomDocument::StrToUnits(const QString &unit) { - const QStringList units = QStringList() << UnitMM << UnitCM << UnitINCH << UnitPX; + const QStringList units = QStringList() << unitMM << unitCM << unitINCH << unitPX; Unit result = Unit::Cm; switch (units.indexOf(unit)) { @@ -691,17 +687,17 @@ QString VDomDocument::UnitsToStr(const Unit &unit, const bool translate) switch (unit) { case Unit::Mm: - translate ? result = QObject::tr("mm") : result = UnitMM; + translate ? result = QObject::tr("mm") : result = unitMM; break; case Unit::Inch: - translate ? result = QObject::tr("inch") : result = UnitINCH; + translate ? result = QObject::tr("inch") : result = unitINCH; break; case Unit::Px: - translate ? result = QObject::tr("px") : result = UnitPX; + translate ? result = QObject::tr("px") : result = unitPX; break; case Unit::Cm: default: - translate ? result = QObject::tr("cm") : result = UnitCM; + translate ? result = QObject::tr("cm") : result = unitCM; break; } return result; diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 58218e637..b1f546788 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -83,10 +83,6 @@ class VDomDocument : public QDomDocument Q_DECLARE_TR_FUNCTIONS(VDomDocument) public: static const QString AttrId; - static const QString UnitMM; - static const QString UnitCM; - static const QString UnitINCH; - static const QString UnitPX; static const QString TagVersion; static const QString TagUnit; diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index e9e7b3736..a56cdf368 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -119,6 +119,11 @@ const QString degreeSymbol = QStringLiteral("°"); const QString trueStr = QStringLiteral("true"); const QString falseStr = QStringLiteral("false"); +const QString unitMM = QStringLiteral("mm"); +const QString unitCM = QStringLiteral("cm"); +const QString unitINCH = QStringLiteral("inch"); +const QString unitPX = QStringLiteral("px"); + //--------------------------------------------------------------------------------------------------------------------- void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY) { diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index ee1d0e805..ffc216724 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -361,6 +361,11 @@ extern const QString strStraightforward; extern const QString strBisector; extern const QString strIntersection; +extern const QString unitMM; +extern const QString unitCM; +extern const QString unitINCH; +extern const QString unitPX; + void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1); void SetOverrideCursor(Qt::CursorShape shape); void RestoreOverrideCursor(const QString & pixmapPath); diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 218f1576e..a21413934 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -392,7 +392,8 @@ void VCommonSettings::SetPMSystemCode(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString VCommonSettings::GetUnit() const { - return value(settingConfigurationUnit, "cm").toString(); + return value(settingConfigurationUnit, + QLocale().measurementSystem() == QLocale::MetricSystem ? unitCM : unitINCH).toString(); } //---------------------------------------------------------------------------------------------------------------------