Format: Add QFont support
This commit is contained in:
@@ -464,6 +464,35 @@ void Format::setFontName(const QString &name)
|
|||||||
setProperty(FormatPrivate::P_Font_Name, name, QStringLiteral("Calibri"));
|
setProperty(FormatPrivate::P_Font_Name, name, QStringLiteral("Calibri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a QFont object based on font data contained in the format.
|
||||||
|
*/
|
||||||
|
QFont Format::font() const
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setFamily(fontName());
|
||||||
|
if (fontSize() > 0)
|
||||||
|
font.setPointSize(fontSize());
|
||||||
|
font.setBold(fontBold());
|
||||||
|
font.setItalic(fontItalic());
|
||||||
|
font.setUnderline(fontUnderline()!=FontUnderlineNone);
|
||||||
|
font.setStrikeOut(fontStrikeOut());
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the format properties from the given \a font.
|
||||||
|
*/
|
||||||
|
void Format::setFont(const QFont &font)
|
||||||
|
{
|
||||||
|
setFontName(font.family());
|
||||||
|
setFontSize(font.pointSize());
|
||||||
|
setFontBold(font.bold());
|
||||||
|
setFontItalic(font.italic());
|
||||||
|
setFontUnderline(font.underline() ? FontUnderlineSingle : FontUnderlineNone);
|
||||||
|
setFontStrikeOut(font.strikeOut());
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
* When the format has font data, when need to assign a valid index for it.
|
* When the format has font data, when need to assign a valid index for it.
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ public:
|
|||||||
void setFontOutline(bool outline);
|
void setFontOutline(bool outline);
|
||||||
QString fontName() const;
|
QString fontName() const;
|
||||||
void setFontName(const QString &);
|
void setFontName(const QString &);
|
||||||
|
QFont font() const;
|
||||||
|
void setFont(const QFont &font);
|
||||||
|
|
||||||
HorizontalAlignment horizontalAlignment() const;
|
HorizontalAlignment horizontalAlignment() const;
|
||||||
void setHorizontalAlignment(HorizontalAlignment align);
|
void setHorizontalAlignment(HorizontalAlignment align);
|
||||||
|
|||||||
Reference in New Issue
Block a user