From fb326d4f393390b1849b3e4fe8496dada7683f5e Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Mon, 15 Aug 2016 13:03:59 +0200 Subject: [PATCH] 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;