From 1e3631c9a21f99e08bbb4bace61590b1221bc9f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Mon, 11 Mar 2013 10:24:25 -0300 Subject: Add AutoLogin checkbox --- src/leap/gui/mainwindow.py | 17 +++++++++++++++-- src/leap/gui/ui/mainwindow.ui | 38 ++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 16 deletions(-) (limited to 'src/leap') diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index 68c73e4d..399a7cb4 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -48,10 +48,13 @@ class MainWindow(QtGui.QMainWindow): LOGIN_INDEX = 0 EIP_STATUS_INDEX = 1 + # Settings GEOMETRY_KEY = "Geometry" WINDOWSTATE_KEY = "WindowState" USER_KEY = "User" + AUTOLOGIN_KEY = "AutoLogin" + # Keyring KEYRING_KEY = "leap_client" def __init__(self): @@ -202,15 +205,22 @@ class MainWindow(QtGui.QMainWindow): else: settings = QtCore.QSettings() saved_user = settings.value(self.USER_KEY, None) + auto_login = settings.value(self.AUTOLOGIN_KEY, None) if saved_user is not None: self.ui.lnUser.setText(saved_user) self.ui.chkRemember.setChecked(True) + self.ui.chkAutoLogin.setEnabled(True) saved_password = keyring.get_password(self.KEYRING_KEY, saved_user .encode("utf8")) self.ui.lnPassword.setText(saved_password.decode("utf8")) + # Only automatically login if there is a saved user + if auto_login is not None: + self.ui.chkAutoLogin.setChecked(True) + self._login() + def _show_systray(self): """ Sets up the systray icon @@ -315,6 +325,7 @@ class MainWindow(QtGui.QMainWindow): settings = QtCore.QSettings() settings.setValue(self.GEOMETRY_KEY, self.saveGeometry()) settings.setValue(self.WINDOWSTATE_KEY, self.saveState()) + settings.setValue(self.AUTOLOGIN_KEY, self.ui.chkAutoLogin.isChecked()) QtGui.QMainWindow.closeEvent(self, e) def _configured_providers(self): @@ -378,6 +389,7 @@ class MainWindow(QtGui.QMainWindow): self.ui.lnPassword.setEnabled(enabled) self.ui.btnLogin.setEnabled(enabled) self.ui.chkRemember.setEnabled(enabled) + self.ui.chkAutoLogin.setEnabled(enabled) self.ui.cmbProviders.setEnabled(enabled) def _download_provider_config(self): @@ -458,6 +470,8 @@ class MainWindow(QtGui.QMainWindow): self._set_status(self.tr("Logging in...")) self._login_set_enabled(False) + settings = QtCore.QSettings() + if self.ui.chkRemember.isChecked(): try: keyring.set_password(self.KEYRING_KEY, @@ -465,7 +479,6 @@ class MainWindow(QtGui.QMainWindow): password.encode("utf8")) # Only save the username if it was saved correctly in # the keyring - settings = QtCore.QSettings() settings.setValue(self.USER_KEY, username) except Exception as e: logger.error("Problem saving data to keyring. %r" @@ -577,7 +590,7 @@ class MainWindow(QtGui.QMainWindow): """ selected_pixmap = self.ERROR_ICON tray_message = self.tr("Encryption is OFF") - if status in ("WAIT", "AUTH", "GET_CONFIG"): + if status in ("WAIT", "AUTH", "GET_CONFIG", "RECONNECTING"): selected_pixmap = self.CONNECTING_ICON elif status in ("CONNECTED"): tray_message = self.tr("Encryption is ON") diff --git a/src/leap/gui/ui/mainwindow.ui b/src/leap/gui/ui/mainwindow.ui index d8a6d37d..d723114c 100644 --- a/src/leap/gui/ui/mainwindow.ui +++ b/src/leap/gui/ui/mainwindow.ui @@ -70,13 +70,10 @@ - 1 + 0 - - - @@ -84,15 +81,11 @@ - - - - Login - - + + - - + + Qt::Horizontal @@ -104,8 +97,15 @@ - - + + + + Login + + + + + Qt::Horizontal @@ -167,6 +167,16 @@ + + + + false + + + Automatically login + + + -- cgit v1.2.3