diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-09-02 11:49:49 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-09-03 07:31:45 +0200 |
commit | 0e0149c64dc9b4cf46f4e8f01e5680e7ea5372c4 (patch) | |
tree | ac2e3fb9a0eda3a2f67885d201fa448a049edb78 /src/tools | |
parent | 6bbf3f0257603eb39d5511910e8bee1ed862b6cf (diff) |
Ignore weight in .ui files instead of converting it
In 3558704ed5c3d2c6dc6d024dfa454997469ca75f, we added code to
support old .ui files which used the old integer scale for font
weights by checking for a special attribute which would help
separate new and old files.
Since then, it has become apparent that the weight element in
.ui is not actually used for anything, since it is only emitted
when the bold flag is set and always has to match QFont::Bold
in these cases.
So instead of converting, we simply ignore it now, and respect
the bold flag instead.
This also reverts the changes to ui4.* in uic, since the
scale attribute is no longer needed.
Task-number: QTBUG-42248
Change-Id: I1898868b58004099590f4eaf01f24c57bd34d779
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 53 | ||||
-rw-r--r-- | src/tools/uic/ui4.cpp | 13 | ||||
-rw-r--r-- | src/tools/uic/ui4.h | 13 |
3 files changed, 0 insertions, 79 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 2a3c9bdd70..8ba6e12903 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1622,59 +1622,6 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) m_output << m_indent << fontName << ".setUnderline(" << language::boolValue(f->elementUnderline()) << ')' << language::eol; } - if (f->hasElementWeight() && f->elementWeight() > 0) { - int weight = f->elementWeight(); - if (!f->hasAttributeScale()) { - // Convert from old Qt scale to OpenType scale. - // (not a linear conversion, so we adapt the known values and approximate the others). - // Note that we cannot use qt_legacyToOpenTypeWeight from qfont_p.h here due to - // dependency issues. - - switch (f->elementWeight()) { - case 0: - weight = 100; - break; - case 12: - weight = 200; - break; - case 25: - weight = 300; - break; - case 50: - weight = 400; - break; - case 57: - weight = 500; - break; - case 63: - weight = 600; - break; - case 75: - weight = 700; - break; - case 81: - weight = 800; - break; - case 87: - weight = 900; - break; - default: - weight *= 8; - weight += 100; - break; - } - } - - switch (language::language()) { - case Language::Cpp: - m_output << m_indent << fontName << ".setWeight(QFont::Weight(" << weight << "))" - << language::eol; - break; - case Language::Python: - m_output << m_indent << fontName << ".setWeight(" << weight << ")" << language::eol; - break; - } - } if (f->hasElementStrikeOut()) { m_output << m_indent << fontName << ".setStrikeOut(" << language::boolValue(f->elementStrikeOut()) << ')' << language::eol; diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 8a535582b9..a155df9b6c 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -3099,16 +3099,6 @@ DomFont::~DomFont() = default; void DomFont::read(QXmlStreamReader &reader) { - const QXmlStreamAttributes &attributes = reader.attributes(); - for (const QXmlStreamAttribute &attribute : attributes) { - const auto name = attribute.name(); - if (name == QLatin1String("scale")) { - setAttributeScale(attribute.value().toString()); - continue; - } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); - } - while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { @@ -3168,9 +3158,6 @@ void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const { writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("font") : tagName.toLower()); - if (hasAttributeScale()) - writer.writeAttribute(QStringLiteral("scale"), attributeScale()); - if (m_children & Family) writer.writeTextElement(QStringLiteral("family"), m_family); diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 41f11644bd..a5ac51f521 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -1619,16 +1619,6 @@ public: void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - // attribute accessors - inline bool hasAttributeScale() const { return m_has_attr_scale; } - inline QString attributeScale() const { return m_attr_scale; } - inline void setAttributeScale(const QString &a) - { - m_attr_scale = a; - m_has_attr_scale = true; - } - inline void clearAttributeScale() { m_has_attr_scale = false; } - // child element accessors inline QString elementFamily() const { return m_family; } void setElementFamily(const QString &a); @@ -1681,9 +1671,6 @@ public: void clearElementKerning(); private: - // attribute data - QString m_attr_scale; - bool m_has_attr_scale = false; // child element data uint m_children = 0; |