Added global option "Forbid Flipping". ref #560.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-09-06 17:05:54 +03:00
parent ef576d7646
commit 0d35033275
8 changed files with 51 additions and 18 deletions

View File

@ -54,18 +54,22 @@ PatternPage::PatternPage(QWidget *parent):
undoCount(nullptr),
countStepsLabel(nullptr),
userMaterialsGroup(nullptr),
userMaterialClearButton(nullptr)
userMaterialClearButton(nullptr),
workpieceGroup(nullptr),
forbidFlippingCheck(nullptr)
{
QGroupBox *userGroup = UserGroup();
QGroupBox *graphOutputGroup = GraphOutputGroup();
QGroupBox *undoGroup = UndoGroup();
QGroupBox *userMatGroup = UserMaterialGroup();
QGroupBox *userMatGroup = UserMaterialGroup();
QGroupBox *workpieceGroup = UserWorkpieceGroup();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(userGroup);
mainLayout->addWidget(graphOutputGroup);
mainLayout->addWidget(undoGroup);
mainLayout->addWidget(userMatGroup);
mainLayout->addWidget(workpieceGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
@ -85,6 +89,8 @@ void PatternPage::Apply()
* non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack
* prints a warning and does nothing.*/
settings->SetUndoCount(undoCount->value());
settings->SetForbidWorkpieceFlipping(forbidFlippingCheck->isChecked());
}
//---------------------------------------------------------------------------------------------------------------------
@ -183,6 +189,22 @@ QGroupBox *PatternPage::UserMaterialGroup()
return userMaterialsGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::UserWorkpieceGroup()
{
workpieceGroup = new QGroupBox(tr("Workpiece"));
forbidFlippingCheck = new QCheckBox(tr("Forbid flipping"));
forbidFlippingCheck->setToolTip(tr("By default forbid flipping for all workpieces"));
forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
QVBoxLayout *editLayout = new QVBoxLayout;
editLayout->addWidget(forbidFlippingCheck);
workpieceGroup->setLayout(editLayout);
return workpieceGroup;
}
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::RetranslateUi()
{

View File

@ -61,11 +61,14 @@ private:
QLabel *countStepsLabel;
QGroupBox *userMaterialsGroup;
QPushButton* userMaterialClearButton;
QGroupBox *workpieceGroup;
QCheckBox *forbidFlippingCheck;
QGroupBox *UserGroup() Q_REQUIRED_RESULT;
QGroupBox *GraphOutputGroup() Q_REQUIRED_RESULT;
QGroupBox *UndoGroup() Q_REQUIRED_RESULT;
QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT;
QGroupBox *UserWorkpieceGroup() Q_REQUIRED_RESULT;
void RetranslateUi();
};

View File

@ -616,7 +616,8 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1"));
detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1"));
detail.setForbidFlipping(GetParametrUInt(domElement, VToolDetail::AttrForbidFlipping, "0"));
detail.setForbidFlipping(GetParametrUInt(domElement, VToolDetail::AttrForbidFlipping,
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
QStringList types = QStringList() << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline

View File

@ -61,6 +61,7 @@ const QString VCommonSettings::SettingConfigurationToolBarStyle = QString
const QString VCommonSettings::SettingPatternUser = QStringLiteral("pattern/user");
const QString VCommonSettings::SettingPatternUndo = QStringLiteral("pattern/undo");
const QString VCommonSettings::SettingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
const QString VCommonSettings::SettingGeneralRecentFileList = QStringLiteral("recentFileList");
const QString VCommonSettings::SettingGeneralRestoreFileList = QStringLiteral("restoreFileList");
@ -70,7 +71,7 @@ const QString VCommonSettings::SettingGeneralToolbarsState = QString
const QString VCommonSettings::SettingPreferenceDialogSize = QStringLiteral("preferenceDialogSize");
const QString VCommonSettings::SettingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion");
const QString VCommonSettings::SettingDateOfLastRemind = QStringLiteral("dateOfLastRemind");
const QString VCommonSettings::SettingUserDefinedMaterials = QStringLiteral("configuration/userDefinedMaterials");
const QString VCommonSettings::SettingUserDefinedMaterials = QStringLiteral("configuration/userDefinedMaterials");
static const QString commonIniFilename = QStringLiteral("common");
@ -486,3 +487,15 @@ void VCommonSettings::ClearUserDefinedMaterial()
QStringList qsl;
setValue(SettingUserDefinedMaterials, qsl);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetForbidWorkpieceFlipping() const
{
return value(SettingPatternForbidFlipping, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetForbidWorkpieceFlipping(bool value)
{
setValue(SettingPatternForbidFlipping, value);
}

View File

@ -122,6 +122,9 @@ public:
void AddUserDefinedMaterial(QString qsMaterial);
void ClearUserDefinedMaterial();
bool GetForbidWorkpieceFlipping() const;
void SetForbidWorkpieceFlipping(bool value);
private:
Q_DISABLE_COPY(VCommonSettings)
@ -141,6 +144,7 @@ private:
static const QString SettingPatternUser;
static const QString SettingPatternUndo;
static const QString SettingPatternForbidFlipping;
static const QString SettingGeneralRecentFileList;
static const QString SettingGeneralRestoreFileList;

View File

@ -85,6 +85,8 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
ui.lineEditLetter->setClearButtonEnabled(true);
#endif
ui.checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
labelEditNamePoint = ui.labelEditName;
ui.labelUnit->setText( VDomDocument::UnitsToStr(qApp->patternUnit(), true));
ui.labelUnitX->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));

View File

@ -433,11 +433,7 @@ void VToolDetail::AddToFile()
doc->SetAttribute(domElement, AttrSupplement, static_cast<quint8>(detail.getSeamAllowance()));
doc->SetAttribute(domElement, AttrClosed, static_cast<quint8>(detail.getClosed()));
doc->SetAttribute(domElement, AttrWidth, detail.getWidth());
if (detail.getForbidFlipping())//for backward compatibility
{
doc->SetAttribute(domElement, AttrForbidFlipping, static_cast<quint8>(detail.getForbidFlipping()));
}
doc->SetAttribute(domElement, AttrForbidFlipping, static_cast<quint8>(detail.getForbidFlipping()));
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
const VPatternPieceData& data = detail.GetPatternPieceData();

View File

@ -140,15 +140,7 @@ void SaveDetailOptions::SaveDet(QDomElement &domElement, const VDetail &det)
doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(det.getSeamAllowance()));
doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(det.getClosed()));
doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(det.getWidth()));
if (det.getForbidFlipping())//for backward compatibility
{
doc->SetAttribute(domElement, VToolDetail::AttrForbidFlipping, QString().setNum(det.getForbidFlipping()));
}
else
{
domElement.removeAttribute(VToolDetail::AttrForbidFlipping);
}
doc->SetAttribute(domElement, VToolDetail::AttrForbidFlipping, QString().setNum(det.getForbidFlipping()));
}
//---------------------------------------------------------------------------------------------------------------------