Avoid GUI display for App listing

This commit is contained in:
Anselm Busse
2021-04-04 10:43:21 +02:00
committed by Cameron Gutman
parent 0802609fd8
commit 4ee36fd405
7 changed files with 46 additions and 87 deletions

View File

@@ -38,6 +38,7 @@
#include "gui/computermodel.h"
#include "gui/appmodel.h"
#include "backend/autoupdatechecker.h"
#include "backend/computermanager.h"
#include "backend/systemproperties.h"
#include "streaming/session.h"
#include "settings/streamingpreferences.h"
@@ -585,6 +586,7 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
QString initialView;
bool hasGUI = true;
GlobalCommandLineParser parser;
switch (parser.parse(app.arguments())) {
@@ -623,21 +625,24 @@ int main(int argc, char *argv[])
}
case GlobalCommandLineParser::ListRequested:
{
initialView = "qrc:/gui/CliListAppsSegue.qml";
ListCommandLineParser listParser;
listParser.parse(app.arguments());
auto launcher = new CliListApps::Launcher(listParser.getHost(), listParser.isPrintCSV(), &app);
engine.rootContext()->setContextProperty("launcher", launcher);
auto launcher = new CliListApps::Launcher(listParser.getHost(), listParser, &app);
launcher->execute(new ComputerManager(&app));
hasGUI = false;
break;
}
}
engine.rootContext()->setContextProperty("initialView", initialView);
if (hasGUI) {
engine.rootContext()->setContextProperty("initialView", initialView);
// Load the main.qml file
engine.load(QUrl(QStringLiteral("qrc:/gui/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
}
// Load the main.qml file
engine.load(QUrl(QStringLiteral("qrc:/gui/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
int err = app.exec();
// Give worker tasks time to properly exit. Fixes PendingQuitTask