summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-04-19 19:23:13 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-04-19 19:23:13 +0200
commit96f1cd6d95de3226ce9ef24c8927993d5d2a7f22 (patch)
tree2f77bb4f045851b071891e35590e46b90b7d1f4b /src/leap
parentedb5249b12bc88472f7a9fad6c755bac4afbaccc (diff)
[feature] expose gui shutdown to js
- Resolves: #8837
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/gui/app.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/leap/bitmask/gui/app.py b/src/leap/bitmask/gui/app.py
index 52598cb..0f98fa7 100644
--- a/src/leap/bitmask/gui/app.py
+++ b/src/leap/bitmask/gui/app.py
@@ -61,9 +61,18 @@ DEBUG = os.environ.get("DEBUG", False)
qApp = None
bitmaskd = None
+browser = None
class BrowserWindow(QWebView):
+ """
+ This qt-webkit window exposes a couple of callable objects through the
+ python-js bridge:
+
+ bitmaskApp.shutdown() -> shut downs the backend and frontend.
+ bitmaskBrowser.openPixelated() -> opens Pixelated app in a new window.
+
+ """
def __init__(self, *args, **kw):
url = kw.pop('url', None)
first = False
@@ -80,6 +89,10 @@ class BrowserWindow(QWebView):
self.bitmask_browser = NewPageConnector(self) if first else None
self.loadPage(self.url)
+ self.proxy = AppProxy(self) if first else None
+ self.frame.addToJavaScriptWindowObject(
+ "bitmaskApp", self.proxy)
+
def loadPage(self, web_page):
self.settings().setAttribute(
QWebSettings.DeveloperExtrasEnabled, True)
@@ -125,6 +138,16 @@ class BrowserWindow(QWebView):
sys.exit(1)
+class AppProxy(QObject):
+
+ @pyqtSlot()
+ def shutdown(self):
+ """To be exposed from the js bridge"""
+ global browser
+ if browser:
+ browser.close()
+
+
pixbrowser = None
@@ -149,6 +172,7 @@ def _handle_kill(*args, **kw):
def launch_gui():
global qApp
global bitmaskd
+ global browser
if IS_WIN:
freeze_support()