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>
This commit is contained in:
parent
a8cb177d31
commit
3c3a2eb3ce
@ -35,6 +35,7 @@
|
|||||||
#include "globaldefs.h"
|
#include "globaldefs.h"
|
||||||
|
|
||||||
#include <qtextstream.h>
|
#include <qtextstream.h>
|
||||||
|
#include <qversionnumber.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -1765,6 +1766,13 @@ QString WriteInitialization::domColor2QString(const DomColor *c)
|
|||||||
.arg(c->elementBlue());
|
.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)
|
void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QString &group, const QString &paletteName)
|
||||||
{
|
{
|
||||||
if (!colorGroup)
|
if (!colorGroup)
|
||||||
@ -1785,10 +1793,19 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri
|
|||||||
const auto &colorRoles = colorGroup->elementColorRole();
|
const auto &colorRoles = colorGroup->elementColorRole();
|
||||||
for (const DomColorRole *colorRole : colorRoles) {
|
for (const DomColorRole *colorRole : colorRoles) {
|
||||||
if (colorRole->hasAttributeRole()) {
|
if (colorRole->hasAttributeRole()) {
|
||||||
|
const QString roleName = colorRole->attributeRole();
|
||||||
|
const QVersionNumber versionAdded = colorRoleVersionAdded(roleName);
|
||||||
const QString brushName = writeBrushInitialization(colorRole->elementBrush());
|
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
|
m_output << m_indent << paletteName << ".setBrush(" << group
|
||||||
<< ", " << "QPalette::" << colorRole->attributeRole()
|
<< ", " << "QPalette::" << roleName
|
||||||
<< ", " << brushName << ");\n";
|
<< ", " << brushName << ");\n";
|
||||||
|
if (!versionAdded.isNull())
|
||||||
|
m_output << "#endif\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user