aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2020-01-30 15:43:57 +0100
committerThomas Hartmann <thomas.hartmann@qt.io>2020-02-04 06:25:00 +0100
commit6e111f96e307501ec02a620fa3124fd3ce9c9193 (patch)
treeab415fda5367e45a1d8f53dd54bc3f55555f0424 /tools
parentbda38eae465fdf7dc719966e1199eafc7eb7c27c (diff)
Add support for file selectors to qml tool
This allows defining file selectors using a command-line option. [ChangeLog][QtQml][qml] The QML Runtime tool --selector option now allows defining a custom QQmlFileSelector. Change-Id: I1be5efd273b2f387df72b1d5057f7281e5c0c156 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/main.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 4c613e4ab4..9f5aacb1dd 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -59,6 +59,7 @@
#include <QLibraryInfo>
#include <qqml.h>
#include <qqmldebug.h>
+#include <qqmlfileselector.h>
#include <private/qmemory_p.h>
#include <private/qtqmlglobal_p.h>
@@ -511,6 +512,9 @@ int main(int argc, char *argv[])
"Backend is one of: default, vulkan, metal, d3d11, gl"),
QStringLiteral("backend"));
parser.addOption(rhiOption);
+ QCommandLineOption selectorOption(QStringLiteral("S"), QCoreApplication::translate("main",
+ "Add selector to the list of QQmlFileSelectors."), QStringLiteral("selector"));
+ parser.addOption(selectorOption);
// Positional arguments
parser.addPositionalArgument("files",
@@ -550,6 +554,15 @@ int main(int argc, char *argv[])
#endif
for (const QString &importPath : parser.values(importOption))
e.addImportPath(importPath);
+
+ QStringList customSelectors;
+ for (const QString &selector : parser.values(selectorOption))
+ customSelectors.append(selector);
+ if (!customSelectors.isEmpty()) {
+ QQmlFileSelector *selector = QQmlFileSelector::get(&e);
+ selector->setExtraSelectors(customSelectors);
+ }
+
files << parser.values(qmlFileOption);
if (parser.isSet(configOption))
confFile = parser.value(configOption);