summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-12-14 09:27:15 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-12-14 18:20:41 +0000
commit3c3a2eb3cea0bbb0b45e43278421e051c253e434 (patch)
treec3c8214b42ffc42dfa0f5d90bf5573e71aec2738
parenta8cb177d31d45a8cfee16b2c82131d1474d1d2e5 (diff)
uic: Generate version check macros around newly introduced palette color role
Change ebd3a13b807c6af2684b42d3912549caf7ef82aa introduced a new QPaletter::PlaceholderText color role which causes the uic-generated code not to compile when using Qt Designer embedded in Qt Creator with older (5.9 LTS) kits. Generate a version check macro to fix this. Change-Id: I6d9f7edb0c6047c2f64ef3357b29f91655c52aac Fixes: QTBUG-72555 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: André Hartmann <aha_1980@gmx.de>
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 4f6ac1eb97..7ab6c31cb2 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -35,6 +35,7 @@
#include "globaldefs.h"
#include <qtextstream.h>
+#include <qversionnumber.h>
#include <qdebug.h>
#include <algorithm>
@@ -1765,6 +1766,13 @@ QString WriteInitialization::domColor2QString(const DomColor *c)
.arg(c->elementBlue());
}
+static inline QVersionNumber colorRoleVersionAdded(const QString &roleName)
+{
+ if (roleName == QLatin1String("PlaceholderText"))
+ return QVersionNumber(5, 12, 0);
+ return QVersionNumber();
+}
+
void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QString &group, const QString &paletteName)
{
if (!colorGroup)
@@ -1785,10 +1793,19 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri
const auto &colorRoles = colorGroup->elementColorRole();
for (const DomColorRole *colorRole : colorRoles) {
if (colorRole->hasAttributeRole()) {
+ const QString roleName = colorRole->attributeRole();
+ const QVersionNumber versionAdded = colorRoleVersionAdded(roleName);
const QString brushName = writeBrushInitialization(colorRole->elementBrush());
+ if (!versionAdded.isNull()) {
+ m_output << "#if QT_VERSION >= QT_VERSION_CHECK("
+ << versionAdded.majorVersion() << ", " << versionAdded.minorVersion()
+ << ", " << versionAdded.microVersion() << ")\n";
+ }
m_output << m_indent << paletteName << ".setBrush(" << group
- << ", " << "QPalette::" << colorRole->attributeRole()
+ << ", " << "QPalette::" << roleName
<< ", " << brushName << ");\n";
+ if (!versionAdded.isNull())
+ m_output << "#endif\n";
}
}
}