Skip to content

Commit

Permalink
uic: Fix font family code generation for python
Browse files Browse the repository at this point in the history
Amend the code introduced by d8602ce
to generator correct code for Python.

Pick-to: 6.1 dev
Change-Id: I71fc9a1830d6bd591d32ce08002572c29f02a27f
Reviewed-by: Jani Heikkinen <[email protected]>
Reviewed-by: Jarek Kobus <[email protected]>
  • Loading branch information
FriedemannKleint committed May 3, 2021
1 parent 6d52d86 commit b2ebc64
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tools/uic/cpp/cppwriteinitialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions src/tools/uic/shared/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::");
Expand All @@ -54,6 +56,8 @@ void setLanguage(Language l)
break;
case Language::Python:
derefPointer = QLatin1String(".");
listStart = '[';
listEnd = ']';
nullPtr = QLatin1String("None");
operatorNew = QLatin1String("");
qtQualifier = QLatin1String("Qt.");
Expand All @@ -67,6 +71,8 @@ void setLanguage(Language l)
}

QString derefPointer;
char listStart;
char listEnd;
QString nullPtr;
QString operatorNew;
QString qtQualifier;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/uic/shared/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b2ebc64

Please sign in to comment.