diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2021-12-16 13:54:03 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-12-16 20:58:52 +0100 |
commit | c2317a1f99ff778010385aad11745eb75d6a1900 (patch) | |
tree | e58ed853022036130aece07baf62c14d38f68ac9 | |
parent | a114b25c5720cedc93bec36e4fa822fe6cfa85b4 (diff) |
[bug] fix osx quits from app menu and dock
aboutToQuit let us catch Quits coming from the osx menu or the dock.
-rw-r--r-- | gui/components/MainView.qml | 12 | ||||
-rw-r--r-- | gui/components/StatusBox.qml | 11 | ||||
-rw-r--r-- | gui/components/Systray.qml | 6 | ||||
-rw-r--r-- | gui/main.cpp | 6 | ||||
-rw-r--r-- | pkg/helper/darwin.go | 12 |
5 files changed, 25 insertions, 22 deletions
diff --git a/gui/components/MainView.qml b/gui/components/MainView.qml index 886e896..946e36f 100644 --- a/gui/components/MainView.qml +++ b/gui/components/MainView.qml @@ -48,36 +48,36 @@ Page { ListElement { text: qsTr("Preferences") icon: "../resources/tools.svg" - triggered: function () { + triggered: function() { stackView.push("Preferences.qml") } } ListElement { text: qsTr("Donate") icon: "../resources/donate.svg" - triggered: function () { + triggered: function() { Qt.openUrlExternally(ctx.donateURL) } } ListElement { text: qsTr("Help") icon: "../resources/help.svg" - triggered: function () { + triggered: function() { stackView.push("Help.qml") } } // -> can link to another dialog with report bug / support / contribute / FAQ ListElement { text: qsTr("About") icon: "../resources/about.svg" - triggered: function () { + triggered: function() { stackView.push("About.qml") } } ListElement { text: qsTr("Quit") icon: "../resources/quit.svg" - triggered: function () { - backend.quit() + triggered: function() { + Qt.callLater(backend.quit) } } } // end listmodel diff --git a/gui/components/StatusBox.qml b/gui/components/StatusBox.qml index bfcc175..7715123 100644 --- a/gui/components/StatusBox.qml +++ b/gui/components/StatusBox.qml @@ -56,13 +56,6 @@ Item { } onClicked: { settingsDrawer.toggle() - /* - if (stackView.depth > 1) { - stackView.pop() - } else { - settingsDrawer.toggle() - } - */ } Icon { @@ -71,10 +64,6 @@ Item { height: 16 anchors.centerIn: settingsButton source: "../resources/gear-fill.svg" - /* - source: stackView.depth - > 1 ? "../resources/arrow-left.svg" : "../resources/gear-fill.svg" - */ } } diff --git a/gui/components/Systray.qml b/gui/components/Systray.qml index f25860c..1026f01 100644 --- a/gui/components/Systray.qml +++ b/gui/components/Systray.qml @@ -53,9 +53,11 @@ Labs.SystemTrayIcon { } Labs.MenuItem { - //: Part of the systray menu; quits que application + //: Part of the systray menu; quits the application text: qsTr("Quit") - onTriggered: backend.quit() + onTriggered: { + backend.quit() + } } } diff --git a/gui/main.cpp b/gui/main.cpp index fe96caa..1cb2d0e 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -48,7 +48,6 @@ QString getAppName(QJsonValue info, QString provider) { auto handler = [](int sig) -> void { printf("\nCatched signal(%d): quitting\n", sig); - Quit(); QApplication::quit(); }; @@ -82,6 +81,11 @@ int main(int argc, char **argv) { app.setQuitOnLastWindowClosed(false); app.setAttribute(Qt::AA_UseHighDpiPixmaps); + QObject::connect(&app, &QApplication::aboutToQuit, []() { + qDebug() << ">>> Quitting, bye!"; + Quit(); + }); + #ifdef OS_WIN signal(SIGINT, handler); signal(SIGTERM, handler); diff --git a/pkg/helper/darwin.go b/pkg/helper/darwin.go index a9f8e00..2db92a5 100644 --- a/pkg/helper/darwin.go +++ b/pkg/helper/darwin.go @@ -36,6 +36,7 @@ import ( "path/filepath" "strconv" "strings" + "time" "github.com/sevlyar/go-daemon" ) @@ -135,9 +136,16 @@ func firewallStop() error { log.Printf("An error ocurred stopping the firewall: %v", out) /* TODO return error if different from anchor not exists */ /*return errors.New("Error while stopping firewall")*/ - return nil } - return nil + for _ = range [50]int{} { + if firewallIsUp() { + log.Printf("Firewall still up, waiting...") + time.Sleep(200 * time.Millisecond) + } else { + return nil + } + } + return errors.New("Could not stop firewall") } func firewallIsUp() bool { |