From 4d58e05f3ecbc003f0bd54ea45573061ae643f08 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 18:10:15 +0300 Subject: [PATCH] New option Font size increment. Add value to point size of base font. --HG-- branch : feature --- src/libs/ifc/ifcdef.h | 1 + src/libs/ifc/schema/label_template/v1.0.0.xsd | 1 + src/libs/ifc/schema/pattern/v0.6.0.xsd | 1 + src/libs/ifc/xml/vdomdocument.cpp | 13 ++++++---- src/libs/ifc/xml/vdomdocument.h | 1 + src/libs/vlayout/vtextmanager.cpp | 2 +- .../dialogs/support/dialogeditlabel.cpp | 25 +++++++++++++++++++ .../vtools/dialogs/support/dialogeditlabel.h | 1 + .../vtools/dialogs/support/dialogeditlabel.ui | 13 ++++++++++ 9 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 21899c820..e5ae62094 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -222,6 +222,7 @@ struct VLabelTemplateLine bool bold; bool italic; int alignment; + int fontSizeIncrement; }; QT_WARNING_POP diff --git a/src/libs/ifc/schema/label_template/v1.0.0.xsd b/src/libs/ifc/schema/label_template/v1.0.0.xsd index 3890aade3..894be390d 100644 --- a/src/libs/ifc/schema/label_template/v1.0.0.xsd +++ b/src/libs/ifc/schema/label_template/v1.0.0.xsd @@ -13,6 +13,7 @@ + diff --git a/src/libs/ifc/schema/pattern/v0.6.0.xsd b/src/libs/ifc/schema/pattern/v0.6.0.xsd index 71bb2b232..f85c1c285 100644 --- a/src/libs/ifc/schema/pattern/v0.6.0.xsd +++ b/src/libs/ifc/schema/pattern/v0.6.0.xsd @@ -102,6 +102,7 @@ + diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 27970f670..247a564cb 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -178,11 +178,12 @@ void MessageHandler::handleMessage(QtMsgType type, const QString &description, c Q_LOGGING_CATEGORY(vXML, "v.xml") -const QString VDomDocument::AttrId = QStringLiteral("id"); -const QString VDomDocument::AttrText = QStringLiteral("text"); -const QString VDomDocument::AttrBold = QStringLiteral("bold"); -const QString VDomDocument::AttrItalic = QStringLiteral("italic"); -const QString VDomDocument::AttrAlignment = QStringLiteral("alignment"); +const QString VDomDocument::AttrId = QStringLiteral("id"); +const QString VDomDocument::AttrText = QStringLiteral("text"); +const QString VDomDocument::AttrBold = QStringLiteral("bold"); +const QString VDomDocument::AttrItalic = QStringLiteral("italic"); +const QString VDomDocument::AttrAlignment = QStringLiteral("alignment"); +const QString VDomDocument::AttrFSIncrement = QStringLiteral("sfIncrement"); const QString VDomDocument::TagVersion = QStringLiteral("version"); const QString VDomDocument::TagUnit = QStringLiteral("unit"); @@ -928,6 +929,7 @@ QVector VDomDocument::GetLabelTemplate(const QDomElement &el line.bold = GetParametrBool(tagLine, AttrBold, falseStr); line.italic = GetParametrBool(tagLine, AttrItalic, falseStr); line.alignment = GetParametrUInt(tagLine, AttrAlignment, "0"); + line.fontSizeIncrement = GetParametrUInt(tagLine, AttrFSIncrement, "0"); lines.append(line); } tagLine = tagLine.nextSiblingElement(TagLine); @@ -950,6 +952,7 @@ void VDomDocument::SetLabelTemplate(QDomElement &element, const QVector PrepareLines(const QVector &lines) TextLine tl; tl.m_qsText = lines.at(i).line; tl.m_eAlign = static_cast(lines.at(i).alignment); - tl.m_iFontSize = 0; + tl.m_iFontSize = lines.at(i).fontSizeIncrement; tl.bold = lines.at(i).bold; tl.italic = lines.at(i).italic; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index af36f047e..3104dfb9f 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -66,6 +66,8 @@ DialogEditLabel::DialogEditLabel(VAbstractPattern *doc, QWidget *parent) connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate); connect(ui->toolButtonExportLabel, &QToolButton::clicked, this, &DialogEditLabel::ExportTemplate); connect(ui->toolButtonImportLabel, &QToolButton::clicked, this, &DialogEditLabel::ImportTemplate); + connect(ui->spinBoxFontSize, static_cast(&QSpinBox::valueChanged), this, + &DialogEditLabel::SaveAdditionalFontSize); InitPlaceholders(); InitPlaceholdersMenu(); @@ -129,6 +131,10 @@ void DialogEditLabel::ShowLineDetails() ui->toolButtonTextLeft->blockSignals(false); ui->toolButtonTextCenter->blockSignals(false); ui->toolButtonTextRight->blockSignals(false); + + ui->spinBoxFontSize->blockSignals(true); + ui->spinBoxFontSize->setValue(line->data(Qt::UserRole).toInt()); + ui->spinBoxFontSize->blockSignals(false); } } @@ -397,6 +403,19 @@ void DialogEditLabel::TabChanged(int index) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::SaveAdditionalFontSize(int i) +{ + QListWidgetItem *curLine = ui->listWidgetEdit->currentItem(); + if (curLine) + { + QFont lineFont = curLine->font(); + lineFont.setPointSize(lineFont.pointSize() - curLine->data(Qt::UserRole).toInt() + i); + curLine->setFont(lineFont); + curLine->setData(Qt::UserRole, i); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::SetupControls() { @@ -422,6 +441,7 @@ void DialogEditLabel::SetupControls() ui->toolButtonNewLabel->setEnabled(enabled); ui->toolButtonExportLabel->setEnabled(enabled); ui->lineEditLine->setEnabled(enabled); + ui->spinBoxFontSize->setEnabled(enabled); } //--------------------------------------------------------------------------------------------------------------------- @@ -503,6 +523,7 @@ QVector DialogEditLabel::GetTemplate() const VLabelTemplateLine line; line.line = qApp->TrVars()->PlaceholderFromUserText(lineItem->text()); line.alignment = lineItem->textAlignment(); + line.fontSizeIncrement = lineItem->data(Qt::UserRole).toInt(); const QFont font = lineItem->font(); line.bold = font.bold(); @@ -527,10 +548,12 @@ void DialogEditLabel::SetTemplate(const QVector &lines) { QListWidgetItem *item = new QListWidgetItem(qApp->TrVars()->PlaceholderToUserText(lines.at(i).line)); item->setTextAlignment(lines.at(i).alignment); + item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement); QFont font = item->font(); font.setBold(lines.at(i).bold); font.setItalic(lines.at(i).italic); + font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement); item->setFont(font); ui->listWidgetEdit->insertItem(++row, item); @@ -555,10 +578,12 @@ void DialogEditLabel::InitPreviewLines(const QVector &lines) { QListWidgetItem *item = new QListWidgetItem(ReplacePlaceholders(lines.at(i).line)); item->setTextAlignment(lines.at(i).alignment); + item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement); QFont font = item->font(); font.setBold(lines.at(i).bold); font.setItalic(lines.at(i).italic); + font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement); item->setFont(font); ui->listWidgetPreview->insertItem(++row, item); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index ad785ddfa..13800f784 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -64,6 +64,7 @@ private slots: void ImportTemplate(); void InsertPlaceholder(); void TabChanged(int index); + void SaveAdditionalFontSize(int i); private: Q_DISABLE_COPY(DialogEditLabel) diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.ui b/src/libs/vtools/dialogs/support/dialogeditlabel.ui index 8efd7d4f2..f03281469 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.ui +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.ui @@ -237,6 +237,19 @@ + + + + false + + + Additional font size. Use to make a line bigger. + + + 25 + + +