summaryrefslogtreecommitdiff
path: root/gui/main.cpp
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-06-17 18:54:54 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-06-26 12:13:42 +0200
commit2bcaa8e89c2e76c2d14cf9f7f029e17d46c91e0f (patch)
tree9da47f4d83266df8782ca8a5baaced7a7e33aa95 /gui/main.cpp
parent253b12e140905d3a38bcd09d55b9c5dbf0601d66 (diff)
[feat] quit signal handler
Diffstat (limited to 'gui/main.cpp')
-rw-r--r--gui/main.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/gui/main.cpp b/gui/main.cpp
index 5ecd4ad..eca834a 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -1,10 +1,12 @@
+#include <csignal>
+#include <string>
+
#include <QApplication>
#include <QSystemTrayIcon>
#include <QTimer>
#include <QtQml>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
-#include <string>
#include "handlers.h"
#include "qjsonmodel.h"
@@ -32,7 +34,13 @@ std::string getEnv(std::string const& key)
return val == NULL ? std::string() : std::string(val);
}
+void signalHandler(int signum) {
+ Quit();
+ exit(0);
+}
+
int main(int argc, char **argv) {
+ signal(SIGINT, signalHandler);
bool debugQml = getEnv("DEBUG_QML_DATA") == "yes";
@@ -80,6 +88,7 @@ int main(int argc, char **argv) {
QGuiApplication::quit();
});
+
/* register statusChanged callback with CGO */
const char *stCh = "OnStatusChanged";
GoString statusChangedEvt = {stCh, (long int)strlen(stCh)};