summaryrefslogtreecommitdiff
path: root/src/leap/gui/mainwindow.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui/mainwindow.py')
-rw-r--r--src/leap/gui/mainwindow.py58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index 3f29f957..3fa3aad3 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -18,30 +18,33 @@
"""
Main window for the leap client
"""
-import os
import logging
+import os
+import platform
import tempfile
-import keyring
-
-from PySide import QtCore, QtGui
from functools import partial
-from ui_mainwindow import Ui_MainWindow
+import keyring
+from PySide import QtCore, QtGui
from leap.common.check import leap_assert
from leap.config.leapsettings import LeapSettings
from leap.config.providerconfig import ProviderConfig
from leap.crypto.srpauth import SRPAuth
+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.initializers import init_platform
from leap.services.eip.vpn import VPN
from leap.services.eip.vpnlaunchers import (VPNLauncherException,
OpenVPNNotFoundException,
EIPNoPkexecAvailable,
EIPNoPolkitAuthAgentAvailable)
-from leap.services.eip.providerbootstrapper import ProviderBootstrapper
-from leap.services.eip.eipbootstrapper import EIPBootstrapper
-from leap.services.eip.eipconfig import EIPConfig
-from leap.gui.wizard import Wizard
-from leap.util.checkerthread import CheckerThread
from leap.util import __version__ as VERSION
+from leap.util.checkerthread import CheckerThread
+
+from ui_mainwindow import Ui_MainWindow
+
logger = logging.getLogger(__name__)
@@ -178,11 +181,11 @@ class MainWindow(QtGui.QMainWindow):
self._stop_eip)
self._action_eip_write = QtGui.QAction(
QtGui.QIcon(":/images/Arrow-Up-32.png"),
- "0.0 Kb", self)
+ "%12.2f Kb" % (0.0,), self)
self._action_eip_write.setEnabled(False)
self._action_eip_read = QtGui.QAction(
QtGui.QIcon(":/images/Arrow-Down-32.png"),
- "0.0 Kb", self)
+ "%12.2f Kb" % (0.0,), self)
self._action_eip_read.setEnabled(False)
self._action_visible = QtGui.QAction(self.tr("Hide"), self)
@@ -192,6 +195,9 @@ class MainWindow(QtGui.QMainWindow):
self._settings = LeapSettings(standalone)
self._center_window()
+
+ init_platform()
+
self._wizard = None
self._wizard_firstrun = False
if self._first_run():
@@ -287,18 +293,19 @@ class MainWindow(QtGui.QMainWindow):
self._vpn_systray.setIcon(QtGui.QIcon(self.ERROR_ICON))
self._vpn_systray.setVisible(False)
- def _toggle_visible(self):
+ def _toggle_visible(self, reason=None):
"""
SLOT
TRIGGER: self._systray.activated
Toggles the window visibility
"""
- self.setVisible(not self.isVisible())
- action_visible_text = self.tr("Hide")
- if not self.isVisible():
- action_visible_text = self.tr("Show")
- self._action_visible.setText(action_visible_text)
+ if reason != QtGui.QSystemTrayIcon.Context:
+ self.setVisible(not self.isVisible())
+ action_visible_text = self.tr("Hide")
+ if not self.isVisible():
+ action_visible_text = self.tr("Show")
+ self._action_visible.setText(action_visible_text)
def _center_window(self):
"""
@@ -605,9 +612,14 @@ class MainWindow(QtGui.QMainWindow):
"""
# TODO: make this properly multiplatform
- host = os.path.join(tempfile.mkdtemp(prefix="leap-tmp"),
- 'openvpn.socket')
- port = "unix"
+
+ if platform.system() == "Windows":
+ host = "localhost"
+ port = "9876"
+ else:
+ host = os.path.join(tempfile.mkdtemp(prefix="leap-tmp"),
+ 'openvpn.socket')
+ port = "unix"
return host, port
@@ -746,12 +758,12 @@ class MainWindow(QtGui.QMainWindow):
"""
upload = float(data[self._vpn.TUNTAP_WRITE_KEY])
upload = upload / 1000.0
- upload_str = "%s Kb" % (upload,)
+ upload_str = "%12.2f Kb" % (upload,)
self.ui.lblUpload.setText(upload_str)
self._action_eip_write.setText(upload_str)
download = float(data[self._vpn.TUNTAP_READ_KEY])
download = download / 1000.0
- download_str = "%s Kb" % (download,)
+ download_str = "%12.2f Kb" % (download,)
self.ui.lblDownload.setText(download_str)
self._action_eip_read.setText(download_str)