diff --git a/src/app/valentina/dialogs/configpages/configurationpage.cpp b/src/app/valentina/dialogs/configpages/configurationpage.cpp index 4bc1915c0..f13c5d96b 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/configurationpage.cpp @@ -43,6 +43,7 @@ #include #include #include +#include //--------------------------------------------------------------------------------------------------------------------- ConfigurationPage::ConfigurationPage(QWidget *parent) diff --git a/src/app/valentina/dialogs/configpages/patternpage.cpp b/src/app/valentina/dialogs/configpages/patternpage.cpp index 11edccf1d..072e9cd93 100644 --- a/src/app/valentina/dialogs/configpages/patternpage.cpp +++ b/src/app/valentina/dialogs/configpages/patternpage.cpp @@ -39,6 +39,8 @@ #include #include #include +#include +#include //--------------------------------------------------------------------------------------------------------------------- PatternPage::PatternPage(QWidget *parent): @@ -50,16 +52,20 @@ PatternPage::PatternPage(QWidget *parent): graphOutputCheck(nullptr), undoGroup(nullptr), undoCount(nullptr), - countStepsLabel(nullptr) + countStepsLabel(nullptr), + userMaterialsGroup(nullptr), + userMaterialClearButton(nullptr) { QGroupBox *userGroup = UserGroup(); QGroupBox *graphOutputGroup = GraphOutputGroup(); QGroupBox *undoGroup = UndoGroup(); + QGroupBox *userMatGroup = UserMaterialGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(userGroup); mainLayout->addWidget(graphOutputGroup); mainLayout->addWidget(undoGroup); + mainLayout->addWidget(userMatGroup); mainLayout->addStretch(1); setLayout(mainLayout); } @@ -81,6 +87,16 @@ void PatternPage::Apply() settings->SetUndoCount(undoCount->value()); } +//--------------------------------------------------------------------------------------------------------------------- +void PatternPage::ClearUserDefinedMaterials() +{ + VSettings* pSet = qApp->ValentinaSettings(); + pSet->ClearUserDefinedMaterial(); + pSet->sync(); + QString qsMsg = tr("All user defined materials have been deleted!"); + QMessageBox::information(this, QApplication::applicationName(), qsMsg); +} + //--------------------------------------------------------------------------------------------------------------------- void PatternPage::changeEvent(QEvent *event) { @@ -152,6 +168,21 @@ QGroupBox *PatternPage::UndoGroup() return undoGroup; } +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PatternPage::UserMaterialGroup() +{ + userMaterialsGroup = new QGroupBox(tr("User defined materials")); + userMaterialClearButton = new QPushButton(tr("Delete all")); + connect(userMaterialClearButton, &QPushButton::clicked, this, &PatternPage::ClearUserDefinedMaterials); + + QHBoxLayout* pLayout = new QHBoxLayout; + pLayout->addWidget(userMaterialClearButton); + pLayout->addStretch(1); + + userMaterialsGroup->setLayout(pLayout); + return userMaterialsGroup; +} + //--------------------------------------------------------------------------------------------------------------------- void PatternPage::RetranslateUi() { diff --git a/src/app/valentina/dialogs/configpages/patternpage.h b/src/app/valentina/dialogs/configpages/patternpage.h index da28f7e46..176d004c4 100644 --- a/src/app/valentina/dialogs/configpages/patternpage.h +++ b/src/app/valentina/dialogs/configpages/patternpage.h @@ -37,6 +37,7 @@ class QSpinBox; class QGroupBox; class QLineEdit; class QLabel; +class QPushButton; class PatternPage : public QWidget { @@ -44,6 +45,8 @@ class PatternPage : public QWidget public: explicit PatternPage(QWidget *parent = nullptr); void Apply(); +public slots: + void ClearUserDefinedMaterials(); protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private: @@ -56,9 +59,13 @@ private: QGroupBox *undoGroup; QSpinBox *undoCount; QLabel *countStepsLabel; + QGroupBox *userMaterialsGroup; + QPushButton* userMaterialClearButton; + QGroupBox *UserGroup() Q_REQUIRED_RESULT; QGroupBox *GraphOutputGroup() Q_REQUIRED_RESULT; QGroupBox *UndoGroup() Q_REQUIRED_RESULT; + QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT; void RetranslateUi(); }; diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index 69e597dfc..5e04e4baf 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -1139,8 +1139,11 @@ + + Use %size% and %height% to insert pattern size and height + - 30 + 40 diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 3fef25852..3c2d2612f 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1222,6 +1222,7 @@ void MainWindow::changeEvent(QEvent *event) helpLabel->setText(QObject::tr("Changes applied.")); patternPieceLabel->setText(tr("Pattern Piece:")); UpdateWindowTitle(); + emit sceneDetails->LanguageChanged(); } // remember to call base class implementation QMainWindow::changeEvent(event); @@ -2805,6 +2806,7 @@ void MainWindow::ChangedSize(const QString & text) if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), text.toInt(), static_cast(pattern->height()))) { doc->LiteParseTree(Document::LiteParse); + emit sceneDetails->DimensionsChanged(); } else { @@ -2833,6 +2835,7 @@ void MainWindow::ChangedHeight(const QString &text) if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), static_cast(pattern->size()), text.toInt())) { doc->LiteParseTree(Document::LiteParse); + emit sceneDetails->DimensionsChanged(); } else { diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index fab419219..c0dcf2379 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -470,7 +470,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *de { date = QDate::currentDate(); } - det.SetPatternInfo(pDoc, geom, qApp->font()); + det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height()); } det.setWidth(qApp->toPixel(d.getWidth())); det.CreateTextItems(); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 4dae1eac9..61b45100e 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -689,7 +689,10 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document MaterialCutPlacement mcp; QDomElement domMCP = nodeListMCP.at(iMCP).toElement(); mcp.m_eMaterial = MaterialType(GetParametrUInt(domMCP, AttrMaterial, 0)); - mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, ""); + if (mcp.m_eMaterial == MaterialType::mtUserDefined) + { + mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, ""); + } mcp.m_iCutNumber = GetParametrUInt(domMCP, AttrCutNumber, 0); mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0)); detail.GetPatternPieceData().Append(mcp); diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 5764f4246..fc4de3307 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -153,7 +153,8 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont &font) +void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont &font, + qreal dSize, qreal dHeight) { d->patternGeom = geom; qreal dAng = qDegreesToRadians(geom.GetRotation()); @@ -173,7 +174,7 @@ void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternI d->m_tmPattern.SetFont(font); d->m_tmPattern.SetFontSize(geom.GetFontSize()); - d->m_tmPattern.Update(pDoc); + d->m_tmPattern.Update(pDoc, dSize, dHeight); // generate lines of text d->m_tmPattern.SetFontSize(geom.GetFontSize()); d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight()); diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index 34b4e31e3..ef9cbd5cb 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -77,7 +77,8 @@ public: void SetDetail(const QString &qsName, const VPatternPieceData& data, const QFont& font); - void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font); + void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font, + qreal dSize, qreal dHeight); QTransform GetMatrix() const; void SetMatrix(const QTransform &matrix); diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 54d55da98..89695a8e2 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -1,8 +1,37 @@ +/************************************************************************ + ** + ** @file vpatternpiecedata.cpp + ** @author Bojan Kverh + ** @date July 19, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + #include #include #include #include #include +#include #include "../ifc/xml/vabstractpattern.h" #include "../vpatterndb/vpatternpiecedata.h" @@ -212,6 +241,11 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data) AddLine(tl); } // MCP + QStringList qslMaterials; + qslMaterials << QApplication::translate("Detail", "Fabric", 0) + << QApplication::translate("Detail", "Lining", 0) + << QApplication::translate("Detail", "Interfacing", 0) + << QApplication::translate("Detail", "Interlining", 0); QString qsText = tr("Cut %1 on %2%3"); QStringList qslPlace; qslPlace << "" << QLatin1String(" ") + tr("on Fold"); @@ -222,7 +256,16 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data) MaterialCutPlacement mcp = data.GetMCP(i); if (mcp.m_iCutNumber > 0) { - tl.m_qsText = qsText.arg(mcp.m_iCutNumber).arg(mcp.m_qsMaterialUserDef). + QString qsMat; + if (mcp.m_eMaterial == MaterialType::mtUserDefined) + { + qsMat = mcp.m_qsMaterialUserDef; + } + else + { + qsMat = qslMaterials[int(mcp.m_eMaterial)]; + } + tl.m_qsText = qsText.arg(mcp.m_iCutNumber).arg(qsMat). arg(qslPlace[int(mcp.m_ePlacement)]); AddLine(tl); } @@ -234,7 +277,7 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data) * @brief VTextManager::Update updates the text lines with pattern info * @param pDoc pointer to the abstract pattern object */ -void VTextManager::Update(const VAbstractPattern *pDoc) +void VTextManager::Update(const VAbstractPattern *pDoc, qreal dSize, qreal dHeight) { Clear(); TextLine tl; @@ -281,6 +324,8 @@ void VTextManager::Update(const VAbstractPattern *pDoc) tl.m_qsText = pDoc->GetPatternSize(); if (tl.m_qsText.isEmpty() == false) { + tl.m_qsText.replace(QApplication::translate("Detail", "%size%", 0), QString::number(dSize)); + tl.m_qsText.replace(QApplication::translate("Detail", "%height%", 0), QString::number(dHeight)); tl.m_eFontWeight = QFont::Normal; tl.m_eStyle = QFont::StyleNormal; tl.m_iFontSize = 0; diff --git a/src/libs/vlayout/vtextmanager.h b/src/libs/vlayout/vtextmanager.h index 773fd02ab..1e3d2bf77 100644 --- a/src/libs/vlayout/vtextmanager.h +++ b/src/libs/vlayout/vtextmanager.h @@ -1,3 +1,31 @@ +/************************************************************************ + ** + ** @file vpatternpiecedata.cpp + ** @author Bojan Kverh + ** @date July 19, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + #ifndef VTEXTMANAGER_H #define VTEXTMANAGER_H @@ -57,7 +85,7 @@ public: bool IsBigEnough(qreal fW, qreal fH, int iFontSize); void FitFontSize(qreal fW, qreal fH); void Update(const QString& qsName, const VPatternPieceData& data); - void Update(const VAbstractPattern* pDoc); + void Update(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight); protected: static QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm); diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 386ff236d..5d6e6818b 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -70,6 +70,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"); static const QString commonIniFilename = QStringLiteral("common"); @@ -464,3 +465,24 @@ void VCommonSettings::SetDateOfLastRemind(const QDate &date) settings.setValue(SettingDateOfLastRemind, date); settings.sync(); } + +//--------------------------------------------------------------------------------------------------------------------- +QStringList VCommonSettings::GetUserDefinedMaterials() const +{ + return value(SettingUserDefinedMaterials).toStringList(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommonSettings::AddUserDefinedMaterial(QString qsMaterial) +{ + QStringList qsl = GetUserDefinedMaterials(); + qsl << qsMaterial; + setValue(SettingUserDefinedMaterials, qsl); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommonSettings::ClearUserDefinedMaterial() +{ + QStringList qsl; + setValue(SettingUserDefinedMaterials, qsl); +} diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index b56f926bb..258879e66 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -118,6 +118,10 @@ public: QDate GetDateOfLastRemind() const; void SetDateOfLastRemind(const QDate &date); + QStringList GetUserDefinedMaterials() const; + void AddUserDefinedMaterial(QString qsMaterial); + void ClearUserDefinedMaterial(); + private: Q_DISABLE_COPY(VCommonSettings) @@ -146,6 +150,7 @@ private: static const QString SettingPreferenceDialogSize; static const QString SettingLatestSkippedVersion; static const QString SettingDateOfLastRemind; + static const QString SettingUserDefinedMaterials; }; #endif // VCOMMONSETTINGS_H diff --git a/src/libs/vmisc/vsettings.cpp b/src/libs/vmisc/vsettings.cpp index d7f39df48..a00f73bed 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/libs/vmisc/vsettings.cpp @@ -598,3 +598,4 @@ void VSettings::SetMultiplier(quint8 value) { setValue(SettingMultiplier, value); } + diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 76cb6beb5..4a95b77bc 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -124,9 +124,22 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge connect(ui.toolButtonUp, &QToolButton::clicked, this, &DialogDetail::ScrollUp); connect(ui.toolButtonDown, &QToolButton::clicked, this, &DialogDetail::ScrollDown); - m_qslMaterials << tr("Fabric") << tr("Lining") << tr("Interfacing") << tr("Interlining"); + m_qslMaterials << QApplication::translate("Detail", "Fabric", 0) + << QApplication::translate("Detail", "Lining", 0) + << QApplication::translate("Detail", "Interfacing", 0) + << QApplication::translate("Detail", "Interlining", 0); + + for (int i = 0; i < m_qslMaterials.count(); ++i) + { + ui.comboBoxMaterial->addItem(m_qslMaterials[i], i); + } + + QStringList qsl = qApp->Settings()->GetUserDefinedMaterials(); + for (int i = 0; i < qsl.count(); ++i) + { + ui.comboBoxMaterial->addItem(qsl[i], int(MaterialType::mtUserDefined)); + } - ui.comboBoxMaterial->addItems(m_qslMaterials); m_qslPlacements << tr("None") << tr("Cut on fold"); ui.comboBoxPlacement->addItems(m_qslPlacements); @@ -134,6 +147,7 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge connect(ui.pushButtonCancel, &QPushButton::clicked, this, &DialogDetail::Cancel); connect(ui.pushButtonRemove, &QPushButton::clicked, this, &DialogDetail::Remove); connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode); + connect(ui.comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogDetail::MaterialChanged); SetAddMode(); ui.tabWidget->setCurrentIndex(0); @@ -235,13 +249,33 @@ void DialogDetail::UpdateList() void DialogDetail::AddUpdate() { MaterialCutPlacement mcp; - mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText(); - mcp.m_eMaterial = MaterialType::mtUserDefined; - for (int i = 0; i < m_qslMaterials.count(); ++i) + QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials(); + + int i = ui.comboBoxMaterial->currentData().toInt(); + QString qsMat = ui.comboBoxMaterial->currentText(); + if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i]) { - if (mcp.m_qsMaterialUserDef == m_qslMaterials[i]) + mcp.m_eMaterial = MaterialType(i); + mcp.m_qsMaterialUserDef.clear(); + } + else + { + mcp.m_eMaterial = MaterialType::mtUserDefined; + mcp.m_qsMaterialUserDef = qsMat; + // check if we have new user defined material + bool bFound = false; + for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i) { - mcp.m_eMaterial = MaterialType(i); + if (mcp.m_qsMaterialUserDef == qslUserMaterials[i]) + { + bFound = true; + } + } + if (bFound == false) + { + qApp->Settings()->AddUserDefinedMaterial(mcp.m_qsMaterialUserDef); + qApp->Settings()->sync(); + ui.comboBoxMaterial->addItem(mcp.m_qsMaterialUserDef, int(MaterialType::mtUserDefined)); } } @@ -306,6 +340,12 @@ void DialogDetail::NameDetailChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::MaterialChanged() +{ + ui.pushButtonAdd->setEnabled(ui.comboBoxMaterial->currentText().isEmpty() == false); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief NewItem add new object (point, arc, spline or spline path) to list @@ -413,8 +453,6 @@ VDetail DialogDetail::CreateDetail() const detail.GetPatternPieceData().SetRotation(m_oldData.GetRotation()); detail.GetPatternPieceData().SetVisible(ui.checkBoxDetail->isChecked()); - qDebug() << "DD VISIBLE" << detail.GetPatternPieceData().IsVisible(); - detail.GetPatternInfo() = m_oldGeom; detail.GetPatternInfo().SetVisible(ui.checkBoxPattern->isChecked()); @@ -780,7 +818,22 @@ void DialogDetail::SetEditMode() ui.pushButtonRemove->show(); MaterialCutPlacement mcp = m_conMCP.at(iR); - ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef); + if (mcp.m_eMaterial == MaterialType::mtUserDefined) + { + int iRow = qApp->Settings()->GetUserDefinedMaterials().indexOf(mcp.m_qsMaterialUserDef); + if (iRow >= 0) + { + ui.comboBoxMaterial->setCurrentIndex(iRow + m_qslMaterials.count()); + } + else + { + ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef); + } + } + else + { + ui.comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial)); + } ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber); ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement)); diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.h b/src/libs/vtools/dialogs/tools/dialogdetail.h index 69a3928af..26dbe48a0 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.h +++ b/src/libs/vtools/dialogs/tools/dialogdetail.h @@ -84,6 +84,7 @@ protected slots: private slots: void NameDetailChanged(); + void MaterialChanged(); private: /** @brief ui keeps information about user interface */ diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.ui b/src/libs/vtools/dialogs/tools/dialogdetail.ui index be52c4dde..ea9d9a4b2 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.ui +++ b/src/libs/vtools/dialogs/tools/dialogdetail.ui @@ -305,7 +305,8 @@ - .. + + @@ -319,7 +320,8 @@ - .. + + @@ -419,6 +421,9 @@ + + You can choose one of the predefined materials or enter a new one + true diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index 64107936b..7a491b4e6 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -229,6 +229,23 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH) return; } + if (fW > parentItem()->boundingRect().width()) + { + fW = parentItem()->boundingRect().width(); + } + if (fW < MIN_W) + { + fW = MIN_W; + } + if (fH > parentItem()->boundingRect().height()) + { + fH = parentItem()->boundingRect().height(); + } + if (fH < m_iMinH) + { + fH = m_iMinH; + } + m_rectBoundingBox.setTopLeft(QPointF(0, 0)); m_rectBoundingBox.setWidth(fW); m_rectBoundingBox.setHeight(fH); @@ -308,9 +325,9 @@ void VTextGraphicsItem::UpdateData(const QString &qsName, const VPatternPieceDat * @brief VTextGraphicsItem::UpdateData Updates the pattern label * @param pDoc pointer to the pattern object */ -void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc) +void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight) { - m_tm.Update(pDoc); + m_tm.Update(pDoc, dSize, dHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vtextgraphicsitem.h b/src/libs/vtools/tools/vtextgraphicsitem.h index b6f0ba59a..fdd451820 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.h +++ b/src/libs/vtools/tools/vtextgraphicsitem.h @@ -88,7 +88,7 @@ public: void Update(); bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const; void UpdateData(const QString& qsName, const VPatternPieceData& data); - void UpdateData(const VAbstractPattern* pDoc); + void UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight); int GetTextLines() const; protected: diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index a1bc33916..2b5e4f35e 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -205,6 +205,11 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdatePatternInfo); + + connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdateLabel); + connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdatePatternInfo); + connect(sceneDetails, &VMainGraphicsScene::LanguageChanged, this, &VToolDetail::retranslateUi); + UpdateLabel(); UpdatePatternInfo(); } @@ -443,7 +448,14 @@ void VToolDetail::AddToFile() MaterialCutPlacement mcp = data.GetMCP(i); QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP); doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); - doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); + if (mcp.m_eMaterial == MaterialType::mtUserDefined) + { + doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); + } + else + { + domMCP.removeAttribute(VAbstractPattern::AttrUserDefined); + } doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); domData.appendChild(domMCP); @@ -502,7 +514,14 @@ void VToolDetail::RefreshDataInFile() MaterialCutPlacement mcp = data.GetMCP(i); QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP); doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); - doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); + if (mcp.m_eMaterial == MaterialType::mtUserDefined) + { + doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); + } + else + { + domMCP.removeAttribute(VAbstractPattern::AttrUserDefined); + } doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); domData.appendChild(domMCP); @@ -763,8 +782,8 @@ void VToolDetail::UpdateLabel() QPointF pt = data.GetPos(); QRectF rectBB; rectBB.setTopLeft(pt); - rectBB.setWidth(data.GetLabelWidth()); - rectBB.setHeight(data.GetLabelHeight()); + rectBB.setWidth(dataLabel->boundingRect().width()); + rectBB.setHeight(dataLabel->boundingRect().height()); qreal dX; qreal dY; if (dataLabel->IsContained(rectBB, data.GetRotation(), dX, dY) == false) @@ -804,13 +823,13 @@ void VToolDetail::UpdatePatternInfo() fnt.setPixelSize(iFS); patternInfo->SetFont(fnt); patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight()); - patternInfo->UpdateData(doc); + patternInfo->UpdateData(doc, getData()->size(), getData()->height()); QPointF pt = geom.GetPos(); QRectF rectBB; rectBB.setTopLeft(pt); - rectBB.setWidth(geom.GetLabelWidth()); - rectBB.setHeight(geom.GetLabelHeight()); + rectBB.setWidth(patternInfo->boundingRect().width()); + rectBB.setHeight(patternInfo->boundingRect().height()); qreal dX; qreal dY; if (patternInfo->IsContained(rectBB, geom.GetRotation(), dX, dY) == false) @@ -1122,3 +1141,10 @@ void VToolDetail::UpdateAll() sceneDetails->update(); update(); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::retranslateUi() +{ + UpdateLabel(); + UpdatePatternInfo(); +} diff --git a/src/libs/vtools/tools/vtooldetail.h b/src/libs/vtools/tools/vtooldetail.h index 9e69f77d1..250129deb 100644 --- a/src/libs/vtools/tools/vtooldetail.h +++ b/src/libs/vtools/tools/vtooldetail.h @@ -99,6 +99,7 @@ public slots: virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; virtual void ResetChildren(QGraphicsItem* pItem); virtual void UpdateAll(); + virtual void retranslateUi(); protected: virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index 51fabd490..e16d4c107 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -161,7 +161,16 @@ void SaveDetailOptions::SavePatternPieceData(QDomElement &domElement, const VDet MaterialCutPlacement mcp = data.GetMCP(i); QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP); doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); - doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); + if (mcp.m_eMaterial == MaterialType::mtUserDefined) + { + qDebug() << "USER DEFINED MATERIAL"; + doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); + } + else + { + qDebug() << "PREDEFINED MATERIAL"; + domMCP.removeAttribute(VAbstractPattern::AttrUserDefined); + } doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); domData.appendChild(domMCP); diff --git a/src/libs/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index a81172270..e9d7c1822 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -146,6 +146,9 @@ signals: void EnableNodePointItemHover(bool enabled); void EnableDetailItemHover(bool enabled); void EnableLineItemHover(bool enabled); + void DimensionsChanged(); + void LanguageChanged(); + private: /** @brief horScrollBar value horizontal scroll bar. */ qint32 horScrollBar;