uic: support label attribute in UI files

provide support for label attribute in ui files. The label
is used to categorize ID-based translations on Linguist.
This is a part of a larger change in
qttools (3c0836a55d)

Pick-to: 6.8
Pick-to: 6.9
Pick-to: 6.10
Change-Id: If9f010f84d65daea7d8fc5622f7a1d660de064e6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
This commit is contained in:
Masoud Jami 2025-02-28 16:23:08 +01:00
parent 3f6b128d7e
commit 12636b09ea
2 changed files with 15 additions and 0 deletions

View File

@ -54,6 +54,10 @@ void DomUI::read(QXmlStreamReader &reader)
setAttributeIdbasedtr(attribute.value() == u"true"_s);
continue;
}
if (name == u"label"_s) {
setAttributeLabel(attribute.value().toString());
continue;
}
if (name == u"connectslotsbyname"_s) {
setAttributeConnectslotsbyname(attribute.value() == u"true"_s);
continue;
@ -192,6 +196,9 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const
if (hasAttributeIdbasedtr())
writer.writeAttribute(u"idbasedtr"_s, (attributeIdbasedtr() ? u"true"_s : u"false"_s));
if (hasAttributeLabel())
writer.writeAttribute(u"label"_s, attributeLabel());
if (hasAttributeConnectslotsbyname())
writer.writeAttribute(u"connectslotsbyname"_s, (attributeConnectslotsbyname() ? u"true"_s : u"false"_s));

View File

@ -143,6 +143,11 @@ public:
inline void setAttributeIdbasedtr(bool a) { m_attr_idbasedtr = a; m_has_attr_idbasedtr = true; }
inline void clearAttributeIdbasedtr() { m_has_attr_idbasedtr = false; }
inline bool hasAttributeLabel() const { return m_has_attr_label; }
inline QString attributeLabel() const { return m_attr_label; }
inline void setAttributeLabel(const QString &a) { m_attr_label = a; m_has_attr_label = true; }
inline void clearAttributeLabel() { m_attr_label.clear(); }
inline bool hasAttributeConnectslotsbyname() const { return m_has_attr_connectslotsbyname; }
inline bool attributeConnectslotsbyname() const { return m_attr_connectslotsbyname; }
inline void setAttributeConnectslotsbyname(bool a) { m_attr_connectslotsbyname = a; m_has_attr_connectslotsbyname = true; }
@ -264,6 +269,9 @@ private:
bool m_attr_idbasedtr = false;
bool m_has_attr_idbasedtr = false;
QString m_attr_label;
bool m_has_attr_label = false;
bool m_attr_connectslotsbyname = false;
bool m_has_attr_connectslotsbyname = false;