summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp22
-rw-r--r--src/tools/uic3/converter.cpp17
2 files changed, 29 insertions, 10 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index b6e5ba7..d43f74e 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -391,6 +391,13 @@ void WriteInitialization::LayoutDefaultHandler::acceptLayoutFunction(DomLayoutFu
}
}
+static inline void writeContentsMargins(const QString &indent, const QString &objectName, int value, QTextStream &str)
+{
+ QString contentsMargins;
+ QTextStream(&contentsMargins) << value << ", " << value << ", " << value << ", " << value;
+ writeSetter(indent, objectName, QLatin1String("setContentsMargins"), contentsMargins, str);
+ }
+
void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QString &indent, const QString &objectName,
const DomPropertyMap &properties, const QString &propertyName, const QString &setter,
int defaultStyleValue, bool suppressDefault, QTextStream &str) const
@@ -408,7 +415,11 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri
&& value == defaultStyleValue);
if (ifndefMac)
str << "#ifndef Q_OS_MAC\n";
- writeSetter(indent, objectName, setter, value, str);
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, value, str);
+ } else {
+ writeSetter(indent, objectName, setter, value, str);
+ }
if (ifndefMac)
str << "#endif\n";
return;
@@ -416,13 +427,18 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri
}
if (suppressDefault)
return;
- // get default
+ // get default.
if (m_state[p] & HasDefaultFunction) {
+ // Do not use setContentsMargins to avoid repetitive evaluations.
writeSetter(indent, objectName, setter, m_functions[p], str);
return;
}
if (m_state[p] & HasDefaultValue) {
- writeSetter(indent, objectName, setter, m_defaultValues[p], str);
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, m_defaultValues[p], str);
+ } else {
+ writeSetter(indent, objectName, setter, m_defaultValues[p], str);
+ }
}
return;
}
diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp
index 1b0460b..c5a75eb 100644
--- a/src/tools/uic3/converter.cpp
+++ b/src/tools/uic3/converter.cpp
@@ -988,6 +988,7 @@ void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *prop
QString objectName;
bool wordWrapFound = false;
+ bool wordWrapPropertyFound = false;
for (QDomElement e=n.firstChild().toElement(); !e.isNull(); e = e.nextSibling().toElement()) {
if (e.tagName().toLower() == QLatin1String("property")) {
@@ -1099,14 +1100,16 @@ void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *prop
name = prop->attributeName(); // sync the name
- if (className == QLatin1String("QLabel") && name == QLatin1String("alignment")) {
- QString v = prop->elementSet();
-
- if (v.contains(QRegExp(QLatin1String("\\bWordBreak\\b"))))
- wordWrapFound = true;
+ if (className == QLatin1String("QLabel")) {
+ if (name == QLatin1String("alignment")) {
+ const QString v = prop->elementSet();
+ if (v.contains(QRegExp(QLatin1String("\\bWordBreak\\b"))))
+ wordWrapFound = true;
+ } else if (name == QLatin1String("wordWrap")) {
+ wordWrapPropertyFound = true;
+ }
}
-
// resolve the flags and enumerator
if (prop->kind() == DomProperty::Set) {
QStringList flags = prop->elementSet().split(QLatin1Char('|'));
@@ -1164,7 +1167,7 @@ void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *prop
}
}
}
- if (className == QLatin1String("QLabel")) {
+ if (className == QLatin1String("QLabel") && !wordWrapPropertyFound) {
DomProperty *wordWrap = new DomProperty();
wordWrap->setAttributeName(QLatin1String("wordWrap"));
if (wordWrapFound)