summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/app.py19
-rw-r--r--src/leap/baseapp/mainwindow.py1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index 4dd93600..c88ca913 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -1,15 +1,23 @@
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
+from functools import partial
import logging
+import signal
# This is only needed for Python v2 but is harmless for Python v3.
import sip
sip.setapi('QVariant', 2)
sip.setapi('QString', 2)
from PyQt4.QtGui import (QApplication, QSystemTrayIcon, QMessageBox)
+from PyQt4.QtCore import QTimer
+from PyQt4 import QtCore
from leap import __version__ as VERSION
from leap.baseapp.mainwindow import LeapWindow
+def sigint_handler(*args):
+ #import pdb4qt as pdb; pdb.set_trace()
+ app = args[0]
+ app.cleanupAndQuit()
def main():
"""
@@ -52,6 +60,10 @@ def main():
logger.info('Starting app')
app = QApplication(sys.argv)
+ timer = QTimer()
+ timer.start(500)
+ timer.timeout.connect(lambda: None)
+
# needed for initializing qsettings
# it will write .config/leap/leap.conf
# top level app settings
@@ -69,6 +81,13 @@ def main():
QApplication.setQuitOnLastWindowClosed(False)
window = LeapWindow(opts)
+
+ sigint_window = partial(sigint_handler, window)
+ signal.signal(signal.SIGINT, sigint_window)
+ #signal.signal(signal.SIGINT, lambda: QtCore.QMetaObject.invokeMethod(window, 'cleanupAndQuit'))
+ #window.shutdownSignal.connect(window.cleanupAndQuit)
+ #signal.signal(signal.SIGINT, window.shutdownSignal.emit))
+
if debug:
# we only show the main window
# if debug mode active.
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index f07ebb7d..85185ca6 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -40,6 +40,7 @@ class LeapWindow(QtGui.QMainWindow,
networkError = QtCore.pyqtSignal([object])
triggerEIPError = QtCore.pyqtSignal([object])
start_eipconnection = QtCore.pyqtSignal([])
+ shutdownSignal = QtCore.pyqtSignal([])
# this is status change got from openvpn management
openvpnStatusChange = QtCore.pyqtSignal([object])