uic: Fix font family code generation for python

Amend the code introduced by d8602ce58b
to generator correct code for Python.

Change-Id: I71fc9a1830d6bd591d32ce08002572c29f02a27f
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit b2ebc64dd9914359fe8acf2bc9960e341e98cf80)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Friedemann Kleint 2021-04-30 11:31:33 +02:00 committed by Qt Cherry-pick Bot
parent c28e609ff4
commit 96d9cf8de4
3 changed files with 12 additions and 2 deletions

View File

@ -1624,8 +1624,10 @@ QString WriteInitialization::writeFontProperties(const DomFont *f)
m_output << m_indent << language::stackVariable("QFont", fontName)
<< language::eol;
if (f->hasElementFamily() && !f->elementFamily().isEmpty()) {
m_output << m_indent << fontName << ".setFamilies(QStringList{"
<< language::qstring(f->elementFamily(), m_dindent) << "})" << language::eol;
m_output << m_indent << fontName << ".setFamilies("
<< language::listStart
<< language::qstring(f->elementFamily(), m_dindent)
<< language::listEnd << ')' << language::eol;
}
if (f->hasElementPointSize() && f->elementPointSize() > 0) {
m_output << m_indent << fontName << ".setPointSize(" << f->elementPointSize()

View File

@ -43,6 +43,8 @@ void setLanguage(Language l)
switch (_language) {
case Language::Cpp:
derefPointer = QLatin1String("->");
listStart = '{';
listEnd = '}';
nullPtr = QLatin1String("nullptr");
operatorNew = QLatin1String("new ");
qtQualifier = QLatin1String("Qt::");
@ -54,6 +56,8 @@ void setLanguage(Language l)
break;
case Language::Python:
derefPointer = QLatin1String(".");
listStart = '[';
listEnd = ']';
nullPtr = QLatin1String("None");
operatorNew = QLatin1String("");
qtQualifier = QLatin1String("Qt.");
@ -67,6 +71,8 @@ void setLanguage(Language l)
}
QString derefPointer;
char listStart;
char listEnd;
QString nullPtr;
QString operatorNew;
QString qtQualifier;

View File

@ -48,6 +48,8 @@ ConnectionSyntax connectionSyntax();
void setConnectionSyntax(ConnectionSyntax cs);
extern QString derefPointer;
extern char listStart;
extern char listEnd;
extern QString nullPtr;
extern QString operatorNew;
extern QString qtQualifier;