summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-04-25 13:26:55 -0300
committerTomás Touceda <chiiph@leap.se>2014-04-25 13:26:55 -0300
commit558d33fb8ffb884834153b5b941c7425723f45b7 (patch)
treec73587186c7b94bf797dda5ce4c6b73c937eb8d6 /src
parent55d4f043ee457bc780c7ea37a6b8ded448b0abdd (diff)
parent0408e01474d43acf0aefcb6fb664d3e48a0faf0b (diff)
Merge remote-tracking branch 'refs/remotes/ivan/bug/5550_show-hide-services-according-provider' into develop
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/gui/eip_status.py14
-rw-r--r--src/leap/bitmask/gui/mainwindow.py51
-rw-r--r--src/leap/bitmask/gui/statemachines.py2
3 files changed, 54 insertions, 13 deletions
diff --git a/src/leap/bitmask/gui/eip_status.py b/src/leap/bitmask/gui/eip_status.py
index bc31b91d..ca28b8bf 100644
--- a/src/leap/bitmask/gui/eip_status.py
+++ b/src/leap/bitmask/gui/eip_status.py
@@ -260,11 +260,12 @@ class EIPStatusWidget(QtGui.QWidget):
self._service_name, self.tr("disabled")))
# Replace EIP tray menu with an action that displays a "disabled" text
- menu = self._systray.contextMenu()
- menu.insertAction(
- self._eip_status_menu.menuAction(),
- self._eip_disabled_action)
- self._eip_status_menu.menuAction().setVisible(False)
+ if self.isVisible():
+ menu = self._systray.contextMenu()
+ menu.insertAction(
+ self._eip_status_menu.menuAction(),
+ self._eip_disabled_action)
+ self._eip_status_menu.menuAction().setVisible(False)
@QtCore.Slot()
def enable_eip_start(self):
@@ -278,7 +279,8 @@ class EIPStatusWidget(QtGui.QWidget):
# Restore the eip action menu
menu = self._systray.contextMenu()
menu.removeAction(self._eip_disabled_action)
- self._eip_status_menu.menuAction().setVisible(True)
+ if self.isVisible():
+ self._eip_status_menu.menuAction().setVisible(True)
# XXX disable (later) --------------------------
def set_eip_status(self, status, error=False):
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index b49717c9..a5c81983 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -256,6 +256,8 @@ class MainWindow(QtGui.QMainWindow):
# self.ui.btnEIPPreferences.clicked.connect(self._show_eip_preferences)
self._enabled_services = []
+ self._ui_mx_visible = True
+ self._ui_eip_visible = True
# last minute UI manipulations
@@ -723,7 +725,7 @@ class MainWindow(QtGui.QMainWindow):
if IS_MAC:
self.raise_()
- self._hide_unsupported_services()
+ self._show_hide_unsupported_services()
if self._wizard:
possible_username = self._wizard.get_username()
@@ -765,7 +767,7 @@ class MainWindow(QtGui.QMainWindow):
if self._login_widget.load_user_from_keyring(saved_user):
self._login()
- def _hide_unsupported_services(self):
+ def _show_hide_unsupported_services(self):
"""
Given a set of configured providers, it creates a set of
available services among all of them and displays the service
@@ -786,8 +788,38 @@ class MainWindow(QtGui.QMainWindow):
for service in provider_config.get_services():
services.add(service)
- self.ui.eipWidget.setVisible(EIP_SERVICE in services)
- self.ui.mailWidget.setVisible(MX_SERVICE in services)
+ self._set_eip_visible(EIP_SERVICE in services)
+ self._set_mx_visible(MX_SERVICE in services)
+
+ def _set_mx_visible(self, visible):
+ """
+ Change the visibility of MX_SERVICE related UI components.
+
+ :param visible: whether the components should be visible or not.
+ :type visible: bool
+ """
+ # only update visibility if it is something to change
+ if self._ui_mx_visible ^ visible:
+ self.ui.mailWidget.setVisible(visible)
+ self.ui.lineUnderEmail.setVisible(visible)
+ self._action_mail_status.setVisible(visible)
+ self._ui_mx_visible = visible
+
+ def _set_eip_visible(self, visible):
+ """
+ Change the visibility of EIP_SERVICE related UI components.
+
+ :param visible: whether the components should be visible or not.
+ :type visible: bool
+ """
+ # NOTE: we use xor to avoid the code being run if the visibility hasn't
+ # changed. This is meant to avoid the eip menu being displayed floating
+ # around at start because the systray isn't rendered yet.
+ if self._ui_eip_visible ^ visible:
+ self.ui.eipWidget.setVisible(visible)
+ self.ui.lineUnderEIP.setVisible(visible)
+ self._eip_menu.setVisible(visible)
+ self._ui_eip_visible = visible
def _set_label_offline(self):
"""
@@ -824,7 +856,7 @@ class MainWindow(QtGui.QMainWindow):
systrayMenu.addSeparator()
eip_status_label = "{0}: {1}".format(self._eip_name, self.tr("OFF"))
- eip_menu = systrayMenu.addMenu(eip_status_label)
+ self._eip_menu = eip_menu = systrayMenu.addMenu(eip_status_label)
eip_menu.addAction(self._action_eip_startstop)
self._eip_status.set_eip_status_menu(eip_menu)
systrayMenu.addSeparator()
@@ -1186,7 +1218,7 @@ class MainWindow(QtGui.QMainWindow):
username = self._login_widget.get_user()
password = self._login_widget.get_password()
- self._hide_unsupported_services()
+ self._show_hide_unsupported_services()
domain = self._provider_config.get_domain()
self._backend.login(domain, username, password)
@@ -1221,6 +1253,9 @@ class MainWindow(QtGui.QMainWindow):
self._soledad_bootstrapper.soledad_failed.connect(
lambda: btn_enabled(True))
+ if not self._get_best_provider_config().provides_mx():
+ self._set_mx_visible(False)
+
def _start_eip_bootstrap(self):
"""
Changes the stackedWidget index to the EIP status one and
@@ -1521,7 +1556,7 @@ class MainWindow(QtGui.QMainWindow):
domain = provider_config.get_domain()
self._eip_status.set_provider(domain)
- self._settings.set_defaultprovider(provider)
+ self._settings.set_defaultprovider(domain)
self._already_started_eip = True
# check for connectivity
@@ -1950,6 +1985,8 @@ class MainWindow(QtGui.QMainWindow):
self._login_widget.logged_out()
self._mail_status.mail_state_disabled()
+ self._show_hide_unsupported_services()
+
@QtCore.Slot(dict)
def _intermediate_stage(self, data):
# TODO this method name is confusing as hell.
diff --git a/src/leap/bitmask/gui/statemachines.py b/src/leap/bitmask/gui/statemachines.py
index 93731ce0..31938a70 100644
--- a/src/leap/bitmask/gui/statemachines.py
+++ b/src/leap/bitmask/gui/statemachines.py
@@ -562,6 +562,8 @@ class ConnectionMachineBuilder(object):
if action:
off.assignProperty(
action, 'text', off_label)
+ off.assignProperty(
+ action, 'enabled', True)
off.setObjectName(_OFF)
states[_OFF] = off