From 7001408dd893b5e8302c4ff8a0dfe63f50e283fa Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 15 Aug 2013 15:25:43 -0300 Subject: Add preferences panel. --- Makefile | 2 +- src/leap/bitmask/gui/mainwindow.py | 20 +++ src/leap/bitmask/gui/preferenceswindow.py | 40 ++++++ src/leap/bitmask/gui/ui/mainwindow.ui | 10 ++ src/leap/bitmask/gui/ui/preferences.ui | 219 ++++++++++++++++++++++++++++++ 5 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 src/leap/bitmask/gui/preferenceswindow.py create mode 100644 src/leap/bitmask/gui/ui/preferences.ui diff --git a/Makefile b/Makefile index 011c060e..4f4d77c4 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ TRANSLAT_DIR = data/translations PROJFILE = data/bitmask.pro #UI files to compile -UI_FILES = loggerwindow.ui mainwindow.ui wizard.ui login.ui statuspanel.ui +UI_FILES = loggerwindow.ui mainwindow.ui wizard.ui login.ui statuspanel.ui preferences.ui #Qt resource files to compile RESOURCES = locale.qrc loggerwindow.qrc mainwindow.qrc icons.qrc diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 17275983..5447d993 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -33,6 +33,7 @@ from leap.bitmask.config.leapsettings import LeapSettings from leap.bitmask.config.providerconfig import ProviderConfig from leap.bitmask.crypto.srpauth import SRPAuth from leap.bitmask.gui.loggerwindow import LoggerWindow +from leap.bitmask.gui.preferenceswindow import PreferencesWindow from leap.bitmask.gui.wizard import Wizard from leap.bitmask.gui.login import LoginWidget from leap.bitmask.gui.statuspanel import StatusPanelWidget @@ -162,6 +163,7 @@ class MainWindow(QtGui.QMainWindow): self._launch_wizard) self.ui.btnShowLog.clicked.connect(self._show_logger_window) + self.ui.btnPreferences.clicked.connect(self._show_preferences) self._status_panel = StatusPanelWidget( self.ui.stackedWidget.widget(self.EIP_STATUS_INDEX)) @@ -292,6 +294,7 @@ class MainWindow(QtGui.QMainWindow): self._wizard_firstrun = False self._logger_window = None + self._preferences_window = None self._bypass_checks = bypass_checks @@ -403,6 +406,21 @@ class MainWindow(QtGui.QMainWindow): self._logger_window.finished.connect(self._uncheck_logger_button) + def _show_preferences(self): + """ + SLOT + TRIGGERS: + self.ui.action_show_preferences.triggered + self.ui.btnPreferences.clicked + + Displays the preferences window. + """ + preferences = self._preferences_window + if preferences is None: + preferences = PreferencesWindow(self, self._srp_auth) + + preferences.show() + def _uncheck_logger_button(self): """ SLOT @@ -925,6 +943,7 @@ class MainWindow(QtGui.QMainWindow): # panel QtCore.QTimer.singleShot(1000, self._switch_to_status) self._login_defer = None + self.ui.btnPreferences.setEnabled(True) else: self._login_widget.set_enabled(True) @@ -1399,6 +1418,7 @@ class MainWindow(QtGui.QMainWindow): self._login_widget.set_password("") self._login_widget.set_enabled(True) self._login_widget.set_status("") + self.ui.btnPreferences.setEnabled(False) def _intermediate_stage(self, data): """ diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py new file mode 100644 index 00000000..5f8dd5cc --- /dev/null +++ b/src/leap/bitmask/gui/preferenceswindow.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# preferenceswindow.py +# Copyright (C) 2013 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +Preferences log window +""" +import logging + +from PySide import QtGui + +from leap.bitmask.gui.ui_preferences import Ui_Preferences +from leap.bitmask.crypto.srpauth import SRPAuthBadPassword + +logger = logging.getLogger(__name__) + + +class PreferencesWindow(QtGui.QDialog): + """ + Window that displays the preferences. + """ + def __init__(self, parent): + QtGui.QDialog.__init__(self, parent) + + # Load UI + self.ui = Ui_Preferences() + self.ui.setupUi(self) diff --git a/src/leap/bitmask/gui/ui/mainwindow.ui b/src/leap/bitmask/gui/ui/mainwindow.ui index b46b62b0..834a562e 100644 --- a/src/leap/bitmask/gui/ui/mainwindow.ui +++ b/src/leap/bitmask/gui/ui/mainwindow.ui @@ -214,6 +214,16 @@ + + + + false + + + Preferences + + + diff --git a/src/leap/bitmask/gui/ui/preferences.ui b/src/leap/bitmask/gui/ui/preferences.ui new file mode 100644 index 00000000..ffca381e --- /dev/null +++ b/src/leap/bitmask/gui/ui/preferences.ui @@ -0,0 +1,219 @@ + + + Preferences + + + + 0 + 0 + 451 + 267 + + + + Preferences + + + + :/images/mask-icon.png:/images/mask-icon.png + + + + + + Password Change + + + + QFormLayout::ExpandingFieldsGrow + + + + + &Current password: + + + leCurrentPassword + + + + + + + QLineEdit::Password + + + + + + + &New password: + + + leNewPassword + + + + + + + QLineEdit::Password + + + + + + + &Re-enter new password: + + + leNewPassword2 + + + + + + + QLineEdit::Password + + + + + + + Change + + + + + + + <Password change status> + + + Qt::AlignCenter + + + + + + + + + + false + + + Select gateway for provider + + + false + + + + + + &Select provider: + + + cbProviders + + + + + + + + <Select provider> + + + + + + + + Select gateway: + + + + + + + + Automatic + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + leCurrentPassword + returnPressed() + leNewPassword + setFocus() + + + 273 + 113 + + + 272 + 135 + + + + + leNewPassword + returnPressed() + leNewPassword2 + setFocus() + + + 349 + 139 + + + 351 + 163 + + + + + leNewPassword2 + returnPressed() + pbChangePassword + setFocus() + + + 178 + 169 + + + 178 + 198 + + + + + -- cgit v1.2.3