~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

Viewing changes to ubuntu_sso/qt/gui.py

Fix pylint warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# with this program.  If not, see <http://www.gnu.org/licenses/>.
17
17
"""Qt implementation of the UI."""
18
18
 
19
 
from PyQt4 import Qt
20
19
from PyQt4.QtGui import (
21
20
    QApplication,
22
21
    QColor,
27
26
    QPushButton,
28
27
    QStyle,
29
28
    QWizard,
30
 
    QWizardPage,
31
 
    QGraphicsScene)
 
29
    QWizardPage)
32
30
 
33
31
from ubuntu_sso.logger import setup_logging
34
32
# pylint: disable=F0401,E0611
50
48
 
51
49
# colors used to define the password stenght
52
50
WEAK_COLOR = QColor(220, 20, 60)
53
 
MEDIUN_COLOR = QColor(255, 215, 0)
 
51
MEDIUM_COLOR = QColor(255, 215, 0)
54
52
STRONG_COLOR = QColor(50, 205, 50)
55
53
 
56
54
 
224
222
        # palettes that will be used to set the colors of the password strenght
225
223
        original_palette = self.ui.strenght_frame.palette()
226
224
        self._original_color = original_palette.background().color()
 
225
        self.next = -1
 
226
        self.captcha_id = None
 
227
        self.captcha_file = None
227
228
        self.controller = controller
228
229
        self.controller.setupUi(self)
229
 
        self.next = -1
230
 
        # create the scene to be used to show the captcha
231
 
        self.image = None
232
 
        self.image_file = None
233
 
        self.scene = QGraphicsScene(self.ui.captcha_view)
234
230
 
235
231
    def set_strenght_level(self, level, password):
236
232
        """Set the strenght level colors."""
348
344
        return self.ui.confirm_password_edit
349
345
 
350
346
    @property
 
347
    def captcha_refresh_label(self):
 
348
        """Return the refresh label."""
 
349
        return self.ui.refresh_label
 
350
 
 
351
    @property
351
352
    def captcha_solution(self):
352
353
        """Return the provided captcha solution."""
353
354
        return str(self.ui.captcha_solution_edit.text())
359
360
 
360
361
    def get_captcha_image(self):
361
362
        """Return the path to the captcha image."""
362
 
        return self.image_file
 
363
        return self.captcha_id
363
364
 
364
 
    def set_captcha_image(self, file_path):
 
365
    def set_captcha_image(self, data):
365
366
        """Set the new image of the captcha."""
366
 
        if self.image:
367
 
            self.scene.removeItem(self.image)
368
 
        self.image_file = file_path
369
 
        pix = QPixmap(self.image_file)
370
 
        self.image = self.scene.addPixmap(pix)
 
367
        self.captcha_id = data
 
368
        # lets set the QPixmap for the label
 
369
        pic = QPixmap(self.captcha_file)
 
370
        self.ui.captcha_view.setPixmap(pic)
371
371
 
372
372
    captcha_image = property(get_captcha_image, set_captcha_image)
373
373
 
416
416
        self.email_verification = EmailVerificationPage(
417
417
                                                Ui_EmailVerificationPage(),
418
418
                                                EmailVerificationController())
419
 
        self.current_user_controller = CurrentUserController(title='Sign in')
 
419
        self.current_user_controller = CurrentUserController(title='Sign in',
 
420
                                                            app_name=app_name)
420
421
        self.current_user = CurrentUserSignInPage(Ui_CurrentUserSignInPage(),
421
422
                                                  self.current_user_controller,
422
423
                                                  parent=self)
445
446
 
446
447
class UbuntuSSOClientGUI(object):
447
448
    """Ubuntu single sign-on GUI."""
448
 
 
449
 
if __name__ == '__main__':
450
 
    # pylint: disable=C0103
451
 
    # show the ui
452
 
    import sys
453
 
 
454
 
    app = Qt.QApplication(sys.argv)
455
 
 
456
 
    wizard = UbuntuSSOWizard()
457
 
    wizard.show()
458
 
    # Now we can start it.
459
 
    app.exec_()