uic: Generate QFont::Weight
Check for the new "fontweight" attribute before "bold". Task-number: QTBUG-113670 Change-Id: Ib34ab5a19872adb3c063861ffbe6b2d3374afcaa Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit 79436bd34ddf2dc39d42ed9b80a54f4d581c44d9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
38c0d60047
commit
d0962ccebe
@ -180,6 +180,15 @@ FontHandle::FontHandle(const DomFont *domFont) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString fontWeight(const DomFont *domFont)
|
||||||
|
{
|
||||||
|
if (domFont->hasElementFontWeight())
|
||||||
|
return domFont->elementFontWeight();
|
||||||
|
if (domFont->hasElementBold())
|
||||||
|
return domFont->elementBold() ? u"Bold"_s : u"Normal"_s;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
int FontHandle::compare(const FontHandle &rhs) const
|
int FontHandle::compare(const FontHandle &rhs) const
|
||||||
{
|
{
|
||||||
const QString family = m_domFont->hasElementFamily() ? m_domFont->elementFamily() : QString();
|
const QString family = m_domFont->hasElementFamily() ? m_domFont->elementFamily() : QString();
|
||||||
@ -194,10 +203,10 @@ int FontHandle::compare(const FontHandle &rhs) const
|
|||||||
if (const int crc = compareInt(pointSize, rhsPointSize))
|
if (const int crc = compareInt(pointSize, rhsPointSize))
|
||||||
return crc;
|
return crc;
|
||||||
|
|
||||||
const int bold = m_domFont->hasElementBold() ? (m_domFont->elementBold() ? 1 : 0) : -1;
|
const QString fontWeight = CPP::fontWeight(m_domFont);
|
||||||
const int rhsBold = rhs.m_domFont->hasElementBold() ? (rhs.m_domFont->elementBold() ? 1 : 0) : -1;
|
const QString rhsFontWeight = CPP::fontWeight(rhs.m_domFont);
|
||||||
if (const int crc = compareInt(bold, rhsBold))
|
if (const int wrc = fontWeight.compare(rhsFontWeight))
|
||||||
return crc;
|
return wrc;
|
||||||
|
|
||||||
const int italic = m_domFont->hasElementItalic() ? (m_domFont->elementItalic() ? 1 : 0) : -1;
|
const int italic = m_domFont->hasElementItalic() ? (m_domFont->elementItalic() ? 1 : 0) : -1;
|
||||||
const int rhsItalic = rhs.m_domFont->hasElementItalic() ? (rhs.m_domFont->elementItalic() ? 1 : 0) : -1;
|
const int rhsItalic = rhs.m_domFont->hasElementItalic() ? (rhs.m_domFont->elementItalic() ? 1 : 0) : -1;
|
||||||
@ -209,11 +218,6 @@ int FontHandle::compare(const FontHandle &rhs) const
|
|||||||
if (const int crc = compareInt(underline, rhsUnderline))
|
if (const int crc = compareInt(underline, rhsUnderline))
|
||||||
return crc;
|
return crc;
|
||||||
|
|
||||||
const int weight = m_domFont->hasElementWeight() ? m_domFont->elementWeight() : -1;
|
|
||||||
const int rhsWeight = rhs.m_domFont->hasElementWeight() ? rhs.m_domFont->elementWeight() : -1;
|
|
||||||
if (const int crc = compareInt(weight, rhsWeight))
|
|
||||||
return crc;
|
|
||||||
|
|
||||||
const int strikeOut = m_domFont->hasElementStrikeOut() ? (m_domFont->elementStrikeOut() ? 1 : 0) : -1;
|
const int strikeOut = m_domFont->hasElementStrikeOut() ? (m_domFont->elementStrikeOut() ? 1 : 0) : -1;
|
||||||
const int rhsStrikeOut = rhs.m_domFont->hasElementStrikeOut() ? (rhs.m_domFont->elementStrikeOut() ? 1 : 0) : -1;
|
const int rhsStrikeOut = rhs.m_domFont->hasElementStrikeOut() ? (rhs.m_domFont->elementStrikeOut() ? 1 : 0) : -1;
|
||||||
if (const int crc = compareInt(strikeOut, rhsStrikeOut))
|
if (const int crc = compareInt(strikeOut, rhsStrikeOut))
|
||||||
@ -1634,10 +1638,14 @@ QString WriteInitialization::writeFontProperties(const DomFont *f)
|
|||||||
<< ")" << language::eol;
|
<< ")" << language::eol;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->hasElementBold()) {
|
if (f->hasElementFontWeight()) {
|
||||||
|
m_output << m_indent << fontName << ".setWeight(QFont"
|
||||||
|
<< language::qualifier << f->elementFontWeight() << ')' << language::eol;
|
||||||
|
} else if (f->hasElementBold()) {
|
||||||
m_output << m_indent << fontName << ".setBold("
|
m_output << m_indent << fontName << ".setBold("
|
||||||
<< language::boolValue(f->elementBold()) << ')' << language::eol;
|
<< language::boolValue(f->elementBold()) << ')' << language::eol;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->hasElementItalic()) {
|
if (f->hasElementItalic()) {
|
||||||
m_output << m_indent << fontName << ".setItalic("
|
m_output << m_indent << fontName << ".setItalic("
|
||||||
<< language::boolValue(f->elementItalic()) << ')' << language::eol;
|
<< language::boolValue(f->elementItalic()) << ')' << language::eol;
|
||||||
|
@ -3125,6 +3125,10 @@ void DomFont::read(QXmlStreamReader &reader)
|
|||||||
setElementHintingPreference(reader.readElementText());
|
setElementHintingPreference(reader.readElementText());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!tag.compare(u"fontweight"_s, Qt::CaseInsensitive)) {
|
||||||
|
setElementFontWeight(reader.readElementText());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
reader.raiseError("Unexpected element "_L1 + tag);
|
reader.raiseError("Unexpected element "_L1 + tag);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3173,6 +3177,9 @@ void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const
|
|||||||
if (m_children & HintingPreference)
|
if (m_children & HintingPreference)
|
||||||
writer.writeTextElement(u"hintingpreference"_s, m_hintingPreference);
|
writer.writeTextElement(u"hintingpreference"_s, m_hintingPreference);
|
||||||
|
|
||||||
|
if (m_children & FontWeight)
|
||||||
|
writer.writeTextElement(u"fontweight"_s, m_fontWeight);
|
||||||
|
|
||||||
writer.writeEndElement();
|
writer.writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3242,6 +3249,12 @@ void DomFont::setElementHintingPreference(const QString &a)
|
|||||||
m_hintingPreference = a;
|
m_hintingPreference = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomFont::setElementFontWeight(const QString &a)
|
||||||
|
{
|
||||||
|
m_children |= FontWeight;
|
||||||
|
m_fontWeight = a;
|
||||||
|
}
|
||||||
|
|
||||||
void DomFont::clearElementFamily()
|
void DomFont::clearElementFamily()
|
||||||
{
|
{
|
||||||
m_children &= ~Family;
|
m_children &= ~Family;
|
||||||
@ -3297,6 +3310,11 @@ void DomFont::clearElementHintingPreference()
|
|||||||
m_children &= ~HintingPreference;
|
m_children &= ~HintingPreference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomFont::clearElementFontWeight()
|
||||||
|
{
|
||||||
|
m_children &= ~FontWeight;
|
||||||
|
}
|
||||||
|
|
||||||
DomPoint::~DomPoint() = default;
|
DomPoint::~DomPoint() = default;
|
||||||
|
|
||||||
void DomPoint::read(QXmlStreamReader &reader)
|
void DomPoint::read(QXmlStreamReader &reader)
|
||||||
|
@ -1650,6 +1650,11 @@ public:
|
|||||||
inline bool hasElementHintingPreference() const { return m_children & HintingPreference; }
|
inline bool hasElementHintingPreference() const { return m_children & HintingPreference; }
|
||||||
void clearElementHintingPreference();
|
void clearElementHintingPreference();
|
||||||
|
|
||||||
|
inline QString elementFontWeight() const { return m_fontWeight; }
|
||||||
|
void setElementFontWeight(const QString &a);
|
||||||
|
inline bool hasElementFontWeight() const { return m_children & FontWeight; }
|
||||||
|
void clearElementFontWeight();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// child element data
|
// child element data
|
||||||
@ -1665,6 +1670,7 @@ private:
|
|||||||
QString m_styleStrategy;
|
QString m_styleStrategy;
|
||||||
bool m_kerning = false;
|
bool m_kerning = false;
|
||||||
QString m_hintingPreference;
|
QString m_hintingPreference;
|
||||||
|
QString m_fontWeight;
|
||||||
|
|
||||||
enum Child {
|
enum Child {
|
||||||
Family = 1,
|
Family = 1,
|
||||||
@ -1677,7 +1683,8 @@ private:
|
|||||||
Antialiasing = 128,
|
Antialiasing = 128,
|
||||||
StyleStrategy = 256,
|
StyleStrategy = 256,
|
||||||
Kerning = 512,
|
Kerning = 512,
|
||||||
HintingPreference = 1024
|
HintingPreference = 1024,
|
||||||
|
FontWeight = 2048
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user