@@ -70,6 +70,11 @@ int main(int argc, const char *argv[])
70Load the testability driver");
70Load the testability driver");
71 parser.addOption(testabilityOption);
71 parser.addOption(testabilityOption);
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);
73 application = new QGuiApplication(argc, (char**)argv);
78 application = new QGuiApplication(argc, (char**)argv);
75 // Treat args with single dashes the same as arguments with two dashes
80 // Treat args with single dashes the same as arguments with two dashes
@@ -90,6 +95,26 @@ Load the testability driver");
90 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
95 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
98+ // If an invalid option was specified, set it to the default
99+ // If no default was provided in the QCommandLineOption constructor, abort.
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"))
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;
111+ qFatal("Shell mode argument was not provided and there is no default mode,");
115+ shellMode = parser.value(modeOption);
93 // The testability driver is only loaded by QApplication but not by QGuiApplication.
118 // The testability driver is only loaded by QApplication but not by QGuiApplication.
94 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
119 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
95 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
120 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
@@ -117,6 +142,7 @@ Load the testability driver");
117 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
142 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
118 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
143 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
119 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
144 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
145+ view->rootContext()->setContextProperty("shellMode", shellMode);
120 if (parser.isSet(framelessOption)) {
146 if (parser.isSet(framelessOption)) {
121 view->setFlags(Qt::FramelessWindowHint);
147 view->setFlags(Qt::FramelessWindowHint);