diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-08-15 10:32:37 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-08-15 10:32:37 -0300 |
commit | e8c028f3eb6cd0681f039c456dc1ac45c98d598f (patch) | |
tree | b7e84ebafad106726308d3c87f58ad1d900d66d7 /src/leap/bitmask/gui/login.py | |
parent | 159dbe295148975bdfe9a50f871254aa9adf2328 (diff) | |
parent | fb9bad95cc4bd2769af5f91c2f0cac1be4c3c617 (diff) |
Merge branch 'release-0.6.1'0.6.1
Diffstat (limited to 'src/leap/bitmask/gui/login.py')
-rw-r--r-- | src/leap/bitmask/gui/login.py | 77 |
1 files changed, 10 insertions, 67 deletions
diff --git a/src/leap/bitmask/gui/login.py b/src/leap/bitmask/gui/login.py index f66e71d9..2a79fafd 100644 --- a/src/leap/bitmask/gui/login.py +++ b/src/leap/bitmask/gui/login.py @@ -43,10 +43,6 @@ class LoginWidget(QtGui.QWidget): cancel_login = QtCore.Signal() logout = QtCore.Signal() - # Emitted when the user selects "Other..." in the provider - # combobox or click "Create Account" - show_wizard = QtCore.Signal() - MAX_STATUS_WIDTH = 40 # Keyring @@ -64,7 +60,6 @@ class LoginWidget(QtGui.QWidget): QtGui.QWidget.__init__(self, parent) self._settings = settings - self._selected_provider_index = -1 self.ui = Ui_LoginWidget() self.ui.setupUi(self) @@ -80,9 +75,6 @@ class LoginWidget(QtGui.QWidget): self.ui.lnUser.returnPressed.connect(self._focus_password) - self.ui.cmbProviders.currentIndexChanged.connect( - self._current_provider_changed) - self.ui.btnLogout.clicked.connect( self.logout) @@ -111,35 +103,6 @@ class LoginWidget(QtGui.QWidget): enable = True if state == QtCore.Qt.Checked else False self._settings.set_remember(enable) - def set_providers(self, provider_list): - """ - Set the provider list to provider_list plus an "Other..." item - that triggers the wizard - - :param provider_list: list of providers - :type provider_list: list of str - """ - self.ui.cmbProviders.blockSignals(True) - self.ui.cmbProviders.clear() - self.ui.cmbProviders.addItems(provider_list + [self.tr("Other...")]) - self.ui.cmbProviders.blockSignals(False) - - def select_provider_by_name(self, name): - """ - Given a provider name/domain, it selects it in the combobox - - :param name: name or domain for the provider - :type name: str - """ - provider_index = self.ui.cmbProviders.findText(name) - self.ui.cmbProviders.setCurrentIndex(provider_index) - - def get_selected_provider(self): - """ - Returns the selected provider in the combobox - """ - return self.ui.cmbProviders.currentText() - def set_remember(self, value): """ Checks the remember user and password checkbox @@ -216,8 +179,7 @@ class LoginWidget(QtGui.QWidget): """ self.ui.lnUser.setEnabled(enabled) self.ui.lnPassword.setEnabled(enabled) - self.ui.chkRemember.setEnabled(enabled) - self.ui.cmbProviders.setEnabled(enabled) + self.ui.chkRemember.setEnabled(enabled and has_keyring()) self._set_cancel(not enabled) @@ -258,41 +220,20 @@ class LoginWidget(QtGui.QWidget): """ self.ui.lnPassword.setFocus() - @QtCore.Slot(int) - def _current_provider_changed(self, idx): - """ - TRIGGERS: - self.ui.cmbProviders.currentIndexChanged - - :param idx: the index of the new selected item - :type idx: int - """ - if idx == (self.ui.cmbProviders.count() - 1): - self.show_wizard.emit() - # Leave the previously selected provider in the combobox - prev_provider = 0 - if self._selected_provider_index != -1: - prev_provider = self._selected_provider_index - self.ui.cmbProviders.blockSignals(True) - self.ui.cmbProviders.setCurrentIndex(prev_provider) - self.ui.cmbProviders.blockSignals(False) - else: - self._selected_provider_index = idx - - def start_login(self): + def start_login(self, provider): """ Setups the login widgets for actually performing the login and performs some basic checks. + :param provider: the domain of the current provider + :type provider: unicode str :returns: True if everything's good to go, False otherwise :rtype: bool """ username = self.get_user() password = self.get_password() - provider = self.get_selected_provider() - self._enabled_services = self._settings.get_enabled_services( - self.get_selected_provider()) + self._enabled_services = self._settings.get_enabled_services(provider) if len(provider) == 0: self.set_status( @@ -331,14 +272,16 @@ class LoginWidget(QtGui.QWidget): % (e,)) return True - def logged_in(self): + def logged_in(self, provider): """ Sets the widgets to the logged in state + + :param provider: the domain of the current provider + :type provider: unicode str """ self.ui.login_widget.hide() self.ui.logged_widget.show() - self.ui.lblUser.setText(make_address( - self.get_user(), self.get_selected_provider())) + self.ui.lblUser.setText(make_address(self.get_user(), provider)) if flags.OFFLINE is False: self.logged_in_signal.emit() |