From b0532e6fb9d3e1b298b6eef78bbb15566a9555b4 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Thu, 11 Aug 2016 22:44:53 +0200 Subject: [PATCH 2/9] Removed userDef attributes from DOM tree, where they are not necessary. Fixed some translations. Refactored finding the selected material in detail dialog --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 9 ++++- src/libs/vlayout/vtextmanager.cpp | 17 ++++++++- .../vtools/dialogs/tools/dialogdetail.cpp | 35 +++++++++++++------ src/libs/vtools/tools/vtooldetail.cpp | 10 ++++-- .../vtools/undocommands/savedetailoptions.cpp | 5 ++- 5 files changed, 60 insertions(+), 16 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index fcf070350..5a78232f6 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -689,7 +689,14 @@ 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, ""); + } + else + { + mcp.m_qsMaterialUserDef.clear(); + } 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/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 54d55da98..2a66e4145 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../ifc/xml/vabstractpattern.h" #include "../vpatterndb/vpatternpiecedata.h" @@ -212,6 +213,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 +228,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); } diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index bd0f93a95..d990ba734 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -125,9 +125,16 @@ 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); - ui.comboBoxMaterial->addItems(m_qslMaterials); + //ui.comboBoxMaterial->addItems(m_qslMaterials); + for (int i = 0; i < m_qslMaterials.count(); ++i) + { + ui.comboBoxMaterial->addItem(m_qslMaterials[i], i); + } m_qslPlacements << tr("None") << tr("Cut on fold"); ui.comboBoxPlacement->addItems(m_qslPlacements); @@ -237,13 +244,14 @@ 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) + int i = ui.comboBoxMaterial->currentData().toInt(); + if (mcp.m_qsMaterialUserDef == m_qslMaterials[i]) { - if (mcp.m_qsMaterialUserDef == m_qslMaterials[i]) - { - mcp.m_eMaterial = MaterialType(i); - } + mcp.m_eMaterial = MaterialType(i); + } + else + { + mcp.m_eMaterial = MaterialType::mtUserDefined; } mcp.m_iCutNumber = ui.spinBoxCutNumber->value(); @@ -414,8 +422,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()); @@ -781,7 +787,14 @@ void DialogDetail::SetEditMode() ui.pushButtonRemove->show(); MaterialCutPlacement mcp = m_conMCP.at(iR); - ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef); + if (mcp.m_eMaterial == MaterialType::mtUserDefined) + { + ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef); + } + else + { + ui.comboBoxMaterial->setCurrentText(m_qslMaterials[int(mcp.m_eMaterial)]); + } ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber); ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement)); diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index e725e13fc..59807146d 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -444,7 +444,10 @@ 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); + } doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); domData.appendChild(domMCP); @@ -503,7 +506,10 @@ 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); + } 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/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index 51fabd490..fc4d76c6e 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -161,7 +161,10 @@ 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) + { + doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); + } doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); domData.appendChild(domMCP); From 86f24bf0e5bf8a1a4473786952787bf9d78cce04 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Fri, 12 Aug 2016 01:22:23 +0200 Subject: [PATCH 3/9] User defined materials are now remembered and can also be deleted in preferences dialog --HG-- branch : feature --- .../dialogs/configpages/configurationpage.cpp | 32 ++++++++++++- .../dialogs/configpages/configurationpage.h | 6 +++ src/libs/vmisc/vcommonsettings.cpp | 22 +++++++++ src/libs/vmisc/vcommonsettings.h | 5 ++ src/libs/vmisc/vsettings.cpp | 1 + .../vtools/dialogs/tools/dialogdetail.cpp | 46 +++++++++++++++++-- src/libs/vtools/dialogs/tools/dialogdetail.h | 1 + 7 files changed, 109 insertions(+), 4 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/configurationpage.cpp b/src/app/valentina/dialogs/configpages/configurationpage.cpp index 528406837..b563632cc 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) @@ -77,7 +78,9 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) sendGroup(nullptr), description(nullptr), drawGroup(nullptr), - toolBarGroup(nullptr) + toolBarGroup(nullptr), + userMaterialsGroup(nullptr), + userMaterialClearButton(nullptr) { QGroupBox *saveGroup = SaveGroup(); QGroupBox *langGroup = LangGroup(); @@ -85,6 +88,7 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) QGroupBox *sendGroup = SendGroup(); QGroupBox *drawGroup = DrawGroup(); QGroupBox *toolBarGroup = ToolBarGroup(); + QGroupBox *userMatGroup = UserMaterialGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(saveGroup); @@ -93,6 +97,7 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) mainLayout->addWidget(sendGroup); mainLayout->addWidget(drawGroup); mainLayout->addWidget(toolBarGroup); + mainLayout->addWidget(userMatGroup); mainLayout->addStretch(1); setLayout(mainLayout); } @@ -161,6 +166,16 @@ void ConfigurationPage::LabelLangChanged() labelLangChanged = true; } +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::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); +} + //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::SaveGroup() { @@ -381,6 +396,21 @@ QGroupBox *ConfigurationPage::ToolBarGroup() return toolBarGroup; } +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::UserMaterialGroup() +{ + userMaterialsGroup = new QGroupBox(tr("User defined materials")); + userMaterialClearButton = new QPushButton(tr("Delete all")); + connect(userMaterialClearButton, &QPushButton::clicked, this, &ConfigurationPage::ClearUserDefinedMaterials); + + QHBoxLayout* pLayout = new QHBoxLayout; + pLayout->addWidget(userMaterialClearButton); + pLayout->addStretch(1); + + userMaterialsGroup->setLayout(pLayout); + return userMaterialsGroup; +} + //--------------------------------------------------------------------------------------------------------------------- void ConfigurationPage::SystemChanged() { diff --git a/src/app/valentina/dialogs/configpages/configurationpage.h b/src/app/valentina/dialogs/configpages/configurationpage.h index fa3167a8e..86ec00faa 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.h +++ b/src/app/valentina/dialogs/configpages/configurationpage.h @@ -38,6 +38,7 @@ class QSpinBox; class QComboBox; class QGroupBox; class QLabel; +class QPushButton; class ConfigurationPage : public QWidget { @@ -50,6 +51,7 @@ public slots: void SystemChanged(); void UnitChanged(); void LabelLangChanged(); + void ClearUserDefinedMaterials(); protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private: @@ -90,12 +92,16 @@ private: QGroupBox *drawGroup; QGroupBox *toolBarGroup; + QGroupBox *userMaterialsGroup; + QPushButton* userMaterialClearButton; + QGroupBox *SaveGroup() Q_REQUIRED_RESULT; QGroupBox *LangGroup() Q_REQUIRED_RESULT; QGroupBox *PMSystemGroup() Q_REQUIRED_RESULT; QGroupBox *SendGroup() Q_REQUIRED_RESULT; QGroupBox *DrawGroup() Q_REQUIRED_RESULT; QGroupBox *ToolBarGroup() Q_REQUIRED_RESULT; + QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT; void SetLabelComboBox(const QStringList &list); void RetranslateUi(); diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 97ddf645c..253ac8723 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -75,6 +75,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"); @@ -469,3 +470,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 7de98c245..3075605a6 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/libs/vmisc/vsettings.cpp @@ -602,3 +602,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 d990ba734..da8b9e7c4 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -135,6 +135,13 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge { 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)); + } + m_qslPlacements << tr("None") << tr("Cut on fold"); ui.comboBoxPlacement->addItems(m_qslPlacements); @@ -142,6 +149,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); @@ -243,15 +251,32 @@ void DialogDetail::UpdateList() void DialogDetail::AddUpdate() { MaterialCutPlacement mcp; + QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials(); + mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText(); int i = ui.comboBoxMaterial->currentData().toInt(); - if (mcp.m_qsMaterialUserDef == m_qslMaterials[i]) + if (i < m_qslMaterials.count() && mcp.m_qsMaterialUserDef == m_qslMaterials[i]) { mcp.m_eMaterial = MaterialType(i); } else { mcp.m_eMaterial = MaterialType::mtUserDefined; + // check if we have new user defined material + bool bFound = false; + for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++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)); + } } mcp.m_iCutNumber = ui.spinBoxCutNumber->value(); @@ -315,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 @@ -789,11 +820,20 @@ void DialogDetail::SetEditMode() MaterialCutPlacement mcp = m_conMCP.at(iR); if (mcp.m_eMaterial == MaterialType::mtUserDefined) { - ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef); + 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->setCurrentText(m_qslMaterials[int(mcp.m_eMaterial)]); + //ui.comboBoxMaterial->setCurrentText(m_qslMaterials[int(mcp.m_eMaterial)]); + 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 */ From 8fc3cfae1bbb267456d04ff76f4d2822a00b2509 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Fri, 12 Aug 2016 12:11:12 +0200 Subject: [PATCH 4/9] Added missing headers --HG-- branch : feature --- src/libs/vlayout/vtextmanager.cpp | 28 ++++++++++++++++++++++++++++ src/libs/vlayout/vtextmanager.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 2a66e4145..eddab3b87 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -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 . + ** + *************************************************************************/ + #include #include #include diff --git a/src/libs/vlayout/vtextmanager.h b/src/libs/vlayout/vtextmanager.h index 773fd02ab..7e9f78bd3 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 From fb326d4f393390b1849b3e4fe8496dada7683f5e Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Mon, 15 Aug 2016 13:03:59 +0200 Subject: [PATCH 5/9] Added %size% and %height% placeholders to display pattern size and height in the Pattern size line edit --HG-- branch : feature --- .../dialogs/configpages/configurationpage.cpp | 31 +---------------- .../dialogs/configpages/configurationpage.h | 6 ---- .../dialogs/configpages/patternpage.cpp | 33 ++++++++++++++++++- .../dialogs/configpages/patternpage.h | 7 ++++ .../dialogs/dialogpatternproperties.ui | 5 ++- src/app/valentina/mainwindowsnogui.cpp | 2 +- src/libs/vlayout/vlayoutdetail.cpp | 5 +-- src/libs/vlayout/vlayoutdetail.h | 3 +- src/libs/vlayout/vtextmanager.cpp | 4 ++- src/libs/vlayout/vtextmanager.h | 2 +- src/libs/vtools/tools/vtextgraphicsitem.cpp | 4 +-- src/libs/vtools/tools/vtextgraphicsitem.h | 2 +- src/libs/vtools/tools/vtooldetail.cpp | 2 +- 13 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/configurationpage.cpp b/src/app/valentina/dialogs/configpages/configurationpage.cpp index c39964e6f..f13c5d96b 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/configurationpage.cpp @@ -78,9 +78,7 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) sendGroup(nullptr), description(nullptr), drawGroup(nullptr), - toolBarGroup(nullptr), - userMaterialsGroup(nullptr), - userMaterialClearButton(nullptr) + toolBarGroup(nullptr) { QGroupBox *saveGroup = SaveGroup(); QGroupBox *langGroup = LangGroup(); @@ -88,7 +86,6 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) QGroupBox *sendGroup = SendGroup(); QGroupBox *drawGroup = DrawGroup(); QGroupBox *toolBarGroup = ToolBarGroup(); - QGroupBox *userMatGroup = UserMaterialGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(saveGroup); @@ -97,7 +94,6 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) mainLayout->addWidget(sendGroup); mainLayout->addWidget(drawGroup); mainLayout->addWidget(toolBarGroup); - mainLayout->addWidget(userMatGroup); mainLayout->addStretch(1); setLayout(mainLayout); } @@ -166,16 +162,6 @@ void ConfigurationPage::LabelLangChanged() labelLangChanged = true; } -//--------------------------------------------------------------------------------------------------------------------- -void ConfigurationPage::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); -} - //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::SaveGroup() { @@ -396,21 +382,6 @@ QGroupBox *ConfigurationPage::ToolBarGroup() return toolBarGroup; } -//--------------------------------------------------------------------------------------------------------------------- -QGroupBox *ConfigurationPage::UserMaterialGroup() -{ - userMaterialsGroup = new QGroupBox(tr("User defined materials")); - userMaterialClearButton = new QPushButton(tr("Delete all")); - connect(userMaterialClearButton, &QPushButton::clicked, this, &ConfigurationPage::ClearUserDefinedMaterials); - - QHBoxLayout* pLayout = new QHBoxLayout; - pLayout->addWidget(userMaterialClearButton); - pLayout->addStretch(1); - - userMaterialsGroup->setLayout(pLayout); - return userMaterialsGroup; -} - //--------------------------------------------------------------------------------------------------------------------- void ConfigurationPage::SystemChanged() { diff --git a/src/app/valentina/dialogs/configpages/configurationpage.h b/src/app/valentina/dialogs/configpages/configurationpage.h index 86ec00faa..fa3167a8e 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.h +++ b/src/app/valentina/dialogs/configpages/configurationpage.h @@ -38,7 +38,6 @@ class QSpinBox; class QComboBox; class QGroupBox; class QLabel; -class QPushButton; class ConfigurationPage : public QWidget { @@ -51,7 +50,6 @@ public slots: void SystemChanged(); void UnitChanged(); void LabelLangChanged(); - void ClearUserDefinedMaterials(); protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private: @@ -92,16 +90,12 @@ private: QGroupBox *drawGroup; QGroupBox *toolBarGroup; - QGroupBox *userMaterialsGroup; - QPushButton* userMaterialClearButton; - QGroupBox *SaveGroup() Q_REQUIRED_RESULT; QGroupBox *LangGroup() Q_REQUIRED_RESULT; QGroupBox *PMSystemGroup() Q_REQUIRED_RESULT; QGroupBox *SendGroup() Q_REQUIRED_RESULT; QGroupBox *DrawGroup() Q_REQUIRED_RESULT; QGroupBox *ToolBarGroup() Q_REQUIRED_RESULT; - QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT; void SetLabelComboBox(const QStringList &list); void RetranslateUi(); 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..147d5022f 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -1139,8 +1139,11 @@ + + Use %width% and %height% to insert pattern width and height + - 30 + 40 diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 6db890d61..9b43b1f71 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -486,7 +486,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/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 17ef791b7..62e300bed 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -161,7 +161,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()); @@ -181,7 +182,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 eddab3b87..89695a8e2 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -277,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; @@ -324,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 7e9f78bd3..1e3d2bf77 100644 --- a/src/libs/vlayout/vtextmanager.h +++ b/src/libs/vlayout/vtextmanager.h @@ -85,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/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index 5fd5e2a41..54b9c6566 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -309,9 +309,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 59807146d..8e3d23882 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -811,7 +811,7 @@ 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; From 92ec78e6b35817a422b58a2e6838d64037f54eae Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Mon, 15 Aug 2016 17:19:21 +0200 Subject: [PATCH 6/9] Made sure that labels stay inside the detail after changing size or height --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 2 ++ src/libs/vtools/tools/vtextgraphicsitem.cpp | 17 +++++++++++++++++ src/libs/vtools/tools/vtooldetail.cpp | 12 ++++++++---- src/libs/vwidgets/vmaingraphicsscene.h | 2 ++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 3eab696c4..dda3a33a3 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2805,6 +2805,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 +2834,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/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index 54b9c6566..75d3b8b01 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -230,6 +230,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); diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 8e3d23882..fc31d3272 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -206,6 +206,10 @@ 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); + UpdateLabel(); UpdatePatternInfo(); } @@ -770,8 +774,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) @@ -816,8 +820,8 @@ void VToolDetail::UpdatePatternInfo() 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) diff --git a/src/libs/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index a81172270..320604be6 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -146,6 +146,8 @@ signals: void EnableNodePointItemHover(bool enabled); void EnableDetailItemHover(bool enabled); void EnableLineItemHover(bool enabled); + void DimensionsChanged(); + private: /** @brief horScrollBar value horizontal scroll bar. */ qint32 horScrollBar; From 1cfa97497c2adc5da39721e7ec6d293990829d2f Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Wed, 17 Aug 2016 21:38:39 +0200 Subject: [PATCH 7/9] Fixed translations after language change --HG-- branch : feature --- src/app/valentina/dialogs/dialogpatternproperties.ui | 2 +- src/app/valentina/mainwindow.cpp | 1 + src/libs/vtools/dialogs/tools/dialogdetail.ui | 9 +++++++-- src/libs/vtools/tools/vtooldetail.cpp | 8 ++++++++ src/libs/vtools/tools/vtooldetail.h | 1 + src/libs/vwidgets/vmaingraphicsscene.h | 1 + 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index 147d5022f..5e04e4baf 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -1140,7 +1140,7 @@ - Use %width% and %height% to insert pattern width and height + Use %size% and %height% to insert pattern size and height 40 diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 227e49c6a..710a8e2e8 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); 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/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 92d3e8328..8377ea9f2 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -208,6 +208,7 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdateLabel); connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdatePatternInfo); + connect(sceneDetails, &VMainGraphicsScene::LanguageChanged, this, &VToolDetail::retranslateUi); UpdateLabel(); UpdatePatternInfo(); @@ -1132,3 +1133,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/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index 320604be6..e9d7c1822 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -147,6 +147,7 @@ signals: void EnableDetailItemHover(bool enabled); void EnableLineItemHover(bool enabled); void DimensionsChanged(); + void LanguageChanged(); private: /** @brief horScrollBar value horizontal scroll bar. */ From ff6d3c7155f31546d218ef221fa0fc81598d2407 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 21 Aug 2016 10:27:39 +0200 Subject: [PATCH 8/9] Fixed user defined materials --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 4 ---- src/libs/vtools/dialogs/tools/dialogdetail.cpp | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index dae100813..61b45100e 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -693,10 +693,6 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document { mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, ""); } - else - { - mcp.m_qsMaterialUserDef.clear(); - } mcp.m_iCutNumber = GetParametrUInt(domMCP, AttrCutNumber, 0); mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0)); detail.GetPatternPieceData().Append(mcp); diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index fc53e805e..8d16da5f4 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -252,15 +252,16 @@ void DialogDetail::AddUpdate() MaterialCutPlacement mcp; QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials(); - mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText(); int i = ui.comboBoxMaterial->currentData().toInt(); if (i < m_qslMaterials.count() && mcp.m_qsMaterialUserDef == m_qslMaterials[i]) { mcp.m_eMaterial = MaterialType(i); + mcp.m_qsMaterialUserDef.clear(); } else { mcp.m_eMaterial = MaterialType::mtUserDefined; + mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText(); // check if we have new user defined material bool bFound = false; for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i) From b4ced822e0a2cbfab98b71c5b716d55d4b75f1a2 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 21 Aug 2016 11:48:51 +0200 Subject: [PATCH 9/9] Fixed material attribute writing to XML and removed commented out lines --HG-- branch : feature --- src/libs/vtools/dialogs/tools/dialogdetail.cpp | 7 +++---- src/libs/vtools/tools/vtooldetail.cpp | 8 ++++++++ src/libs/vtools/undocommands/savedetailoptions.cpp | 6 ++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 8d16da5f4..4a95b77bc 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -129,7 +129,6 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge << QApplication::translate("Detail", "Interfacing", 0) << QApplication::translate("Detail", "Interlining", 0); - //ui.comboBoxMaterial->addItems(m_qslMaterials); for (int i = 0; i < m_qslMaterials.count(); ++i) { ui.comboBoxMaterial->addItem(m_qslMaterials[i], i); @@ -253,7 +252,8 @@ void DialogDetail::AddUpdate() QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials(); int i = ui.comboBoxMaterial->currentData().toInt(); - if (i < m_qslMaterials.count() && mcp.m_qsMaterialUserDef == m_qslMaterials[i]) + QString qsMat = ui.comboBoxMaterial->currentText(); + if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i]) { mcp.m_eMaterial = MaterialType(i); mcp.m_qsMaterialUserDef.clear(); @@ -261,7 +261,7 @@ void DialogDetail::AddUpdate() else { mcp.m_eMaterial = MaterialType::mtUserDefined; - mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText(); + 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) @@ -832,7 +832,6 @@ void DialogDetail::SetEditMode() } else { - //ui.comboBoxMaterial->setCurrentText(m_qslMaterials[int(mcp.m_eMaterial)]); ui.comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial)); } ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber); diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 8377ea9f2..2b5e4f35e 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -452,6 +452,10 @@ void VToolDetail::AddToFile() { 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); @@ -514,6 +518,10 @@ void VToolDetail::RefreshDataInFile() { 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); diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index fc4d76c6e..e16d4c107 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -163,8 +163,14 @@ void SaveDetailOptions::SavePatternPieceData(QDomElement &domElement, const VDet doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); 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);