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),
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()
{

View File

@ -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();

View File

@ -39,6 +39,8 @@
#include <QLineEdit>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QMessageBox>
#include <QPushButton>
//---------------------------------------------------------------------------------------------------------------------
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()
{

View File

@ -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();
};

View File

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

View File

@ -486,7 +486,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *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();

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;
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());

View File

@ -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);

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
* @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;

View File

@ -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);

View File

@ -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);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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:

View File

@ -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;