summaryrefslogtreecommitdiff
path: root/src/leap/gui
diff options
context:
space:
mode:
authorTomas Touceda <chiiph@leap.se>2013-04-11 15:07:54 -0300
committerTomas Touceda <chiiph@leap.se>2013-04-11 15:07:54 -0300
commite0032a6c97b3ed766698521c76bc37d0655f4277 (patch)
tree7808ca6adc8babf42aab34b7cad4271780dda0a9 /src/leap/gui
parentb585cefa15a1d7a03dd8a6c5651220ac3fd94fd1 (diff)
parentcf6c30f6f046401dead7a990f56bf9ad2c7cfa01 (diff)
Merge remote-tracking branch 'kali/feature/single-instance-app2' into develop
Conflicts: src/leap/gui/mainwindow.py
Diffstat (limited to 'src/leap/gui')
-rw-r--r--src/leap/gui/mainwindow.py55
1 files changed, 49 insertions, 6 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index f84cb00c..bf8491d0 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -26,7 +26,10 @@ from functools import partial
import keyring
from PySide import QtCore, QtGui
+
from leap.common.check import leap_assert
+from leap.common.events import register
+from leap.common.events import events_pb2 as proto
from leap.config.leapsettings import LeapSettings
from leap.config.providerconfig import ProviderConfig
from leap.crypto.srpauth import SRPAuth
@@ -34,7 +37,7 @@ from leap.gui.wizard import Wizard
from leap.services.eip.eipbootstrapper import EIPBootstrapper
from leap.services.eip.eipconfig import EIPConfig
from leap.services.eip.providerbootstrapper import ProviderBootstrapper
-from leap.platform_init import IS_MAC
+from leap.platform_init import IS_MAC, IS_WIN
from leap.platform_init.initializers import init_platform
from leap.services.eip.vpn import VPN
from leap.services.eip.vpnlaunchers import (VPNLauncherException,
@@ -43,14 +46,9 @@ from leap.services.eip.vpnlaunchers import (VPNLauncherException,
EIPNoPolkitAuthAgentAvailable)
from leap.util import __version__ as VERSION
from leap.util.checkerthread import CheckerThread
-from leap.common.events import (
- register,
- events_pb2 as proto,
-)
from ui_mainwindow import Ui_MainWindow
-
logger = logging.getLogger(__name__)
@@ -66,7 +64,9 @@ class MainWindow(QtGui.QMainWindow):
# Keyring
KEYRING_KEY = "leap_client"
+ # Signals
new_updates = QtCore.Signal(object)
+ raise_window = QtCore.Signal([])
def __init__(self, standalone=False):
"""
@@ -78,8 +78,12 @@ class MainWindow(QtGui.QMainWindow):
"""
QtGui.QMainWindow.__init__(self)
+ # register leap events
register(signal=proto.UPDATER_NEW_UPDATES,
callback=self._new_updates_available)
+ register(signal=proto.RAISE_WINDOW,
+ callback=self._on_raise_window_event)
+
self._updates_content = ""
if IS_MAC:
@@ -122,6 +126,7 @@ class MainWindow(QtGui.QMainWindow):
self._standalone = standalone
self._provider_config = ProviderConfig()
self._eip_config = EIPConfig()
+
# This is created once we have a valid provider config
self._srp_auth = None
@@ -178,6 +183,10 @@ class MainWindow(QtGui.QMainWindow):
QtCore.QCoreApplication.instance(),
QtCore.SIGNAL("aboutToQuit()"),
self._checker_thread.wait)
+ QtCore.QCoreApplication.instance().connect(
+ QtCore.QCoreApplication.instance(),
+ QtCore.SIGNAL("aboutToQuit()"),
+ self._cleanup_pidfiles)
self.ui.chkRemember.stateChanged.connect(
self._remember_state_changed)
@@ -188,6 +197,7 @@ class MainWindow(QtGui.QMainWindow):
self.ui.action_about_leap.triggered.connect(self._about)
self.ui.action_quit.triggered.connect(self.quit)
self.ui.action_wizard.triggered.connect(self._launch_wizard)
+ self.raise_window.connect(self._do_raise_mainwindow)
# Used to differentiate between real quits and close to tray
self._really_quit = False
@@ -932,6 +942,39 @@ class MainWindow(QtGui.QMainWindow):
logger.debug("Finished VPN with exitCode %s" % (exitCode,))
self._stop_eip()
+ def _on_raise_window_event(self, req):
+ """
+ Callback for the raise window event
+ """
+ self.raise_window.emit()
+
+ def _do_raise_mainwindow(self):
+ """
+ SLOT
+ TRIGGERS:
+ self._on_raise_window_event
+
+ Triggered when we receive a RAISE_WINDOW event.
+ """
+ TOPFLAG = QtCore.Qt.WindowStaysOnTopHint
+ self.setWindowFlags(self.windowFlags() | TOPFLAG)
+ self.show()
+ self.setWindowFlags(self.windowFlags() & ~TOPFLAG)
+ self.show()
+
+ def _cleanup_pidfiles(self):
+ """
+ SLOT
+ TRIGGERS:
+ self.aboutToQuit
+
+ Triggered on about to quit signal, removes lockfiles on a clean
+ shutdown
+ """
+ if IS_WIN:
+ lockfile = WindowsLock()
+ lockfile.release_lock()
+
if __name__ == "__main__":
import signal