diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-09-08 10:24:07 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-09-15 17:57:54 +0200 |
| commit | 3696c99a9ab74113557578401d467d845171e543 (patch) | |
| tree | 7b7bdc1f9d795fb800df377ad1f28d1a658bc30f /src/tools/uic/python/pythonwriteimports.cpp | |
| parent | 30947c7fd4dddd76b69a3aa11567e27174d7a3ea (diff) | |
uic: Add an option to modify the generated resource import
Historically, resource imports were generated as "import file_rc",
however, pyside6-project generates files by prepending "rc_". Add an
option to flip this.
Pick-to: 6.4
Change-Id: Iee0f161cb2101c8080bd131a6401bbaf4682186d
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'src/tools/uic/python/pythonwriteimports.cpp')
| -rw-r--r-- | src/tools/uic/python/pythonwriteimports.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index a894a00a8d5..a268f87bb48 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -56,14 +56,17 @@ static WriteImports::ClassesPerModule defaultClasses() // Change the name of a qrc file "dir/foo.qrc" file to the Python // module name "foo_rc" according to project conventions. -static QString pythonResource(QString resource) +static QString pythonResource(QString resource, bool prefix) { const qsizetype lastSlash = resource.lastIndexOf(u'/'); if (lastSlash != -1) resource.remove(0, lastSlash + 1); if (resource.endsWith(".qrc"_L1)) { resource.chop(4); - resource.append("_rc"_L1); + if (prefix) + resource.prepend("rc_"_L1); + else + resource.append("_rc"_L1); } return resource; } @@ -140,7 +143,8 @@ void WriteImports::acceptUI(DomUI *node) const auto includes = resources->elementInclude(); for (auto include : includes) { if (include->hasAttributeLocation()) - writeImport(pythonResource(include->attributeLocation())); + writeImport(pythonResource(include->attributeLocation(), + uic()->option().rcPrefix)); } output << '\n'; } |
