uic: Add a -no-qt-namespace option
To suppress the generation of the Ui class within QT_BEGIN_NAMESPACE and QT_END_NAMESPACE. Change-Id: I6552b41d8e9eccb0475618d7ed7f7cea7f826625 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>bb10
parent
b74db90be0
commit
7b1ba955a6
|
|
@ -65,8 +65,8 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
|||
// is a User using Qt-in-namespace having his own classes not in a namespace.
|
||||
// In this case the generated Ui helper classes will also end up in
|
||||
// the Qt namespace (which is harmless, but not "pretty")
|
||||
const bool needsMacro = namespaceList.size() == 0
|
||||
|| namespaceList[0] == "qdesigner_internal"_L1;
|
||||
const bool needsMacro = m_option.qtNamespace &&
|
||||
(namespaceList.size() == 0 || namespaceList[0] == "qdesigner_internal"_L1);
|
||||
|
||||
if (needsMacro)
|
||||
m_output << "QT_BEGIN_NAMESPACE\n\n";
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@ int runUic(int argc, char *argv[])
|
|||
postfixOption.setValueName(u"postfix"_s);
|
||||
parser.addOption(postfixOption);
|
||||
|
||||
QCommandLineOption noQtNamespaceOption(u"no-qt-namespace"_s);
|
||||
noQtNamespaceOption.setDescription(
|
||||
u"Disable wrapping the definition of the generated class in QT_{BEGIN,END}_NAMESPACE."_s);
|
||||
parser.addOption(noQtNamespaceOption);
|
||||
|
||||
QCommandLineOption translateOption(QStringList{u"tr"_s, u"translate"_s});
|
||||
translateOption.setDescription(u"Use <function> for i18n."_s);
|
||||
translateOption.setValueName(u"function"_s);
|
||||
|
|
@ -149,6 +154,7 @@ int runUic(int argc, char *argv[])
|
|||
driver.option().autoConnection = !parser.isSet(noAutoConnectionOption);
|
||||
driver.option().headerProtection = !parser.isSet(noProtOption);
|
||||
driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption);
|
||||
driver.option().qtNamespace = !parser.isSet(noQtNamespaceOption);
|
||||
driver.option().idBased = parser.isSet(idBasedOption);
|
||||
driver.option().postfix = parser.value(postfixOption);
|
||||
driver.option().translateFunction = parser.value(translateOption);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ struct Option
|
|||
unsigned int forceStringConnectionSyntax: 1;
|
||||
unsigned int useStarImports: 1;
|
||||
unsigned int rcPrefix: 1; // Python: Generate "rc_file" instead of "file_rc" import
|
||||
unsigned int qtNamespace: 1;
|
||||
|
||||
QString inputFile;
|
||||
QString outputFile;
|
||||
|
|
@ -57,6 +58,7 @@ struct Option
|
|||
forceStringConnectionSyntax(0),
|
||||
useStarImports(0),
|
||||
rcPrefix(0),
|
||||
qtNamespace(1),
|
||||
prefix(QLatin1StringView("Ui_"))
|
||||
{ indent.fill(u' ', 4); }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue