~diegosarmentero/ubuntu-sso-client/930720

« back to all changes in this revision

Viewing changes to ubuntu_sso/qt/sign_in_page.py

- Refactor the pages and controller in sso (LP: #929686).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
 
 
 
2
#
3
3
# Copyright 2012 Canonical Ltd.
4
4
#
5
5
# This program is free software: you can redistribute it and/or modify it
21
21
from PyQt4 import QtGui
22
22
 
23
23
from ubuntu_sso.qt.gui import SSOWizardPage
 
24
from ubuntu_sso.logger import setup_logging
 
25
from ubuntu_sso.utils.ui import (
 
26
    CONGRATULATIONS,
 
27
    EXISTING_ACCOUNT_CHOICE_BUTTON,
 
28
    SET_UP_ACCOUNT_CHOICE_BUTTON,
 
29
)
24
30
 
25
31
 
26
32
_ = gettext.gettext
 
33
logger = setup_logging('ubuntu_sso.sing_in_page')
27
34
 
28
35
 
29
36
class SignInPage(SSOWizardPage):
30
37
    """Wizard Page that lets the user Sign into Ubuntu One."""
31
38
 
32
 
    def __init__(self, image_pixmap, *args, **kwargs):
33
 
        super(SignInPage, self).__init__(*args, **kwargs)
 
39
    def __init__(self, ui, image_pixmap, *args, **kwargs):
 
40
        super(SignInPage, self).__init__(ui, *args, **kwargs)
34
41
        self.ui.image_label.setPixmap(image_pixmap)
 
42
        self._set_up_translated_strings()
 
43
        self._connect_buttons()
 
44
 
 
45
    def _set_up_translated_strings(self):
 
46
        """Set the correct strings for the UI."""
 
47
        logger.debug('SingInPage._set_up_translated_strings')
 
48
        congratulations = CONGRATULATIONS.format(app_name=self.app_name)
 
49
        self.ui.message_label.setText(congratulations)
 
50
        self.ui.existing_account_button.setText(
 
51
                                        EXISTING_ACCOUNT_CHOICE_BUTTON)
 
52
        self.ui.setup_account_button.setText(
 
53
                                        SET_UP_ACCOUNT_CHOICE_BUTTON)
 
54
 
 
55
    def _connect_buttons(self):
 
56
        """Connect the buttons to the actions to perform."""
 
57
        logger.debug('SingInPage._connect_buttons')
 
58
        self.ui.existing_account_button.clicked.connect(
 
59
                                                    self._set_next_existing)
 
60
        self.ui.setup_account_button.clicked.connect(self._set_next_new)
 
61
 
 
62
    def _set_next_existing(self):
 
63
        """Set the next id and fire signal."""
 
64
        logger.debug('SignInPage._set_next_existing')
 
65
        self.next = self.wizard().current_user_page_id
 
66
        self.wizard().next()
 
67
 
 
68
    def _set_next_new(self):
 
69
        """Set the next id and fire signal."""
 
70
        logger.debug('SignInPage._set_next_new')
 
71
        self.next = self.wizard().setup_account_page_id
 
72
        self.wizard().next()
35
73
 
36
74
    # Invalid names of Qt-inherited methods
37
75
    # pylint: disable=C0103