New option Font size increment.

Add value to point size of base font.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-15 18:10:15 +03:00
parent 0c0719114c
commit 4d58e05f3e
9 changed files with 52 additions and 6 deletions

View File

@ -222,6 +222,7 @@ struct VLabelTemplateLine
bool bold;
bool italic;
int alignment;
int fontSizeIncrement;
};
QT_WARNING_POP

View File

@ -13,6 +13,7 @@
<xs:attribute name="bold" type="xs:boolean"/>
<xs:attribute name="italic" type="xs:boolean"/>
<xs:attribute name="alignment" type="alignmentType"/>
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>

View File

@ -102,6 +102,7 @@
<xs:attribute name="bold" type="xs:boolean"/>
<xs:attribute name="italic" type="xs:boolean"/>
<xs:attribute name="alignment" type="alignmentType"/>
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>

View File

@ -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<VLabelTemplateLine> 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<VLabelTe
SetAttribute(tagLine, AttrBold, lines.at(i).bold);
SetAttribute(tagLine, AttrItalic, lines.at(i).italic);
SetAttribute(tagLine, AttrAlignment, lines.at(i).alignment);
SetAttribute(tagLine, AttrFSIncrement, lines.at(i).fontSizeIncrement);
element.appendChild(tagLine);
}

View File

@ -87,6 +87,7 @@ public:
static const QString AttrBold;
static const QString AttrItalic;
static const QString AttrAlignment;
static const QString AttrFSIncrement;
static const QString TagVersion;
static const QString TagUnit;

View File

@ -122,7 +122,7 @@ QList<TextLine> PrepareLines(const QVector<VLabelTemplateLine> &lines)
TextLine tl;
tl.m_qsText = lines.at(i).line;
tl.m_eAlign = static_cast<Qt::Alignment>(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;

View File

@ -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<void (QSpinBox::*)(int)>(&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<VLabelTemplateLine> 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<VLabelTemplateLine> &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<VLabelTemplateLine> &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);

View File

@ -64,6 +64,7 @@ private slots:
void ImportTemplate();
void InsertPlaceholder();
void TabChanged(int index);
void SaveAdditionalFontSize(int i);
private:
Q_DISABLE_COPY(DialogEditLabel)

View File

@ -237,6 +237,19 @@
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxFontSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Additional font size. Use to make a line bigger.</string>
</property>
<property name="maximum">
<number>25</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">