Resolved issue #712. Default seam allowance setting.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-07-03 11:23:34 +03:00
parent 14b0eade7a
commit 13d43d100d
6 changed files with 27 additions and 14 deletions

View File

@ -6,6 +6,7 @@
- [#637] Max scene size too small to fit all objects. - [#637] Max scene size too small to fit all objects.
- New feature Zoom Fit Best Current pattern piece. - New feature Zoom Fit Best Current pattern piece.
- [#693] New feature: Sort workpiece "Groups" by name. - [#693] New feature: Sort workpiece "Groups" by name.
- [#712] Default seam allowance setting.
# Version 0.5.1 # Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions. - [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -52,7 +52,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
QMessageBox::information(this, QCoreApplication::applicationName(), qsMsg); QMessageBox::information(this, QCoreApplication::applicationName(), qsMsg);
}); });
ui->defaultSeamAllowance->setValue(qApp->ValentinaSettings()->GetDefaultSeamAllowance()); InitDefaultSeamAllowance();
ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()); ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
ui->doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark()); ui->doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark());
@ -92,3 +92,10 @@ void PreferencesPatternPage::Apply()
qApp->getCurrentDocument()->LiteParseTree(Document::LiteParse); qApp->getCurrentDocument()->LiteParseTree(Document::LiteParse);
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::InitDefaultSeamAllowance()
{
ui->defaultSeamAllowance->setValue(qApp->ValentinaSettings()->GetDefaultSeamAllowance());
ui->defaultSeamAllowance->setSuffix(UnitsToStr(StrToUnits(qApp->ValentinaSettings()->GetUnit()), true));
}

View File

@ -45,6 +45,7 @@ public:
virtual ~PreferencesPatternPage(); virtual ~PreferencesPatternPage();
void Apply(); void Apply();
void InitDefaultSeamAllowance();
private: private:
Q_DISABLE_COPY(PreferencesPatternPage) Q_DISABLE_COPY(PreferencesPatternPage)

View File

@ -126,6 +126,8 @@ void DialogPreferences::Apply()
m_patternPage->Apply(); m_patternPage->Apply();
m_pathPage->Apply(); m_pathPage->Apply();
m_patternPage->InitDefaultSeamAllowance();
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
emit UpdateProperties(); emit UpdateProperties();
setResult(QDialog::Accepted); setResult(QDialog::Accepted);

View File

@ -43,8 +43,6 @@
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"
//#include "../ifc/xml/vdomdocument.h"
const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements"); const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
const QString settingPathsStandardMeasurements = QStringLiteral("paths/standard_measurements"); const QString settingPathsStandardMeasurements = QStringLiteral("paths/standard_measurements");
@ -762,7 +760,7 @@ QChar VCommonSettings::GetDefCSVSeparator() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetDefaultSeamAllowance(double value) void VCommonSettings::SetDefaultSeamAllowance(double value)
{ {
setValue(settingPatternDefaultSeamAllowance, value); setValue(settingPatternDefaultSeamAllowance, UnitConvertor(value, StrToUnits(GetUnit()), Unit::Cm));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -774,7 +772,7 @@ double VCommonSettings::GetDefaultSeamAllowance()
{ {
double defaultValue; double defaultValue;
Unit globalUnit = StrToUnits(GetUnit()); const Unit globalUnit = StrToUnits(GetUnit());
switch (globalUnit) switch (globalUnit)
{ {
@ -791,15 +789,24 @@ double VCommonSettings::GetDefaultSeamAllowance()
} }
bool ok = false; bool ok = false;
double val = value(settingPatternDefaultSeamAllowance, defaultValue).toDouble(&ok); double val = value(settingPatternDefaultSeamAllowance, -1).toDouble(&ok);
if (ok == false) if (ok == false)
{ {
qDebug()<< "Could not convert value"<<value(settingPatternDefaultSeamAllowance, 0) qDebug()<< "Could not convert value"<<value(settingPatternDefaultSeamAllowance, 0)
<< "to int. Return default value for default seam allowance is " << "to real. Return default value for default seam allowance is "
<< defaultValue << "."; << defaultValue << ".";
val = defaultValue; val = defaultValue;
} }
if (val < 0)
{
val = defaultValue;
}
else
{
val = UnitConvertor(val, Unit::Cm, globalUnit);
}
return val; return val;
} }

View File

@ -2526,13 +2526,8 @@ void DialogSeamAllowance::InitSeamAllowanceTab()
connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance); connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
// init the default seam allowance, convert the value if app unit is different than pattern unit // init the default seam allowance, convert the value if app unit is different than pattern unit
m_saWidth = qApp->Settings()->GetDefaultSeamAllowance(); m_saWidth = UnitConvertor(qApp->Settings()->GetDefaultSeamAllowance(),
Unit defaultUnit = StrToUnits(qApp->Settings()->GetUnit()); StrToUnits(qApp->Settings()->GetUnit()), qApp->patternUnit());
Unit patternUnit = qApp->patternUnit();
if(defaultUnit != patternUnit)
{
m_saWidth = UnitConvertor(m_saWidth, defaultUnit, patternUnit);
}
uiTabPaths->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth)); uiTabPaths->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth));