Add a command line parameter to allow direct connections
This commit is contained in:
parent
e1f3f3879a
commit
2ad82d80a6
@ -75,6 +75,8 @@ int main(int argc, char *argv[])
|
||||
parser.addHelpOption();
|
||||
QCommandLineOption kioskOption = QCommandLineOption({"k", "kiosk"}, "Start the application in kiosk mode.");
|
||||
parser.addOption(kioskOption);
|
||||
QCommandLineOption connectOption = QCommandLineOption({"c", "connect"}, "Connect to nymea:core without discovery.", "host");
|
||||
parser.addOption(connectOption);
|
||||
parser.process(application);
|
||||
|
||||
// Initialize app log controller as early as possible, but after setting app name etc
|
||||
@ -124,6 +126,7 @@ int main(int argc, char *argv[])
|
||||
engine->rootContext()->setContextProperty("styleController", &styleController);
|
||||
|
||||
engine->rootContext()->setContextProperty("kioskMode", parser.isSet(kioskOption));
|
||||
engine->rootContext()->setContextProperty("autoConnectHost", parser.value(connectOption));
|
||||
|
||||
engine->rootContext()->setContextProperty("systemProductType", QSysInfo::productType());
|
||||
|
||||
|
||||
@ -105,8 +105,10 @@ Item {
|
||||
|
||||
Component.onCompleted: {
|
||||
setupPushNotifications();
|
||||
|
||||
if (tabSettings.lastConnectedHost.length > 0) {
|
||||
if (autoConnectHost.length > 0) {
|
||||
var host = discovery.nymeaHosts.createLanHost("Manual connection", autoConnectHost);
|
||||
engine.connection.connect(host)
|
||||
} else if (tabSettings.lastConnectedHost.length > 0) {
|
||||
print("Last connected host was", tabSettings.lastConnectedHost)
|
||||
var cachedHost = discovery.nymeaHosts.find(tabSettings.lastConnectedHost);
|
||||
if (cachedHost) {
|
||||
|
||||
@ -12,7 +12,6 @@ Page {
|
||||
|
||||
Component.onCompleted: {
|
||||
print("Ready to connect")
|
||||
|
||||
pageStack.push(discoveryPage, StackView.Immediate)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user