Fixed issue #706. Default unit in preferences not changing new file unit.

(grafted from f1ce177213a46538a840fc789e4e2ce3d78d98e4)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-06-16 16:01:09 +03:00
parent 46d845f7e1
commit d110dc3325
8 changed files with 23 additions and 21 deletions

View File

@ -22,6 +22,7 @@
- Changed default behaviour if path to multisize measurements or templates doesn't exist. - Changed default behaviour if path to multisize measurements or templates doesn't exist.
- [#703] Valentina warns about format rewriting for unsaved files. - [#703] Valentina warns about format rewriting for unsaved files.
- [#704] Valentina crashes if click on detail. - [#704] Valentina crashes if click on detail.
- [#706] Default unit in preferences not changing new file unit.
# Version 0.5.0 May 9, 2017 # Version 0.5.0 May 9, 2017
- [#581] User can now filter input lists by keyword in function wizard. - [#581] User can now filter input lists by keyword in function wizard.

View File

@ -632,9 +632,7 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
if (not unitValue.isEmpty()) if (not unitValue.isEmpty())
{ {
const QStringList units = QStringList() << VDomDocument::UnitMM const QStringList units = QStringList() << unitMM << unitCM << unitINCH;
<< VDomDocument::UnitCM
<< VDomDocument::UnitINCH;
if (units.contains(unitValue)) if (units.contains(unitValue))
{ {
flagUnit = true; flagUnit = true;

View File

@ -195,9 +195,9 @@ void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::InitUnits() void PreferencesConfigurationPage::InitUnits()
{ {
ui->unitCombo->addItem(tr("Centimeters"), "cm"); ui->unitCombo->addItem(tr("Centimeters"), unitCM);
ui->unitCombo->addItem(tr("Millimiters"), "mm"); ui->unitCombo->addItem(tr("Millimiters"), unitMM);
ui->unitCombo->addItem(tr("Inches"), "in"); ui->unitCombo->addItem(tr("Inches"), unitINCH);
// set default unit // set default unit
const qint32 indexUnit = ui->unitCombo->findData(qApp->ValentinaSettings()->GetUnit()); const qint32 indexUnit = ui->unitCombo->findData(qApp->ValentinaSettings()->GetUnit());

View File

@ -179,10 +179,6 @@ void MessageHandler::handleMessage(QtMsgType type, const QString &description, c
Q_LOGGING_CATEGORY(vXML, "v.xml") Q_LOGGING_CATEGORY(vXML, "v.xml")
const QString VDomDocument::AttrId = QStringLiteral("id"); 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::TagVersion = QStringLiteral("version");
const QString VDomDocument::TagUnit = QStringLiteral("unit"); const QString VDomDocument::TagUnit = QStringLiteral("unit");
@ -488,7 +484,7 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Unit VDomDocument::MUnit() const Unit VDomDocument::MUnit() const
{ {
Unit unit = VDomDocument::StrToUnits(UniqueTagText(TagUnit, UnitCM)); Unit unit = VDomDocument::StrToUnits(UniqueTagText(TagUnit, unitCM));
if (unit == Unit::Px) if (unit == Unit::Px)
{ {
@ -655,7 +651,7 @@ void VDomDocument::setXMLContent(const QString &fileName)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Unit VDomDocument::StrToUnits(const QString &unit) 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; Unit result = Unit::Cm;
switch (units.indexOf(unit)) switch (units.indexOf(unit))
{ {
@ -691,17 +687,17 @@ QString VDomDocument::UnitsToStr(const Unit &unit, const bool translate)
switch (unit) switch (unit)
{ {
case Unit::Mm: case Unit::Mm:
translate ? result = QObject::tr("mm") : result = UnitMM; translate ? result = QObject::tr("mm") : result = unitMM;
break; break;
case Unit::Inch: case Unit::Inch:
translate ? result = QObject::tr("inch") : result = UnitINCH; translate ? result = QObject::tr("inch") : result = unitINCH;
break; break;
case Unit::Px: case Unit::Px:
translate ? result = QObject::tr("px") : result = UnitPX; translate ? result = QObject::tr("px") : result = unitPX;
break; break;
case Unit::Cm: case Unit::Cm:
default: default:
translate ? result = QObject::tr("cm") : result = UnitCM; translate ? result = QObject::tr("cm") : result = unitCM;
break; break;
} }
return result; return result;

View File

@ -83,10 +83,6 @@ class VDomDocument : public QDomDocument
Q_DECLARE_TR_FUNCTIONS(VDomDocument) Q_DECLARE_TR_FUNCTIONS(VDomDocument)
public: public:
static const QString AttrId; 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 TagVersion;
static const QString TagUnit; static const QString TagUnit;

View File

@ -119,6 +119,11 @@ const QString degreeSymbol = QStringLiteral("°");
const QString trueStr = QStringLiteral("true"); const QString trueStr = QStringLiteral("true");
const QString falseStr = QStringLiteral("false"); 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) void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY)
{ {

View File

@ -361,6 +361,11 @@ extern const QString strStraightforward;
extern const QString strBisector; extern const QString strBisector;
extern const QString strIntersection; 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(const QString & pixmapPath, int hotX = -1, int hotY = -1);
void SetOverrideCursor(Qt::CursorShape shape); void SetOverrideCursor(Qt::CursorShape shape);
void RestoreOverrideCursor(const QString & pixmapPath); void RestoreOverrideCursor(const QString & pixmapPath);

View File

@ -392,7 +392,8 @@ void VCommonSettings::SetPMSystemCode(const QString &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetUnit() const QString VCommonSettings::GetUnit() const
{ {
return value(settingConfigurationUnit, "cm").toString(); return value(settingConfigurationUnit,
QLocale().measurementSystem() == QLocale::MetricSystem ? unitCM : unitINCH).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------