From 12636b09ea4143042cfd9de06fe0fe0bf6fb72b0 Mon Sep 17 00:00:00 2001 From: Masoud Jami Date: Fri, 28 Feb 2025 16:23:08 +0100 Subject: [PATCH] uic: support label attribute in UI files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Kai Köhne --- src/tools/uic/ui4.cpp | 7 +++++++ src/tools/uic/ui4.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index b6a8f4eb4bf..e26d0260682 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -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)); diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 333f7f4e6ad..a46a42c6b73 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -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;