From 6e111f96e307501ec02a620fa3124fd3ce9c9193 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 30 Jan 2020 15:43:57 +0100 Subject: 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 --- tools/qml/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools/qml') 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 #include #include +#include #include #include @@ -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); -- cgit v1.2.3