@@ -70,6 +70,11 @@ int main(int argc, const char *argv[])
7070Load the testability driver");
7171 parser.addOption(testabilityOption);
7272
73+ QCommandLineOption modeOption("mode",
74+ "Whether to run greeter and/or shell [full-greeter, full-shell, greeter, shell]",
75+ "mode", "full-greeter");
76+ parser.addOption(modeOption);
77+
7378 application = new QGuiApplication(argc, (char**)argv);
7479
7580 // Treat args with single dashes the same as arguments with two dashes
@@ -90,6 +95,26 @@ Load the testability driver");
9095 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
9196 }
9297
98+ // If an invalid option was specified, set it to the default
99+ // If no default was provided in the QCommandLineOption constructor, abort.
100+ QString shellMode;
101+ if(!parser.isSet(modeOption) ||
102+ (parser.value(modeOption) != "full-greeter" &&
103+ parser.value(modeOption) != "full-shell" &&
104+ parser.value(modeOption) != "greeter" &&
105+ parser.value(modeOption) != "shell"))
106+ {
107+ if (modeOption.defaultValues().first() != nullptr) {
108+ shellMode = modeOption.defaultValues().first();
109+ qWarning() << "Mode argument was not provided or was set to an illegal value. Using default value of --mode=" << shellMode;
110+ } else {
111+ qFatal("Shell mode argument was not provided and there is no default mode,");
112+ }
113+
114+ } else {
115+ shellMode = parser.value(modeOption);
116+ }
117+
93118 // The testability driver is only loaded by QApplication but not by QGuiApplication.
94119 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
95120 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
@@ -117,6 +142,7 @@ Load the testability driver");
117142 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
118143 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
119144 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
145+ view->rootContext()->setContextProperty("shellMode", shellMode);
120146 if (parser.isSet(framelessOption)) {
121147 view->setFlags(Qt::FramelessWindowHint);
122148 }