Merge lp:~diegosarmentero/ubuntu-sso-client/titles-on-pages into lp:ubuntu-sso-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Roberto Alsina
Approved revision: 760
Merge reported by: Roberto Alsina
Merged at revision: not available
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/titles-on-pages
Merge into: lp:ubuntu-sso-client
Diff against target: 631 lines (+166/-96)
8 files modified
data/qt/current_user_sign_in.ui (+3/-3)
data/qt/email_verification.ui (+1/-1)
data/qt/forgotten_password.ui (+1/-1)
data/qt/reset_password.ui (+1/-1)
data/qt/setup_account.ui (+2/-15)
ubuntu_sso/qt/controllers.py (+58/-50)
ubuntu_sso/qt/gui.py (+55/-4)
ubuntu_sso/qt/tests/test_windows.py (+45/-21)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/titles-on-pages
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+70157@code.launchpad.net

Commit message

Move all the Titles and Subtitles into the Wizard Pages

Description of the change

Move all the Titles and Subtitles into the Wizard Pages

To post a comment you must log in.
753. By Diego Sarmentero

adding word wrap mode to title and subtitles

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

I think we should create a new widget to show the title and subtitle in every page, so we can apply the style to a single widget, and we can have a single test suite and main logic handling the absence or presence of the title values.

What do you think?

review: Needs Information
754. By Diego Sarmentero

UI and controller modified to allow the page widget to work with a reimplementation of setTitle and setSubTitle

755. By Diego Sarmentero

tests modified to use set_title and set_subtitle from controller

756. By Diego Sarmentero

removing pylint disable on set_title and set_subtitle methods.

757. By Diego Sarmentero

improving some tests.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

As we talked in IRC, we need to refactor the code to avoid all the duplication for setting title/subtitle.

review: Needs Fixing
758. By Diego Sarmentero

refactoring title and subtitle handling to allow dynamic insertion of headers.

759. By Diego Sarmentero

adding missing docstring

760. By Diego Sarmentero

moving _title and _subtitle to BackendController

Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

It looks great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/qt/current_user_sign_in.ui'
--- data/qt/current_user_sign_in.ui 2011-06-29 22:10:52 +0000
+++ data/qt/current_user_sign_in.ui 2011-08-04 16:27:35 +0000
@@ -6,14 +6,14 @@
6 <rect>6 <rect>
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>400</width>9 <width>399</width>
10 <height>300</height>10 <height>309</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <property name="windowTitle">13 <property name="windowTitle">
14 <string>WizardPage</string>14 <string>WizardPage</string>
15 </property>15 </property>
16 <layout class="QHBoxLayout" name="horizontalLayout">16 <layout class="QVBoxLayout" name="verticalLayout_4">
17 <item>17 <item>
18 <layout class="QHBoxLayout" name="horizontalLayout_3">18 <layout class="QHBoxLayout" name="horizontalLayout_3">
19 <item>19 <item>
2020
=== modified file 'data/qt/email_verification.ui'
--- data/qt/email_verification.ui 2011-03-22 14:34:42 +0000
+++ data/qt/email_verification.ui 2011-08-04 16:27:35 +0000
@@ -13,7 +13,7 @@
13 <property name="windowTitle">13 <property name="windowTitle">
14 <string>WizardPage</string>14 <string>WizardPage</string>
15 </property>15 </property>
16 <layout class="QHBoxLayout" name="horizontalLayout">16 <layout class="QVBoxLayout" name="verticalLayout_2">
17 <item>17 <item>
18 <layout class="QHBoxLayout" name="horizontalLayout_3">18 <layout class="QHBoxLayout" name="horizontalLayout_3">
19 <item>19 <item>
2020
=== modified file 'data/qt/forgotten_password.ui'
--- data/qt/forgotten_password.ui 2011-04-13 16:36:12 +0000
+++ data/qt/forgotten_password.ui 2011-08-04 16:27:35 +0000
@@ -7,7 +7,7 @@
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>446</width>9 <width>446</width>
10 <height>209</height>10 <height>317</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <property name="windowTitle">13 <property name="windowTitle">
1414
=== modified file 'data/qt/reset_password.ui'
--- data/qt/reset_password.ui 2011-04-11 09:38:16 +0000
+++ data/qt/reset_password.ui 2011-08-04 16:27:35 +0000
@@ -7,7 +7,7 @@
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>476</width>9 <width>476</width>
10 <height>282</height>10 <height>262</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <property name="windowTitle">13 <property name="windowTitle">
1414
=== modified file 'data/qt/setup_account.ui'
--- data/qt/setup_account.ui 2011-04-13 14:05:39 +0000
+++ data/qt/setup_account.ui 2011-08-04 16:27:35 +0000
@@ -7,29 +7,16 @@
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>407</width>9 <width>407</width>
10 <height>453</height>10 <height>572</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <property name="windowTitle">13 <property name="windowTitle">
14 <string>WizardPage</string>14 <string>WizardPage</string>
15 </property>15 </property>
16 <layout class="QHBoxLayout" name="horizontalLayout">16 <layout class="QVBoxLayout" name="verticalLayout_5">
17 <item>17 <item>
18 <layout class="QVBoxLayout" name="verticalLayout">18 <layout class="QVBoxLayout" name="verticalLayout">
19 <item>19 <item>
20 <spacer name="verticalSpacer_3">
21 <property name="orientation">
22 <enum>Qt::Vertical</enum>
23 </property>
24 <property name="sizeHint" stdset="0">
25 <size>
26 <width>20</width>
27 <height>40</height>
28 </size>
29 </property>
30 </spacer>
31 </item>
32 <item>
33 <widget class="QFrame" name="_signInFrame">20 <widget class="QFrame" name="_signInFrame">
34 <property name="frameShape">21 <property name="frameShape">
35 <enum>QFrame::NoFrame</enum>22 <enum>QFrame::NoFrame</enum>
3623
=== modified file 'ubuntu_sso/qt/controllers.py'
--- ubuntu_sso/qt/controllers.py 2011-07-29 14:07:53 +0000
+++ ubuntu_sso/qt/controllers.py 2011-08-04 16:27:35 +0000
@@ -82,11 +82,13 @@
82class BackendController(object):82class BackendController(object):
83 """Represent a controller that talks with the sso self.backend."""83 """Represent a controller that talks with the sso self.backend."""
8484
85 def __init__(self):85 def __init__(self, title='', subtitle=''):
86 """Create a new instance."""86 """Create a new instance."""
87 self.root = None87 self.root = None
88 self.view = None88 self.view = None
89 self.backend = None89 self.backend = None
90 self._title = title
91 self._subtitle = subtitle
9092
91 def __del__(self):93 def __del__(self):
92 """Clean the resources."""94 """Clean the resources."""
@@ -115,20 +117,20 @@
115 #pylint: enable=C0103117 #pylint: enable=C0103
116118
117119
118class ChooseSignInController(object):120class ChooseSignInController(BackendController):
119 """Controlled to the ChooseSignIn view/widget."""121 """Controlled to the ChooseSignIn view/widget."""
120122
121 def __init__(self, title=''):123 def __init__(self, title='', subtitle=''):
122 """Create a new instance to manage the view."""124 """Create a new instance to manage the view."""
125 super(ChooseSignInController, self).__init__(title, subtitle)
123 self.view = None126 self.view = None
124 self._title = title
125127
126 # use an ugly name just so have a simlar api as found in PyQt128 # use an ugly name just so have a simlar api as found in PyQt
127 #pylint: disable=C0103129 #pylint: disable=C0103
130
128 def setupUi(self, view):131 def setupUi(self, view):
129 """Perform the required actions to set up the ui."""132 """Perform the required actions to set up the ui."""
130 self.view = view133 self.view = view
131 self.view.setTitle(self._title)
132 self._set_up_translated_strings()134 self._set_up_translated_strings()
133 self._connect_buttons()135 self._connect_buttons()
134 #pylint: enable=C0103136 #pylint: enable=C0103
@@ -166,12 +168,10 @@
166168
167 def __init__(self, backend=None, title='', subtitle='', message_box=None):169 def __init__(self, backend=None, title='', subtitle='', message_box=None):
168 """Create a new instance."""170 """Create a new instance."""
169 super(CurrentUserController, self).__init__()171 super(CurrentUserController, self).__init__(title, subtitle)
170 if message_box is None:172 if message_box is None:
171 message_box = QMessageBox173 message_box = QMessageBox
172 self.message_box = message_box174 self.message_box = message_box
173 self._title = title
174 self._subtitle = subtitle
175175
176 def _set_translated_strings(self):176 def _set_translated_strings(self):
177 """Set the translated strings."""177 """Set the translated strings."""
@@ -199,8 +199,8 @@
199 """Perform the login using the self.backend."""199 """Perform the login using the self.backend."""
200 logger.debug('CurrentUserController.login')200 logger.debug('CurrentUserController.login')
201 # grab the data from the view and call the backend201 # grab the data from the view and call the backend
202 email = str(self.view.ui.email_edit.text())202 email = unicode(self.view.ui.email_edit.text())
203 password = str(self.view.ui.password_edit.text())203 password = unicode(self.view.ui.password_edit.text())
204 d = self.backend.login(self.view.wizard().app_name, email, password)204 d = self.backend.login(self.view.wizard().app_name, email, password)
205 d.addErrback(self.on_login_error)205 d.addErrback(self.on_login_error)
206206
@@ -215,7 +215,7 @@
215 def on_logged_in(self, app_name, result):215 def on_logged_in(self, app_name, result):
216 """We managed to log in."""216 """We managed to log in."""
217 logger.info('Logged in for %s', app_name)217 logger.info('Logged in for %s', app_name)
218 email = str(self.view.ui.email_edit.text())218 email = unicode(self.view.ui.email_edit.text())
219 self.view.wizard().loginSuccess.emit(app_name, email)219 self.view.wizard().loginSuccess.emit(app_name, email)
220 logger.debug('Wizard.loginSuccess emitted.')220 logger.debug('Wizard.loginSuccess emitted.')
221221
@@ -232,9 +232,6 @@
232 """Setup the view."""232 """Setup the view."""
233 self.view = view233 self.view = view
234 self.backend = yield self.get_backend()234 self.backend = yield self.get_backend()
235 self.view.setTitle(self._title)
236 if self._subtitle:
237 self.view.setSubTitle(self._subtitle)
238 self._set_translated_strings()235 self._set_translated_strings()
239 self._connect_ui()236 self._connect_ui()
240 #pylint: enable=C0103237 #pylint: enable=C0103
@@ -245,7 +242,7 @@
245242
246 def __init__(self, message_box=None, title='', subtitle=''):243 def __init__(self, message_box=None, title='', subtitle=''):
247 """Create a new instance."""244 """Create a new instance."""
248 super(SetUpAccountController, self).__init__()245 super(SetUpAccountController, self).__init__(title, subtitle)
249 if message_box is None:246 if message_box is None:
250 message_box = QMessageBox247 message_box = QMessageBox
251 self.message_box = message_box248 self.message_box = message_box
@@ -355,9 +352,9 @@
355 def _set_titles(self):352 def _set_titles(self):
356 """Set the diff titles of the view."""353 """Set the diff titles of the view."""
357 logger.debug('SetUpAccountController._set_titles')354 logger.debug('SetUpAccountController._set_titles')
358 wizard = self.view.wizard()355 self.view.header.set_title(
359 self.view.setTitle(JOIN_HEADER_LABEL % {'app_name': wizard.app_name})356 JOIN_HEADER_LABEL % {'app_name': self.view.wizard().app_name})
360 self.view.setSubTitle(wizard.help_text)357 self.view.header.set_subtitle(self.view.wizard().help_text)
361358
362 def _register_fields(self):359 def _register_fields(self):
363 """Register the diff fields of the Ui."""360 """Register the diff fields of the Ui."""
@@ -445,11 +442,11 @@
445 def set_next_validation(self):442 def set_next_validation(self):
446 """Set the validation as the next page."""443 """Set the validation as the next page."""
447 logger.debug('SetUpAccountController.set_next_validation')444 logger.debug('SetUpAccountController.set_next_validation')
448 email = str(self.view.ui.email_edit.text())445 email = unicode(self.view.ui.email_edit.text())
449 password = str(self.view.ui.password_edit.text())446 password = unicode(self.view.ui.password_edit.text())
450 name = str(self.view.ui.name_edit.text())447 name = unicode(self.view.ui.name_edit.text())
451 captcha_id = self.view.captcha_id448 captcha_id = self.view.captcha_id
452 captcha_solution = str(self.view.ui.captcha_solution_edit.text())449 captcha_solution = unicode(self.view.ui.captcha_solution_edit.text())
453 # validate the current info of the form, try to perform the action450 # validate the current info of the form, try to perform the action
454 # to register the user, and then move foward451 # to register the user, and then move foward
455 if self.validate_form():452 if self.validate_form():
@@ -485,28 +482,29 @@
485 self._connect_ui_elements()482 self._connect_ui_elements()
486 self._refresh_captcha()483 self._refresh_captcha()
487 self._set_titles()484 self._set_titles()
485 self.view.header.set_title(self._title)
486 self.view.header.set_subtitle(self._subtitle)
488 self._set_translated_strings()487 self._set_translated_strings()
489 self._set_line_edits_validations()488 self._set_line_edits_validations()
490 self._register_fields()489 self._register_fields()
491 #pylint: enable=C0103490 #pylint: enable=C0103
492491
493492
494class TosController(object):493class TosController(BackendController):
495 """Controller used for the tos page."""494 """Controller used for the tos page."""
496495
497 def __init__(self, title='', subtitle='', tos_url=''):496 def __init__(self, title='', subtitle='', tos_url=''):
498 """Create a new instance."""497 """Create a new instance."""
498 super(TosController, self).__init__(title, subtitle)
499 self.view = None499 self.view = None
500 self._title = title
501 self._subtitle = subtitle
502 self._tos_url = tos_url500 self._tos_url = tos_url
503501
504 #pylint: disable=C0103502 #pylint: disable=C0103
505 def setupUi(self, view):503 def setupUi(self, view):
506 """Set up the ui."""504 """Set up the ui."""
507 self.view = view505 self.view = view
508 self.view.setTitle(self._title)506 self.view.header.set_title(self._title)
509 self.view.setSubTitle(self._subtitle)507 self.view.header.set_subtitle(self._subtitle)
510 # load the tos page508 # load the tos page
511 self.view.ui.terms_webkit.load(QUrl(self._tos_url))509 self.view.ui.terms_webkit.load(QUrl(self._tos_url))
512 self.view.ui.tos_link_label.setText(510 self.view.ui.tos_link_label.setText(
@@ -518,9 +516,9 @@
518class EmailVerificationController(BackendController):516class EmailVerificationController(BackendController):
519 """Controller used for the verification page."""517 """Controller used for the verification page."""
520518
521 def __init__(self, message_box=None):519 def __init__(self, message_box=None, title='', subtitle=''):
522 """Create a new instance."""520 """Create a new instance."""
523 super(EmailVerificationController, self).__init__()521 super(EmailVerificationController, self).__init__(title, subtitle)
524 if message_box is None:522 if message_box is None:
525 message_box = QMessageBox523 message_box = QMessageBox
526 self.message_box = message_box524 self.message_box = message_box
@@ -543,11 +541,11 @@
543 def _set_titles(self):541 def _set_titles(self):
544 """Set the different titles."""542 """Set the different titles."""
545 logger.debug('EmailVerificationController._set_titles')543 logger.debug('EmailVerificationController._set_titles')
546 self.view.setTitle(VERIFY_EMAIL_TITLE)544 self.view.header.set_title(VERIFY_EMAIL_TITLE)
547 self.view.setSubTitle(VERIFY_EMAIL_CONTENT % {545 self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % {
548 "app_name": self.view.wizard().app_name,546 "app_name": self.view.wizard().app_name,
549 "email": self.view.wizard().field("email_address").toString(),547 "email": self.view.wizard().field("email_address").toString(),
550 })548 })
551549
552 def set_titles(self):550 def set_titles(self):
553 """This class needs to have a public set_titles.551 """This class needs to have a public set_titles.
@@ -571,9 +569,9 @@
571 def validate_email(self):569 def validate_email(self):
572 """Call the next action."""570 """Call the next action."""
573 logger.debug('EmailVerificationController.validate_email')571 logger.debug('EmailVerificationController.validate_email')
574 email = str(self.view.wizard().field('email_address').toString())572 email = unicode(self.view.wizard().field('email_address').toString())
575 password = str(self.view.wizard().field('password').toString())573 password = unicode(self.view.wizard().field('password').toString())
576 code = str(self.view.ui.verification_code_edit.text())574 code = unicode(self.view.ui.verification_code_edit.text())
577 self.backend.validate_email(self.view.wizard().app_name, email,575 self.backend.validate_email(self.view.wizard().app_name, email,
578 password, code)576 password, code)
579577
@@ -601,12 +599,12 @@
601 #pylint: enable=C0103599 #pylint: enable=C0103
602600
603601
604class ErrorController(object):602class ErrorController(BackendController):
605 """Controller used for the error page."""603 """Controller used for the error page."""
606604
607 def __init__(self):605 def __init__(self, title='', subtitle=''):
608 """Create a new instance."""606 """Create a new instance."""
609 super(ErrorController, self).__init__()607 super(ErrorController, self).__init__(title, subtitle)
610 self.view = None608 self.view = None
611609
612 #pylint: disable=C0103610 #pylint: disable=C0103
@@ -615,15 +613,17 @@
615 self.view = view613 self.view = view
616 self.view.next = -1614 self.view.next = -1
617 self.view.ui.error_message_label.setText(ERROR)615 self.view.ui.error_message_label.setText(ERROR)
616 self.view.header.set_title(self._title)
617 self.view.header.set_subtitle(self._subtitle)
618 #pylint: enable=C0103618 #pylint: enable=C0103
619619
620620
621class ForgottenPasswordController(BackendController):621class ForgottenPasswordController(BackendController):
622 """Controller used to deal with the forgotten pwd page."""622 """Controller used to deal with the forgotten pwd page."""
623623
624 def __init__(self):624 def __init__(self, title='', subtitle=''):
625 """Create a new instance."""625 """Create a new instance."""
626 super(ForgottenPasswordController, self).__init__()626 super(ForgottenPasswordController, self).__init__(title, subtitle)
627627
628 def _register_fields(self):628 def _register_fields(self):
629 """Register the fields of the wizard page."""629 """Register the fields of the wizard page."""
@@ -697,15 +697,17 @@
697 self._connect_ui()697 self._connect_ui()
698 self._set_enhanced_line_edit()698 self._set_enhanced_line_edit()
699 self._register_fields()699 self._register_fields()
700 self.view.header.set_title(self._title)
701 self.view.header.set_subtitle(self._subtitle)
700 #pylint: enable=C0103702 #pylint: enable=C0103
701703
702704
703class ResetPasswordController(BackendController):705class ResetPasswordController(BackendController):
704 """Controller used to deal with reseintg the password."""706 """Controller used to deal with reseintg the password."""
705707
706 def __init__(self):708 def __init__(self, title='', subtitle=''):
707 """Create a new instance."""709 """Create a new instance."""
708 super(ResetPasswordController, self).__init__()710 super(ResetPasswordController, self).__init__(title, subtitle)
709711
710 def _set_translated_strings(self):712 def _set_translated_strings(self):
711 """Translate the diff strings used in the app."""713 """Translate the diff strings used in the app."""
@@ -745,9 +747,9 @@
745 def set_new_password(self):747 def set_new_password(self):
746 """Request a new password to be set."""748 """Request a new password to be set."""
747 app_name = self.view.wizard().app_name749 app_name = self.view.wizard().app_name
748 email = str(self.view.wizard().field('email_address').toString())750 email = unicode(self.view.wizard().field('email_address').toString())
749 code = str(self.view.ui.reset_code_line_edit.text())751 code = unicode(self.view.ui.reset_code_line_edit.text())
750 password = str(self.view.ui.password_line_edit.text())752 password = unicode(self.view.ui.password_line_edit.text())
751 logger.info('Settig new password for %s and email %s with code %s',753 logger.info('Settig new password for %s and email %s with code %s',
752 app_name, email, code)754 app_name, email, code)
753 self.backend.set_new_password(app_name, email, code, password)755 self.backend.set_new_password(app_name, email, code, password)
@@ -765,14 +767,17 @@
765 self._set_translated_strings()767 self._set_translated_strings()
766 self._connect_ui()768 self._connect_ui()
767 self._add_line_edits_validations()769 self._add_line_edits_validations()
770 self.view.header.set_title(self._title)
771 self.view.header.set_subtitle(self._subtitle)
768 #pylint: enable=C0103772 #pylint: enable=C0103
769773
770774
771class SuccessController(object):775class SuccessController(BackendController):
772 """Controller used for the success page."""776 """Controller used for the success page."""
773777
774 def __init__(self):778 def __init__(self, title='', subtitle=''):
775 """Create a new instance."""779 """Create a new instance."""
780 super(SuccessController, self).__init__(title, subtitle)
776 self.view = None781 self.view = None
777782
778 #pylint: disable=C0103783 #pylint: disable=C0103
@@ -781,6 +786,8 @@
781 self.view = view786 self.view = view
782 self.view.next = -1787 self.view.next = -1
783 self.view.ui.success_message_label.setText(SUCCESS)788 self.view.ui.success_message_label.setText(SUCCESS)
789 self.view.header.set_title(self._title)
790 self.view.header.set_subtitle(self._subtitle)
784 #pylint: enable=C0103791 #pylint: enable=C0103
785792
786793
@@ -806,7 +813,8 @@
806 def on_login_success(self, app_name, email):813 def on_login_success(self, app_name, email):
807 """Process the success of a login."""814 """Process the success of a login."""
808 logger.debug('UbuntuSSOWizardController.on_login_success')815 logger.debug('UbuntuSSOWizardController.on_login_success')
809 result = yield self.login_success_callback(str(app_name), str(email))816 result = yield self.login_success_callback(
817 unicode(app_name), unicode(email))
810 logger.debug('Result from callback is %s', result)818 logger.debug('Result from callback is %s', result)
811 if result == 0:819 if result == 0:
812 logger.info('Success in calling the given success_callback')820 logger.info('Success in calling the given success_callback')
@@ -819,8 +827,8 @@
819 def on_registration_success(self, app_name, email):827 def on_registration_success(self, app_name, email):
820 """Process the success of a registration."""828 """Process the success of a registration."""
821 logger.debug('UbuntuSSOWizardController.on_registration_success')829 logger.debug('UbuntuSSOWizardController.on_registration_success')
822 result = yield self.registration_success_callback(str(app_name),830 result = yield self.registration_success_callback(unicode(app_name),
823 str(email))831 unicode(email))
824 # TODO: what to do?832 # TODO: what to do?
825 logger.debug('Result from callback is %s', result)833 logger.debug('Result from callback is %s', result)
826 if result == 0:834 if result == 0:
827835
=== modified file 'ubuntu_sso/qt/gui.py'
--- ubuntu_sso/qt/gui.py 2011-07-27 19:20:57 +0000
+++ ubuntu_sso/qt/gui.py 2011-08-04 16:27:35 +0000
@@ -19,13 +19,16 @@
19from PyQt4.QtCore import pyqtSignal19from PyQt4.QtCore import pyqtSignal
20from PyQt4.QtGui import (20from PyQt4.QtGui import (
21 QApplication,21 QApplication,
22 QWidget,
22 QCursor,23 QCursor,
23 QHBoxLayout,24 QHBoxLayout,
25 QVBoxLayout,
24 QPixmap,26 QPixmap,
25 QPushButton,27 QPushButton,
26 QStyle,28 QStyle,
27 QWizard,29 QWizard,
28 QWizardPage)30 QWizardPage,
31 QLabel)
2932
30from ubuntu_sso.logger import setup_logging33from ubuntu_sso.logger import setup_logging
31# pylint: disable=F0401,E061134# pylint: disable=F0401,E0611
@@ -55,6 +58,38 @@
55logger = setup_logging('ubuntu_sso.gui')58logger = setup_logging('ubuntu_sso.gui')
5659
5760
61class Header(QWidget):
62 """Header Class for Title and Subtitle in all wizard pages."""
63
64 def __init__(self):
65 """Create a new instance."""
66 QWidget.__init__(self)
67 vbox = QVBoxLayout(self)
68 self.title_label = QLabel()
69 self.title_label.setObjectName('title_label')
70 self.subtitle_label = QLabel()
71 vbox.addWidget(self.title_label)
72 vbox.addWidget(self.subtitle_label)
73 self.title_label.setVisible(False)
74 self.subtitle_label.setVisible(False)
75
76 def set_title(self, title):
77 """Set the Title of the page or hide it otherwise"""
78 if title:
79 self.title_label.setText(title)
80 self.title_label.setVisible(True)
81 else:
82 self.title_label.setVisible(False)
83
84 def set_subtitle(self, subtitle):
85 """Set the Subtitle of the page or hide it otherwise"""
86 if subtitle:
87 self.subtitle_label.setText(subtitle)
88 self.subtitle_label.setVisible(True)
89 else:
90 self.subtitle_label.setVisible(False)
91
92
58class SSOWizardPage(QWizardPage):93class SSOWizardPage(QWizardPage):
59 """Root class for all wizard pages."""94 """Root class for all wizard pages."""
6095
@@ -63,8 +98,11 @@
63 QWizardPage.__init__(self, parent)98 QWizardPage.__init__(self, parent)
64 self.ui = ui99 self.ui = ui
65 self.ui.setupUi(self)100 self.ui.setupUi(self)
66 self.controller = controller101 self.header = Header()
67 self.controller.setupUi(self)102 self.layout().insertWidget(0, self.header)
103 if controller:
104 self.controller = controller
105 self.controller.setupUi(self)
68 self.next = -1106 self.next = -1
69107
70 # pylint: disable=C0103108 # pylint: disable=C0103
@@ -76,7 +114,20 @@
76 # pylint: disable=C0103114 # pylint: disable=C0103
77 def initializePage(self):115 def initializePage(self):
78 """Called to prepare the page just before it is shown."""116 """Called to prepare the page just before it is shown."""
79 self.controller.pageInitialized()117 if self.controller:
118 self.controller.pageInitialized()
119 # pylint: enable=C0103
120
121 # pylint: disable=C0103
122 def setTitle(self, title=''):
123 """Set the Wizard Page Title."""
124 self.header.set_title(title)
125 # pylint: enable=C0103
126
127 # pylint: disable=C0103
128 def setSubTitle(self, subtitle=''):
129 """Set the Wizard Page Subtitle."""
130 self.header.set_subtitle(subtitle)
80 # pylint: enable=C0103131 # pylint: enable=C0103
81132
82133
83134
=== modified file 'ubuntu_sso/qt/tests/test_windows.py'
--- ubuntu_sso/qt/tests/test_windows.py 2011-07-28 22:50:33 +0000
+++ ubuntu_sso/qt/tests/test_windows.py 2011-08-04 16:27:35 +0000
@@ -205,14 +205,13 @@
205205
206 def test_set_titles(self):206 def test_set_titles(self):
207 """Test how the different titles are set."""207 """Test how the different titles are set."""
208 self.view.wizard()208 self.view.wizard().app_name
209 self.mocker.result(self.view)
210 self.view.app_name
211 self.mocker.result(self.app_name)209 self.mocker.result(self.app_name)
212 self.view.help_text210 self.view.wizard().help_text
213 self.mocker.result(self.help)211 self.mocker.result(self.help)
214 self.view.setTitle(JOIN_HEADER_LABEL % {'app_name': self.app_name})212 self.view.header.set_title(
215 self.view.setSubTitle(self.help)213 JOIN_HEADER_LABEL % {'app_name': self.app_name})
214 self.view.header.set_subtitle(self.help)
216 self.mocker.replay()215 self.mocker.replay()
217 self.controller._set_titles()216 self.controller._set_titles()
218217
@@ -520,8 +519,8 @@
520519
521 def test_setup_ui(self):520 def test_setup_ui(self):
522 """Test the set up of the ui."""521 """Test the set up of the ui."""
523 self.view.setTitle(self.title)522 self.view.header.set_title(self.title)
524 self.view.setSubTitle(self.subtitle)523 self.view.header.set_subtitle(self.subtitle)
525 self.view.ui.terms_webkit.load(ANY)524 self.view.ui.terms_webkit.load(ANY)
526 self.view.ui.tos_link_label.setText(525 self.view.ui.tos_link_label.setText(
527 TOS_LABEL %526 TOS_LABEL %
@@ -561,15 +560,17 @@
561560
562 def test_set_titles(self):561 def test_set_titles(self):
563 """Test that the titles are set."""562 """Test that the titles are set."""
564 self.view.setTitle(VERIFY_EMAIL_TITLE)563 self.view.header.set_title(VERIFY_EMAIL_CONTENT)
565 self.view.wizard().app_name564 self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % {
566 self.view.wizard().field("email_address").toString()
567 self.view.setSubTitle(VERIFY_EMAIL_CONTENT % {
568 "app_name": None,565 "app_name": None,
569 "email": None,566 "email": None,
570 })567 })
571 self.mocker.replay()568 self.mocker.replay()
572 self.controller._set_titles()569 self.view.header.set_title(VERIFY_EMAIL_CONTENT)
570 self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % {
571 "app_name": None,
572 "email": None,
573 })
573574
574 def test_validate_email(self):575 def test_validate_email(self):
575 """Test the callback."""576 """Test the callback."""
@@ -626,10 +627,21 @@
626627
627 def test_set_ui(self):628 def test_set_ui(self):
628 """Test the process that sets the ui."""629 """Test the process that sets the ui."""
629 self.view.next = -1630 self.controller._title = ERROR
630 self.view.ui.error_message_label631 self.controller._subtitle = ERROR
631 self.mocker.result(self.view)632 self.view.next = -1
632 self.view.setText(ERROR)633 self.view.ui.error_message_label.setText(ERROR)
634 self.view.header.set_title(ERROR)
635 self.view.header.set_subtitle(ERROR)
636 self.mocker.replay()
637 self.controller.setupUi(self.view)
638
639 def test_hide_titles(self):
640 """Test how the different titles are set."""
641 self.view.next = -1
642 self.view.ui.error_message_label.setText(ERROR)
643 self.view.header.set_title('')
644 self.view.header.set_subtitle('')
633 self.mocker.replay()645 self.mocker.replay()
634 self.controller.setupUi(self.view)646 self.controller.setupUi(self.view)
635647
@@ -648,10 +660,21 @@
648660
649 def test_set_ui(self):661 def test_set_ui(self):
650 """Test the process that sets the ui."""662 """Test the process that sets the ui."""
651 self.view.next = -1663 self.controller._title = SUCCESS
652 self.view.ui.success_message_label664 self.controller._subtitle = SUCCESS
653 self.mocker.result(self.view)665 self.view.next = -1
654 self.view.setText(SUCCESS)666 self.view.ui.success_message_label.setText(SUCCESS)
667 self.view.header.set_title(SUCCESS)
668 self.view.header.set_subtitle(SUCCESS)
669 self.mocker.replay()
670 self.controller.setupUi(self.view)
671
672 def test_hide_titles(self):
673 """Test how the different titles are set."""
674 self.view.next = -1
675 self.view.ui.success_message_label.setText(SUCCESS)
676 self.view.header.set_title('')
677 self.view.header.set_subtitle('')
655 self.mocker.replay()678 self.mocker.replay()
656 self.controller.setupUi(self.view)679 self.controller.setupUi(self.view)
657680
@@ -851,6 +874,7 @@
851874
852 def test_set_translated_strings(self):875 def test_set_translated_strings(self):
853 """Ensure that the correct strings are set."""876 """Ensure that the correct strings are set."""
877 self.controller._subtitle = PASSWORD_HELP
854 self.view.ui.reset_code_line_edit.setPlaceholderText(RESET_CODE_ENTRY)878 self.view.ui.reset_code_line_edit.setPlaceholderText(RESET_CODE_ENTRY)
855 self.view.ui.password_line_edit.setPlaceholderText(PASSWORD1_ENTRY)879 self.view.ui.password_line_edit.setPlaceholderText(PASSWORD1_ENTRY)
856 self.view.ui.confirm_password_line_edit.setPlaceholderText(880 self.view.ui.confirm_password_line_edit.setPlaceholderText(

Subscribers

People subscribed via source and target branches