summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-11 10:24:25 -0300
committerTomás Touceda <chiiph@leap.se>2013-03-11 10:24:25 -0300
commit1e3631c9a21f99e08bbb4bace61590b1221bc9f1 (patch)
treeea798bb1a8d6989ebef40d08538b531c3d6b9dcb
parent34243a55d2483ed4a3d67e25c7212b4a13c5d41a (diff)
Add AutoLogin checkbox
-rw-r--r--src/leap/gui/mainwindow.py17
-rw-r--r--src/leap/gui/ui/mainwindow.ui38
2 files changed, 39 insertions, 16 deletions
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 @@
<item row="2" column="0" colspan="5">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
- <number>1</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_2">
- <item row="2" column="2" colspan="2">
- <widget class="QLineEdit" name="lnUser"/>
- </item>
<item row="4" column="2">
<widget class="QCheckBox" name="chkRemember">
<property name="text">
@@ -84,15 +81,11 @@
</property>
</widget>
</item>
- <item row="5" column="2">
- <widget class="QPushButton" name="btnLogin">
- <property name="text">
- <string>Login</string>
- </property>
- </widget>
+ <item row="2" column="2" colspan="2">
+ <widget class="QLineEdit" name="lnUser"/>
</item>
- <item row="2" column="4">
- <spacer name="horizontalSpacer_4">
+ <item row="2" column="0">
+ <spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -104,8 +97,15 @@
</property>
</spacer>
</item>
- <item row="2" column="0">
- <spacer name="horizontalSpacer_3">
+ <item row="6" column="2">
+ <widget class="QPushButton" name="btnLogin">
+ <property name="text">
+ <string>Login</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -167,6 +167,16 @@
</property>
</widget>
</item>
+ <item row="5" column="2" colspan="2">
+ <widget class="QCheckBox" name="chkAutoLogin">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Automatically login</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="page_2">