From 20266b063c1be8818d4582bff7b59486551ee447 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Wed, 17 Jun 2020 21:14:35 +0200 Subject: [feat] pass initialization errors to gui --- gui/backend.go | 1 - gui/main.cpp | 2 +- gui/qml/main.qml | 22 +++++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'gui') diff --git a/gui/backend.go b/gui/backend.go index edb2b17..92cda6e 100644 --- a/gui/backend.go +++ b/gui/backend.go @@ -30,7 +30,6 @@ func Unblock() { //export Quit func Quit() { backend.Quit() - } //export DonateAccepted diff --git a/gui/main.cpp b/gui/main.cpp index eca834a..670e664 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -34,7 +34,7 @@ std::string getEnv(std::string const& key) return val == NULL ? std::string() : std::string(val); } -void signalHandler(int signum) { +void signalHandler(int) { Quit(); exit(0); } diff --git a/gui/qml/main.qml b/gui/qml/main.qml index 8d756c6..efcfef2 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -11,7 +11,6 @@ ApplicationWindow { property var ctx - Connections { target: jsonModel onDataChanged: { @@ -20,9 +19,24 @@ ApplicationWindow { console.debug(jsonModel.getJson()) donate.visible = true } + if (ctx.errors ) { + // TODO consider disabling on/off buttons, or quit after closing the dialog + if ( ctx.errors == "nohelpers" ) { + showInitFailure(qsTr("Could not find helpers. Check your installation")) + } else if ( ctx.errors == "nopolkit" ) { + showInitFailure(qsTr("Could not find polkit agent.")) + } else { + console.debug(ctx.errors) + } + } } } + function showInitFailure(msg) { + initFailure.text = msg + initFailure.visible = true + } + Component.onCompleted: { /* stupid as it sounds, windows doesn't like to have the systray icon not being attached to an actual application window. @@ -210,9 +224,6 @@ ApplicationWindow { text: "" detailedText: "" visible: false - //text: ctx ? qsTr("Can't connect to %1").arg(ctx.appName) : "" - //detailedText: ctx ? ctx.errorStartingMsg : "" - //visible: ctx.errorStartingMsg != "" } MessageDialog { @@ -222,7 +233,6 @@ ApplicationWindow { title: qsTr("Missing authentication agent") text: qsTr("Could not find a polkit authentication agent. Please run one and try again.") visible: false - //visible: ctx.missingAuthAgent == "true" } MessageDialog { @@ -232,7 +242,5 @@ ApplicationWindow { title: qsTr("Initialization Error") text: "" visible: false - //text: ctx ? ctx.errorInitMsg : "" - //visible: ctx.errorInitMsg != "" } } -- cgit v1.2.3