summaryrefslogtreecommitdiff
path: root/src/leap/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui')
-rw-r--r--src/leap/gui/login.py6
-rw-r--r--src/leap/gui/mainwindow.py65
2 files changed, 41 insertions, 30 deletions
diff --git a/src/leap/gui/login.py b/src/leap/gui/login.py
index 3c994597..de0b2d50 100644
--- a/src/leap/gui/login.py
+++ b/src/leap/gui/login.py
@@ -197,18 +197,18 @@ class LoginWidget(QtGui.QWidget):
"""
self.ui.lnUser.setEnabled(enabled)
self.ui.lnPassword.setEnabled(enabled)
- self.ui.btnLogin.setEnabled(enabled)
self.ui.chkRemember.setEnabled(enabled)
self.ui.cmbProviders.setEnabled(enabled)
- def set_cancel(self, enabled=False):
+ self._set_cancel(not enabled)
+
+ def _set_cancel(self, enabled=False):
"""
Enables or disables the cancel action in the "log in" process.
:param enabled: wether it should be enabled or not
:type enabled: bool
"""
- self.ui.btnLogin.setEnabled(enabled)
text = self.tr("Cancel")
login_or_cancel = self.cancel_login
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index 8195d23a..130437bf 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -582,13 +582,7 @@ class MainWindow(QtGui.QMainWindow):
Displays the context menu from the tray icon
"""
- get_action = lambda visible: (
- self.tr("Show Main Window"),
- self.tr("Hide Main Window"))[int(visible)]
-
- # set labels
- visible = self.isVisible()
- self._action_visible.setText(get_action(visible))
+ self._update_hideshow_menu()
context_menu = self._systray.contextMenu()
if not IS_MAC:
@@ -598,6 +592,19 @@ class MainWindow(QtGui.QMainWindow):
# this works however.
context_menu.exec_(self._systray.geometry().center())
+ def _update_hideshow_menu(self):
+ """
+ Updates the Hide/Show main window menu text based on the
+ visibility of the window.
+ """
+ get_action = lambda visible: (
+ self.tr("Show Main Window"),
+ self.tr("Hide Main Window"))[int(visible)]
+
+ # set labels
+ visible = self.isVisible()
+ self._action_visible.setText(get_action(visible))
+
def _toggle_visible(self):
"""
SLOT
@@ -611,6 +618,8 @@ class MainWindow(QtGui.QMainWindow):
else:
self.hide()
+ self._update_hideshow_menu()
+
def _center_window(self):
"""
Centers the mainwindow based on the desktop geometry
@@ -797,7 +806,6 @@ class MainWindow(QtGui.QMainWindow):
self._login_widget.set_status(self.tr("Logging in..."), error=False)
self._login_widget.set_enabled(False)
- self._login_widget.set_cancel(True)
if self._login_widget.get_remember() and has_keyring():
# in the keyring and in the settings
@@ -825,7 +833,6 @@ class MainWindow(QtGui.QMainWindow):
Stops the login sequence.
"""
logger.debug("Cancelling log in.")
- self._login_widget.set_cancel(False)
if self._download_provider_defer:
logger.debug("Cancelling download provider defer.")
@@ -1225,29 +1232,34 @@ class MainWindow(QtGui.QMainWindow):
loaded
"""
leap_assert(self._eip_config, "We need an eip config!")
+ passed = data[self._eip_bootstrapper.PASSED_KEY]
+
+ if not passed:
+ error_msg = self.tr("There was a problem with the provider")
+ self._status_panel.set_eip_status(error_msg, error=True)
+ logger.error(data[self._eip_bootstrapper.ERROR_KEY])
+ self._already_started_eip = False
+ return
provider_config = self._get_best_provider_config()
domain = provider_config.get_domain()
- if data[self._eip_bootstrapper.PASSED_KEY] and \
- (self._eip_config.loaded() or
- self._eip_config.load(os.path.join("leap",
- "providers",
- domain,
- "eip-service.json"))):
- self._start_eip()
+ loaded = self._eip_config.loaded()
+ if not loaded:
+ eip_config_path = os.path.join("leap", "providers",
+ domain, "eip-service.json")
+ api_version = provider_config.get_api_version()
+ self._eip_config.set_api_version(api_version)
+ loaded = self._eip_config.load(eip_config_path)
+
+ if loaded:
+ self._start_eip()
else:
- if data[self._eip_bootstrapper.PASSED_KEY]:
- self._status_panel.set_eip_status(
- self.tr("Could not load Encrypted Internet "
- "Configuration."),
- error=True)
- else:
- self._status_panel.set_eip_status(
- data[self._eip_bootstrapper.ERROR_KEY],
- error=True)
- self._already_started_eip = False
+ self._status_panel.set_eip_status(
+ self.tr("Could not load Encrypted Internet "
+ "Configuration."),
+ error=True)
def _logout(self):
"""
@@ -1290,7 +1302,6 @@ class MainWindow(QtGui.QMainWindow):
"""
passed = data[self._provider_bootstrapper.PASSED_KEY]
if not passed:
- self._login_widget.set_cancel(False)
self._login_widget.set_enabled(True)
self._login_widget.set_status(
self.tr("Unable to connect: Problem with provider"))