Added %size% and %height% placeholders to display pattern size and height in the Pattern size line edit

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-08-15 13:03:59 +02:00
parent 37b683f125
commit fb326d4f39
13 changed files with 58 additions and 48 deletions

View File

@ -78,9 +78,7 @@ ConfigurationPage::ConfigurationPage(QWidget *parent)
sendGroup(nullptr), sendGroup(nullptr),
description(nullptr), description(nullptr),
drawGroup(nullptr), drawGroup(nullptr),
toolBarGroup(nullptr), toolBarGroup(nullptr)
userMaterialsGroup(nullptr),
userMaterialClearButton(nullptr)
{ {
QGroupBox *saveGroup = SaveGroup(); QGroupBox *saveGroup = SaveGroup();
QGroupBox *langGroup = LangGroup(); QGroupBox *langGroup = LangGroup();
@ -88,7 +86,6 @@ ConfigurationPage::ConfigurationPage(QWidget *parent)
QGroupBox *sendGroup = SendGroup(); QGroupBox *sendGroup = SendGroup();
QGroupBox *drawGroup = DrawGroup(); QGroupBox *drawGroup = DrawGroup();
QGroupBox *toolBarGroup = ToolBarGroup(); QGroupBox *toolBarGroup = ToolBarGroup();
QGroupBox *userMatGroup = UserMaterialGroup();
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(saveGroup); mainLayout->addWidget(saveGroup);
@ -97,7 +94,6 @@ ConfigurationPage::ConfigurationPage(QWidget *parent)
mainLayout->addWidget(sendGroup); mainLayout->addWidget(sendGroup);
mainLayout->addWidget(drawGroup); mainLayout->addWidget(drawGroup);
mainLayout->addWidget(toolBarGroup); mainLayout->addWidget(toolBarGroup);
mainLayout->addWidget(userMatGroup);
mainLayout->addStretch(1); mainLayout->addStretch(1);
setLayout(mainLayout); setLayout(mainLayout);
} }
@ -166,16 +162,6 @@ void ConfigurationPage::LabelLangChanged()
labelLangChanged = true; 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() QGroupBox *ConfigurationPage::SaveGroup()
{ {
@ -396,21 +382,6 @@ QGroupBox *ConfigurationPage::ToolBarGroup()
return 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() void ConfigurationPage::SystemChanged()
{ {

View File

@ -38,7 +38,6 @@ class QSpinBox;
class QComboBox; class QComboBox;
class QGroupBox; class QGroupBox;
class QLabel; class QLabel;
class QPushButton;
class ConfigurationPage : public QWidget class ConfigurationPage : public QWidget
{ {
@ -51,7 +50,6 @@ public slots:
void SystemChanged(); void SystemChanged();
void UnitChanged(); void UnitChanged();
void LabelLangChanged(); void LabelLangChanged();
void ClearUserDefinedMaterials();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private: private:
@ -92,16 +90,12 @@ private:
QGroupBox *drawGroup; QGroupBox *drawGroup;
QGroupBox *toolBarGroup; QGroupBox *toolBarGroup;
QGroupBox *userMaterialsGroup;
QPushButton* userMaterialClearButton;
QGroupBox *SaveGroup() Q_REQUIRED_RESULT; QGroupBox *SaveGroup() Q_REQUIRED_RESULT;
QGroupBox *LangGroup() Q_REQUIRED_RESULT; QGroupBox *LangGroup() Q_REQUIRED_RESULT;
QGroupBox *PMSystemGroup() Q_REQUIRED_RESULT; QGroupBox *PMSystemGroup() Q_REQUIRED_RESULT;
QGroupBox *SendGroup() Q_REQUIRED_RESULT; QGroupBox *SendGroup() Q_REQUIRED_RESULT;
QGroupBox *DrawGroup() Q_REQUIRED_RESULT; QGroupBox *DrawGroup() Q_REQUIRED_RESULT;
QGroupBox *ToolBarGroup() Q_REQUIRED_RESULT; QGroupBox *ToolBarGroup() Q_REQUIRED_RESULT;
QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT;
void SetLabelComboBox(const QStringList &list); void SetLabelComboBox(const QStringList &list);
void RetranslateUi(); void RetranslateUi();

View File

@ -39,6 +39,8 @@
#include <QLineEdit> #include <QLineEdit>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QFormLayout> #include <QFormLayout>
#include <QMessageBox>
#include <QPushButton>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PatternPage::PatternPage(QWidget *parent): PatternPage::PatternPage(QWidget *parent):
@ -50,16 +52,20 @@ PatternPage::PatternPage(QWidget *parent):
graphOutputCheck(nullptr), graphOutputCheck(nullptr),
undoGroup(nullptr), undoGroup(nullptr),
undoCount(nullptr), undoCount(nullptr),
countStepsLabel(nullptr) countStepsLabel(nullptr),
userMaterialsGroup(nullptr),
userMaterialClearButton(nullptr)
{ {
QGroupBox *userGroup = UserGroup(); QGroupBox *userGroup = UserGroup();
QGroupBox *graphOutputGroup = GraphOutputGroup(); QGroupBox *graphOutputGroup = GraphOutputGroup();
QGroupBox *undoGroup = UndoGroup(); QGroupBox *undoGroup = UndoGroup();
QGroupBox *userMatGroup = UserMaterialGroup();
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(userGroup); mainLayout->addWidget(userGroup);
mainLayout->addWidget(graphOutputGroup); mainLayout->addWidget(graphOutputGroup);
mainLayout->addWidget(undoGroup); mainLayout->addWidget(undoGroup);
mainLayout->addWidget(userMatGroup);
mainLayout->addStretch(1); mainLayout->addStretch(1);
setLayout(mainLayout); setLayout(mainLayout);
} }
@ -81,6 +87,16 @@ void PatternPage::Apply()
settings->SetUndoCount(undoCount->value()); 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) void PatternPage::changeEvent(QEvent *event)
{ {
@ -152,6 +168,21 @@ QGroupBox *PatternPage::UndoGroup()
return 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() void PatternPage::RetranslateUi()
{ {

View File

@ -37,6 +37,7 @@ class QSpinBox;
class QGroupBox; class QGroupBox;
class QLineEdit; class QLineEdit;
class QLabel; class QLabel;
class QPushButton;
class PatternPage : public QWidget class PatternPage : public QWidget
{ {
@ -44,6 +45,8 @@ class PatternPage : public QWidget
public: public:
explicit PatternPage(QWidget *parent = nullptr); explicit PatternPage(QWidget *parent = nullptr);
void Apply(); void Apply();
public slots:
void ClearUserDefinedMaterials();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private: private:
@ -56,9 +59,13 @@ private:
QGroupBox *undoGroup; QGroupBox *undoGroup;
QSpinBox *undoCount; QSpinBox *undoCount;
QLabel *countStepsLabel; QLabel *countStepsLabel;
QGroupBox *userMaterialsGroup;
QPushButton* userMaterialClearButton;
QGroupBox *UserGroup() Q_REQUIRED_RESULT; QGroupBox *UserGroup() Q_REQUIRED_RESULT;
QGroupBox *GraphOutputGroup() Q_REQUIRED_RESULT; QGroupBox *GraphOutputGroup() Q_REQUIRED_RESULT;
QGroupBox *UndoGroup() Q_REQUIRED_RESULT; QGroupBox *UndoGroup() Q_REQUIRED_RESULT;
QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT;
void RetranslateUi(); void RetranslateUi();
}; };

View File

@ -1139,8 +1139,11 @@
</item> </item>
<item row="6" column="1"> <item row="6" column="1">
<widget class="QLineEdit" name="lineEditSize"> <widget class="QLineEdit" name="lineEditSize">
<property name="toolTip">
<string>Use %width% and %height% to insert pattern width and height</string>
</property>
<property name="maxLength"> <property name="maxLength">
<number>30</number> <number>40</number>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -486,7 +486,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
{ {
date = QDate::currentDate(); 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.setWidth(qApp->toPixel(d.getWidth()));
det.CreateTextItems(); det.CreateTextItems();

View File

@ -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; d->patternGeom = geom;
qreal dAng = qDegreesToRadians(geom.GetRotation()); 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.SetFont(font);
d->m_tmPattern.SetFontSize(geom.GetFontSize()); d->m_tmPattern.SetFontSize(geom.GetFontSize());
d->m_tmPattern.Update(pDoc); d->m_tmPattern.Update(pDoc, dSize, dHeight);
// generate lines of text // generate lines of text
d->m_tmPattern.SetFontSize(geom.GetFontSize()); d->m_tmPattern.SetFontSize(geom.GetFontSize());
d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight()); d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());

View File

@ -77,7 +77,8 @@ public:
void SetDetail(const QString &qsName, const VPatternPieceData& data, const QFont& font); 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; QTransform GetMatrix() const;
void SetMatrix(const QTransform &matrix); void SetMatrix(const QTransform &matrix);

View File

@ -277,7 +277,7 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data)
* @brief VTextManager::Update updates the text lines with pattern info * @brief VTextManager::Update updates the text lines with pattern info
* @param pDoc pointer to the abstract pattern object * @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(); Clear();
TextLine tl; TextLine tl;
@ -324,6 +324,8 @@ void VTextManager::Update(const VAbstractPattern *pDoc)
tl.m_qsText = pDoc->GetPatternSize(); tl.m_qsText = pDoc->GetPatternSize();
if (tl.m_qsText.isEmpty() == false) 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_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal; tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 0; tl.m_iFontSize = 0;

View File

@ -85,7 +85,7 @@ public:
bool IsBigEnough(qreal fW, qreal fH, int iFontSize); bool IsBigEnough(qreal fW, qreal fH, int iFontSize);
void FitFontSize(qreal fW, qreal fH); void FitFontSize(qreal fW, qreal fH);
void Update(const QString& qsName, const VPatternPieceData& data); void Update(const QString& qsName, const VPatternPieceData& data);
void Update(const VAbstractPattern* pDoc); void Update(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight);
protected: protected:
static QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm); static QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm);

View File

@ -309,9 +309,9 @@ void VTextGraphicsItem::UpdateData(const QString &qsName, const VPatternPieceDat
* @brief VTextGraphicsItem::UpdateData Updates the pattern label * @brief VTextGraphicsItem::UpdateData Updates the pattern label
* @param pDoc pointer to the pattern object * @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);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -88,7 +88,7 @@ public:
void Update(); void Update();
bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const; bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const;
void UpdateData(const QString& qsName, const VPatternPieceData& data); 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; int GetTextLines() const;
protected: protected:

View File

@ -811,7 +811,7 @@ void VToolDetail::UpdatePatternInfo()
fnt.setPixelSize(iFS); fnt.setPixelSize(iFS);
patternInfo->SetFont(fnt); patternInfo->SetFont(fnt);
patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight()); patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight());
patternInfo->UpdateData(doc); patternInfo->UpdateData(doc, getData()->size(), getData()->height());
QPointF pt = geom.GetPos(); QPointF pt = geom.GetPos();
QRectF rectBB; QRectF rectBB;