Allow passing default main views via cmdline

This commit is contained in:
Michael Zanetti 2020-12-09 15:17:55 +01:00
parent 66cee1eb09
commit cf45517adb
2 changed files with 13 additions and 1 deletions

View File

@ -100,6 +100,8 @@ int main(int argc, char *argv[])
defaultStyleOption.setDefaultValue("light");
parser.addOption(defaultStyleOption);
#endif
QCommandLineOption defaultViewsOption = QCommandLineOption({"v", "default-views"}, "The main views enabled by default if there is no configuration done by the user and the style doesn't dictate them, comma separated.", "mainviews");
parser.addOption(defaultViewsOption);
QCommandLineOption kioskOption = QCommandLineOption({"k", "kiosk"}, "Start the application in kiosk mode.");
parser.addOption(kioskOption);
parser.process(application);
@ -165,6 +167,7 @@ int main(int argc, char *argv[])
engine->rootContext()->setContextProperty("qtBuildVersion", QT_VERSION_STR);
engine->rootContext()->setContextProperty("qtVersion", qVersion());
engine->rootContext()->setContextProperty("defaultMainViewFilter", parser.value(defaultViewsOption));
engine->rootContext()->setContextProperty("kioskMode", parser.isSet(kioskOption));
engine->rootContext()->setContextProperty("autoConnectHost", parser.value(connectOption));

View File

@ -94,7 +94,16 @@ Page {
category: engine.jsonRpcClient.currentHost.uuid
property string mainMenuContent: ""
property var sortOrder: []
property var filterList: app.hasOwnProperty("mainViewsFilter") ? app.mainViewsFilter : ["things"]
// Priority for main view config:
// 1. Settings made by the user
// 2. Style mainViewsFilter as that comes with branding (for now, if a style defines main views, all of them are active by default)
// 3. Command line args
// 4. Just show "things" alone by default
property var filterList: app.hasOwnProperty("mainViewsFilter") ?
app.mainViewsFilter
: defaultMainViewFilter.length > 0 ?
defaultMainViewFilter.split(',')
: ["things"]
property int currentIndex: 0
}