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.
- [#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.

View File

@ -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;

View File

@ -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());

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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);

View File

@ -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();
}
//---------------------------------------------------------------------------------------------------------------------