Merge lp:~diegosarmentero/ubuntu-sso-client/titles-on-pages into lp:ubuntu-sso-client
- titles-on-pages
- Merge into trunk
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 | ||||
Related bugs: |
|
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 : | # |
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
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
1 | === modified file 'data/qt/current_user_sign_in.ui' | |||
2 | --- data/qt/current_user_sign_in.ui 2011-06-29 22:10:52 +0000 | |||
3 | +++ data/qt/current_user_sign_in.ui 2011-08-04 16:27:35 +0000 | |||
4 | @@ -6,14 +6,14 @@ | |||
5 | 6 | <rect> | 6 | <rect> |
6 | 7 | <x>0</x> | 7 | <x>0</x> |
7 | 8 | <y>0</y> | 8 | <y>0</y> |
10 | 9 | <width>400</width> | 9 | <width>399</width> |
11 | 10 | <height>300</height> | 10 | <height>309</height> |
12 | 11 | </rect> | 11 | </rect> |
13 | 12 | </property> | 12 | </property> |
14 | 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
15 | 14 | <string>WizardPage</string> | 14 | <string>WizardPage</string> |
16 | 15 | </property> | 15 | </property> |
18 | 16 | <layout class="QHBoxLayout" name="horizontalLayout"> | 16 | <layout class="QVBoxLayout" name="verticalLayout_4"> |
19 | 17 | <item> | 17 | <item> |
20 | 18 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | 18 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
21 | 19 | <item> | 19 | <item> |
22 | 20 | 20 | ||
23 | === modified file 'data/qt/email_verification.ui' | |||
24 | --- data/qt/email_verification.ui 2011-03-22 14:34:42 +0000 | |||
25 | +++ data/qt/email_verification.ui 2011-08-04 16:27:35 +0000 | |||
26 | @@ -13,7 +13,7 @@ | |||
27 | 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
28 | 14 | <string>WizardPage</string> | 14 | <string>WizardPage</string> |
29 | 15 | </property> | 15 | </property> |
31 | 16 | <layout class="QHBoxLayout" name="horizontalLayout"> | 16 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
32 | 17 | <item> | 17 | <item> |
33 | 18 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | 18 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
34 | 19 | <item> | 19 | <item> |
35 | 20 | 20 | ||
36 | === modified file 'data/qt/forgotten_password.ui' | |||
37 | --- data/qt/forgotten_password.ui 2011-04-13 16:36:12 +0000 | |||
38 | +++ data/qt/forgotten_password.ui 2011-08-04 16:27:35 +0000 | |||
39 | @@ -7,7 +7,7 @@ | |||
40 | 7 | <x>0</x> | 7 | <x>0</x> |
41 | 8 | <y>0</y> | 8 | <y>0</y> |
42 | 9 | <width>446</width> | 9 | <width>446</width> |
44 | 10 | <height>209</height> | 10 | <height>317</height> |
45 | 11 | </rect> | 11 | </rect> |
46 | 12 | </property> | 12 | </property> |
47 | 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
48 | 14 | 14 | ||
49 | === modified file 'data/qt/reset_password.ui' | |||
50 | --- data/qt/reset_password.ui 2011-04-11 09:38:16 +0000 | |||
51 | +++ data/qt/reset_password.ui 2011-08-04 16:27:35 +0000 | |||
52 | @@ -7,7 +7,7 @@ | |||
53 | 7 | <x>0</x> | 7 | <x>0</x> |
54 | 8 | <y>0</y> | 8 | <y>0</y> |
55 | 9 | <width>476</width> | 9 | <width>476</width> |
57 | 10 | <height>282</height> | 10 | <height>262</height> |
58 | 11 | </rect> | 11 | </rect> |
59 | 12 | </property> | 12 | </property> |
60 | 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
61 | 14 | 14 | ||
62 | === modified file 'data/qt/setup_account.ui' | |||
63 | --- data/qt/setup_account.ui 2011-04-13 14:05:39 +0000 | |||
64 | +++ data/qt/setup_account.ui 2011-08-04 16:27:35 +0000 | |||
65 | @@ -7,29 +7,16 @@ | |||
66 | 7 | <x>0</x> | 7 | <x>0</x> |
67 | 8 | <y>0</y> | 8 | <y>0</y> |
68 | 9 | <width>407</width> | 9 | <width>407</width> |
70 | 10 | <height>453</height> | 10 | <height>572</height> |
71 | 11 | </rect> | 11 | </rect> |
72 | 12 | </property> | 12 | </property> |
73 | 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
74 | 14 | <string>WizardPage</string> | 14 | <string>WizardPage</string> |
75 | 15 | </property> | 15 | </property> |
77 | 16 | <layout class="QHBoxLayout" name="horizontalLayout"> | 16 | <layout class="QVBoxLayout" name="verticalLayout_5"> |
78 | 17 | <item> | 17 | <item> |
79 | 18 | <layout class="QVBoxLayout" name="verticalLayout"> | 18 | <layout class="QVBoxLayout" name="verticalLayout"> |
80 | 19 | <item> | 19 | <item> |
81 | 20 | <spacer name="verticalSpacer_3"> | ||
82 | 21 | <property name="orientation"> | ||
83 | 22 | <enum>Qt::Vertical</enum> | ||
84 | 23 | </property> | ||
85 | 24 | <property name="sizeHint" stdset="0"> | ||
86 | 25 | <size> | ||
87 | 26 | <width>20</width> | ||
88 | 27 | <height>40</height> | ||
89 | 28 | </size> | ||
90 | 29 | </property> | ||
91 | 30 | </spacer> | ||
92 | 31 | </item> | ||
93 | 32 | <item> | ||
94 | 33 | <widget class="QFrame" name="_signInFrame"> | 20 | <widget class="QFrame" name="_signInFrame"> |
95 | 34 | <property name="frameShape"> | 21 | <property name="frameShape"> |
96 | 35 | <enum>QFrame::NoFrame</enum> | 22 | <enum>QFrame::NoFrame</enum> |
97 | 36 | 23 | ||
98 | === modified file 'ubuntu_sso/qt/controllers.py' | |||
99 | --- ubuntu_sso/qt/controllers.py 2011-07-29 14:07:53 +0000 | |||
100 | +++ ubuntu_sso/qt/controllers.py 2011-08-04 16:27:35 +0000 | |||
101 | @@ -82,11 +82,13 @@ | |||
102 | 82 | class BackendController(object): | 82 | class BackendController(object): |
103 | 83 | """Represent a controller that talks with the sso self.backend.""" | 83 | """Represent a controller that talks with the sso self.backend.""" |
104 | 84 | 84 | ||
106 | 85 | def __init__(self): | 85 | def __init__(self, title='', subtitle=''): |
107 | 86 | """Create a new instance.""" | 86 | """Create a new instance.""" |
108 | 87 | self.root = None | 87 | self.root = None |
109 | 88 | self.view = None | 88 | self.view = None |
110 | 89 | self.backend = None | 89 | self.backend = None |
111 | 90 | self._title = title | ||
112 | 91 | self._subtitle = subtitle | ||
113 | 90 | 92 | ||
114 | 91 | def __del__(self): | 93 | def __del__(self): |
115 | 92 | """Clean the resources.""" | 94 | """Clean the resources.""" |
116 | @@ -115,20 +117,20 @@ | |||
117 | 115 | #pylint: enable=C0103 | 117 | #pylint: enable=C0103 |
118 | 116 | 118 | ||
119 | 117 | 119 | ||
121 | 118 | class ChooseSignInController(object): | 120 | class ChooseSignInController(BackendController): |
122 | 119 | """Controlled to the ChooseSignIn view/widget.""" | 121 | """Controlled to the ChooseSignIn view/widget.""" |
123 | 120 | 122 | ||
125 | 121 | def __init__(self, title=''): | 123 | def __init__(self, title='', subtitle=''): |
126 | 122 | """Create a new instance to manage the view.""" | 124 | """Create a new instance to manage the view.""" |
127 | 125 | super(ChooseSignInController, self).__init__(title, subtitle) | ||
128 | 123 | self.view = None | 126 | self.view = None |
129 | 124 | self._title = title | ||
130 | 125 | 127 | ||
131 | 126 | # use an ugly name just so have a simlar api as found in PyQt | 128 | # use an ugly name just so have a simlar api as found in PyQt |
132 | 127 | #pylint: disable=C0103 | 129 | #pylint: disable=C0103 |
133 | 130 | |||
134 | 128 | def setupUi(self, view): | 131 | def setupUi(self, view): |
135 | 129 | """Perform the required actions to set up the ui.""" | 132 | """Perform the required actions to set up the ui.""" |
136 | 130 | self.view = view | 133 | self.view = view |
137 | 131 | self.view.setTitle(self._title) | ||
138 | 132 | self._set_up_translated_strings() | 134 | self._set_up_translated_strings() |
139 | 133 | self._connect_buttons() | 135 | self._connect_buttons() |
140 | 134 | #pylint: enable=C0103 | 136 | #pylint: enable=C0103 |
141 | @@ -166,12 +168,10 @@ | |||
142 | 166 | 168 | ||
143 | 167 | def __init__(self, backend=None, title='', subtitle='', message_box=None): | 169 | def __init__(self, backend=None, title='', subtitle='', message_box=None): |
144 | 168 | """Create a new instance.""" | 170 | """Create a new instance.""" |
146 | 169 | super(CurrentUserController, self).__init__() | 171 | super(CurrentUserController, self).__init__(title, subtitle) |
147 | 170 | if message_box is None: | 172 | if message_box is None: |
148 | 171 | message_box = QMessageBox | 173 | message_box = QMessageBox |
149 | 172 | self.message_box = message_box | 174 | self.message_box = message_box |
150 | 173 | self._title = title | ||
151 | 174 | self._subtitle = subtitle | ||
152 | 175 | 175 | ||
153 | 176 | def _set_translated_strings(self): | 176 | def _set_translated_strings(self): |
154 | 177 | """Set the translated strings.""" | 177 | """Set the translated strings.""" |
155 | @@ -199,8 +199,8 @@ | |||
156 | 199 | """Perform the login using the self.backend.""" | 199 | """Perform the login using the self.backend.""" |
157 | 200 | logger.debug('CurrentUserController.login') | 200 | logger.debug('CurrentUserController.login') |
158 | 201 | # grab the data from the view and call the backend | 201 | # grab the data from the view and call the backend |
161 | 202 | email = str(self.view.ui.email_edit.text()) | 202 | email = unicode(self.view.ui.email_edit.text()) |
162 | 203 | password = str(self.view.ui.password_edit.text()) | 203 | password = unicode(self.view.ui.password_edit.text()) |
163 | 204 | d = self.backend.login(self.view.wizard().app_name, email, password) | 204 | d = self.backend.login(self.view.wizard().app_name, email, password) |
164 | 205 | d.addErrback(self.on_login_error) | 205 | d.addErrback(self.on_login_error) |
165 | 206 | 206 | ||
166 | @@ -215,7 +215,7 @@ | |||
167 | 215 | def on_logged_in(self, app_name, result): | 215 | def on_logged_in(self, app_name, result): |
168 | 216 | """We managed to log in.""" | 216 | """We managed to log in.""" |
169 | 217 | logger.info('Logged in for %s', app_name) | 217 | logger.info('Logged in for %s', app_name) |
171 | 218 | email = str(self.view.ui.email_edit.text()) | 218 | email = unicode(self.view.ui.email_edit.text()) |
172 | 219 | self.view.wizard().loginSuccess.emit(app_name, email) | 219 | self.view.wizard().loginSuccess.emit(app_name, email) |
173 | 220 | logger.debug('Wizard.loginSuccess emitted.') | 220 | logger.debug('Wizard.loginSuccess emitted.') |
174 | 221 | 221 | ||
175 | @@ -232,9 +232,6 @@ | |||
176 | 232 | """Setup the view.""" | 232 | """Setup the view.""" |
177 | 233 | self.view = view | 233 | self.view = view |
178 | 234 | self.backend = yield self.get_backend() | 234 | self.backend = yield self.get_backend() |
179 | 235 | self.view.setTitle(self._title) | ||
180 | 236 | if self._subtitle: | ||
181 | 237 | self.view.setSubTitle(self._subtitle) | ||
182 | 238 | self._set_translated_strings() | 235 | self._set_translated_strings() |
183 | 239 | self._connect_ui() | 236 | self._connect_ui() |
184 | 240 | #pylint: enable=C0103 | 237 | #pylint: enable=C0103 |
185 | @@ -245,7 +242,7 @@ | |||
186 | 245 | 242 | ||
187 | 246 | def __init__(self, message_box=None, title='', subtitle=''): | 243 | def __init__(self, message_box=None, title='', subtitle=''): |
188 | 247 | """Create a new instance.""" | 244 | """Create a new instance.""" |
190 | 248 | super(SetUpAccountController, self).__init__() | 245 | super(SetUpAccountController, self).__init__(title, subtitle) |
191 | 249 | if message_box is None: | 246 | if message_box is None: |
192 | 250 | message_box = QMessageBox | 247 | message_box = QMessageBox |
193 | 251 | self.message_box = message_box | 248 | self.message_box = message_box |
194 | @@ -355,9 +352,9 @@ | |||
195 | 355 | def _set_titles(self): | 352 | def _set_titles(self): |
196 | 356 | """Set the diff titles of the view.""" | 353 | """Set the diff titles of the view.""" |
197 | 357 | logger.debug('SetUpAccountController._set_titles') | 354 | logger.debug('SetUpAccountController._set_titles') |
201 | 358 | wizard = self.view.wizard() | 355 | self.view.header.set_title( |
202 | 359 | self.view.setTitle(JOIN_HEADER_LABEL % {'app_name': wizard.app_name}) | 356 | JOIN_HEADER_LABEL % {'app_name': self.view.wizard().app_name}) |
203 | 360 | self.view.setSubTitle(wizard.help_text) | 357 | self.view.header.set_subtitle(self.view.wizard().help_text) |
204 | 361 | 358 | ||
205 | 362 | def _register_fields(self): | 359 | def _register_fields(self): |
206 | 363 | """Register the diff fields of the Ui.""" | 360 | """Register the diff fields of the Ui.""" |
207 | @@ -445,11 +442,11 @@ | |||
208 | 445 | def set_next_validation(self): | 442 | def set_next_validation(self): |
209 | 446 | """Set the validation as the next page.""" | 443 | """Set the validation as the next page.""" |
210 | 447 | logger.debug('SetUpAccountController.set_next_validation') | 444 | logger.debug('SetUpAccountController.set_next_validation') |
214 | 448 | email = str(self.view.ui.email_edit.text()) | 445 | email = unicode(self.view.ui.email_edit.text()) |
215 | 449 | password = str(self.view.ui.password_edit.text()) | 446 | password = unicode(self.view.ui.password_edit.text()) |
216 | 450 | name = str(self.view.ui.name_edit.text()) | 447 | name = unicode(self.view.ui.name_edit.text()) |
217 | 451 | captcha_id = self.view.captcha_id | 448 | captcha_id = self.view.captcha_id |
219 | 452 | captcha_solution = str(self.view.ui.captcha_solution_edit.text()) | 449 | captcha_solution = unicode(self.view.ui.captcha_solution_edit.text()) |
220 | 453 | # validate the current info of the form, try to perform the action | 450 | # validate the current info of the form, try to perform the action |
221 | 454 | # to register the user, and then move foward | 451 | # to register the user, and then move foward |
222 | 455 | if self.validate_form(): | 452 | if self.validate_form(): |
223 | @@ -485,28 +482,29 @@ | |||
224 | 485 | self._connect_ui_elements() | 482 | self._connect_ui_elements() |
225 | 486 | self._refresh_captcha() | 483 | self._refresh_captcha() |
226 | 487 | self._set_titles() | 484 | self._set_titles() |
227 | 485 | self.view.header.set_title(self._title) | ||
228 | 486 | self.view.header.set_subtitle(self._subtitle) | ||
229 | 488 | self._set_translated_strings() | 487 | self._set_translated_strings() |
230 | 489 | self._set_line_edits_validations() | 488 | self._set_line_edits_validations() |
231 | 490 | self._register_fields() | 489 | self._register_fields() |
232 | 491 | #pylint: enable=C0103 | 490 | #pylint: enable=C0103 |
233 | 492 | 491 | ||
234 | 493 | 492 | ||
236 | 494 | class TosController(object): | 493 | class TosController(BackendController): |
237 | 495 | """Controller used for the tos page.""" | 494 | """Controller used for the tos page.""" |
238 | 496 | 495 | ||
239 | 497 | def __init__(self, title='', subtitle='', tos_url=''): | 496 | def __init__(self, title='', subtitle='', tos_url=''): |
240 | 498 | """Create a new instance.""" | 497 | """Create a new instance.""" |
241 | 498 | super(TosController, self).__init__(title, subtitle) | ||
242 | 499 | self.view = None | 499 | self.view = None |
243 | 500 | self._title = title | ||
244 | 501 | self._subtitle = subtitle | ||
245 | 502 | self._tos_url = tos_url | 500 | self._tos_url = tos_url |
246 | 503 | 501 | ||
247 | 504 | #pylint: disable=C0103 | 502 | #pylint: disable=C0103 |
248 | 505 | def setupUi(self, view): | 503 | def setupUi(self, view): |
249 | 506 | """Set up the ui.""" | 504 | """Set up the ui.""" |
250 | 507 | self.view = view | 505 | self.view = view |
253 | 508 | self.view.setTitle(self._title) | 506 | self.view.header.set_title(self._title) |
254 | 509 | self.view.setSubTitle(self._subtitle) | 507 | self.view.header.set_subtitle(self._subtitle) |
255 | 510 | # load the tos page | 508 | # load the tos page |
256 | 511 | self.view.ui.terms_webkit.load(QUrl(self._tos_url)) | 509 | self.view.ui.terms_webkit.load(QUrl(self._tos_url)) |
257 | 512 | self.view.ui.tos_link_label.setText( | 510 | self.view.ui.tos_link_label.setText( |
258 | @@ -518,9 +516,9 @@ | |||
259 | 518 | class EmailVerificationController(BackendController): | 516 | class EmailVerificationController(BackendController): |
260 | 519 | """Controller used for the verification page.""" | 517 | """Controller used for the verification page.""" |
261 | 520 | 518 | ||
263 | 521 | def __init__(self, message_box=None): | 519 | def __init__(self, message_box=None, title='', subtitle=''): |
264 | 522 | """Create a new instance.""" | 520 | """Create a new instance.""" |
266 | 523 | super(EmailVerificationController, self).__init__() | 521 | super(EmailVerificationController, self).__init__(title, subtitle) |
267 | 524 | if message_box is None: | 522 | if message_box is None: |
268 | 525 | message_box = QMessageBox | 523 | message_box = QMessageBox |
269 | 526 | self.message_box = message_box | 524 | self.message_box = message_box |
270 | @@ -543,11 +541,11 @@ | |||
271 | 543 | def _set_titles(self): | 541 | def _set_titles(self): |
272 | 544 | """Set the different titles.""" | 542 | """Set the different titles.""" |
273 | 545 | logger.debug('EmailVerificationController._set_titles') | 543 | logger.debug('EmailVerificationController._set_titles') |
276 | 546 | self.view.setTitle(VERIFY_EMAIL_TITLE) | 544 | self.view.header.set_title(VERIFY_EMAIL_TITLE) |
277 | 547 | self.view.setSubTitle(VERIFY_EMAIL_CONTENT % { | 545 | self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % { |
278 | 548 | "app_name": self.view.wizard().app_name, | 546 | "app_name": self.view.wizard().app_name, |
279 | 549 | "email": self.view.wizard().field("email_address").toString(), | 547 | "email": self.view.wizard().field("email_address").toString(), |
281 | 550 | }) | 548 | }) |
282 | 551 | 549 | ||
283 | 552 | def set_titles(self): | 550 | def set_titles(self): |
284 | 553 | """This class needs to have a public set_titles. | 551 | """This class needs to have a public set_titles. |
285 | @@ -571,9 +569,9 @@ | |||
286 | 571 | def validate_email(self): | 569 | def validate_email(self): |
287 | 572 | """Call the next action.""" | 570 | """Call the next action.""" |
288 | 573 | logger.debug('EmailVerificationController.validate_email') | 571 | logger.debug('EmailVerificationController.validate_email') |
292 | 574 | email = str(self.view.wizard().field('email_address').toString()) | 572 | email = unicode(self.view.wizard().field('email_address').toString()) |
293 | 575 | password = str(self.view.wizard().field('password').toString()) | 573 | password = unicode(self.view.wizard().field('password').toString()) |
294 | 576 | code = str(self.view.ui.verification_code_edit.text()) | 574 | code = unicode(self.view.ui.verification_code_edit.text()) |
295 | 577 | self.backend.validate_email(self.view.wizard().app_name, email, | 575 | self.backend.validate_email(self.view.wizard().app_name, email, |
296 | 578 | password, code) | 576 | password, code) |
297 | 579 | 577 | ||
298 | @@ -601,12 +599,12 @@ | |||
299 | 601 | #pylint: enable=C0103 | 599 | #pylint: enable=C0103 |
300 | 602 | 600 | ||
301 | 603 | 601 | ||
303 | 604 | class ErrorController(object): | 602 | class ErrorController(BackendController): |
304 | 605 | """Controller used for the error page.""" | 603 | """Controller used for the error page.""" |
305 | 606 | 604 | ||
307 | 607 | def __init__(self): | 605 | def __init__(self, title='', subtitle=''): |
308 | 608 | """Create a new instance.""" | 606 | """Create a new instance.""" |
310 | 609 | super(ErrorController, self).__init__() | 607 | super(ErrorController, self).__init__(title, subtitle) |
311 | 610 | self.view = None | 608 | self.view = None |
312 | 611 | 609 | ||
313 | 612 | #pylint: disable=C0103 | 610 | #pylint: disable=C0103 |
314 | @@ -615,15 +613,17 @@ | |||
315 | 615 | self.view = view | 613 | self.view = view |
316 | 616 | self.view.next = -1 | 614 | self.view.next = -1 |
317 | 617 | self.view.ui.error_message_label.setText(ERROR) | 615 | self.view.ui.error_message_label.setText(ERROR) |
318 | 616 | self.view.header.set_title(self._title) | ||
319 | 617 | self.view.header.set_subtitle(self._subtitle) | ||
320 | 618 | #pylint: enable=C0103 | 618 | #pylint: enable=C0103 |
321 | 619 | 619 | ||
322 | 620 | 620 | ||
323 | 621 | class ForgottenPasswordController(BackendController): | 621 | class ForgottenPasswordController(BackendController): |
324 | 622 | """Controller used to deal with the forgotten pwd page.""" | 622 | """Controller used to deal with the forgotten pwd page.""" |
325 | 623 | 623 | ||
327 | 624 | def __init__(self): | 624 | def __init__(self, title='', subtitle=''): |
328 | 625 | """Create a new instance.""" | 625 | """Create a new instance.""" |
330 | 626 | super(ForgottenPasswordController, self).__init__() | 626 | super(ForgottenPasswordController, self).__init__(title, subtitle) |
331 | 627 | 627 | ||
332 | 628 | def _register_fields(self): | 628 | def _register_fields(self): |
333 | 629 | """Register the fields of the wizard page.""" | 629 | """Register the fields of the wizard page.""" |
334 | @@ -697,15 +697,17 @@ | |||
335 | 697 | self._connect_ui() | 697 | self._connect_ui() |
336 | 698 | self._set_enhanced_line_edit() | 698 | self._set_enhanced_line_edit() |
337 | 699 | self._register_fields() | 699 | self._register_fields() |
338 | 700 | self.view.header.set_title(self._title) | ||
339 | 701 | self.view.header.set_subtitle(self._subtitle) | ||
340 | 700 | #pylint: enable=C0103 | 702 | #pylint: enable=C0103 |
341 | 701 | 703 | ||
342 | 702 | 704 | ||
343 | 703 | class ResetPasswordController(BackendController): | 705 | class ResetPasswordController(BackendController): |
344 | 704 | """Controller used to deal with reseintg the password.""" | 706 | """Controller used to deal with reseintg the password.""" |
345 | 705 | 707 | ||
347 | 706 | def __init__(self): | 708 | def __init__(self, title='', subtitle=''): |
348 | 707 | """Create a new instance.""" | 709 | """Create a new instance.""" |
350 | 708 | super(ResetPasswordController, self).__init__() | 710 | super(ResetPasswordController, self).__init__(title, subtitle) |
351 | 709 | 711 | ||
352 | 710 | def _set_translated_strings(self): | 712 | def _set_translated_strings(self): |
353 | 711 | """Translate the diff strings used in the app.""" | 713 | """Translate the diff strings used in the app.""" |
354 | @@ -745,9 +747,9 @@ | |||
355 | 745 | def set_new_password(self): | 747 | def set_new_password(self): |
356 | 746 | """Request a new password to be set.""" | 748 | """Request a new password to be set.""" |
357 | 747 | app_name = self.view.wizard().app_name | 749 | app_name = self.view.wizard().app_name |
361 | 748 | email = str(self.view.wizard().field('email_address').toString()) | 750 | email = unicode(self.view.wizard().field('email_address').toString()) |
362 | 749 | code = str(self.view.ui.reset_code_line_edit.text()) | 751 | code = unicode(self.view.ui.reset_code_line_edit.text()) |
363 | 750 | password = str(self.view.ui.password_line_edit.text()) | 752 | password = unicode(self.view.ui.password_line_edit.text()) |
364 | 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', |
365 | 752 | app_name, email, code) | 754 | app_name, email, code) |
366 | 753 | self.backend.set_new_password(app_name, email, code, password) | 755 | self.backend.set_new_password(app_name, email, code, password) |
367 | @@ -765,14 +767,17 @@ | |||
368 | 765 | self._set_translated_strings() | 767 | self._set_translated_strings() |
369 | 766 | self._connect_ui() | 768 | self._connect_ui() |
370 | 767 | self._add_line_edits_validations() | 769 | self._add_line_edits_validations() |
371 | 770 | self.view.header.set_title(self._title) | ||
372 | 771 | self.view.header.set_subtitle(self._subtitle) | ||
373 | 768 | #pylint: enable=C0103 | 772 | #pylint: enable=C0103 |
374 | 769 | 773 | ||
375 | 770 | 774 | ||
377 | 771 | class SuccessController(object): | 775 | class SuccessController(BackendController): |
378 | 772 | """Controller used for the success page.""" | 776 | """Controller used for the success page.""" |
379 | 773 | 777 | ||
381 | 774 | def __init__(self): | 778 | def __init__(self, title='', subtitle=''): |
382 | 775 | """Create a new instance.""" | 779 | """Create a new instance.""" |
383 | 780 | super(SuccessController, self).__init__(title, subtitle) | ||
384 | 776 | self.view = None | 781 | self.view = None |
385 | 777 | 782 | ||
386 | 778 | #pylint: disable=C0103 | 783 | #pylint: disable=C0103 |
387 | @@ -781,6 +786,8 @@ | |||
388 | 781 | self.view = view | 786 | self.view = view |
389 | 782 | self.view.next = -1 | 787 | self.view.next = -1 |
390 | 783 | self.view.ui.success_message_label.setText(SUCCESS) | 788 | self.view.ui.success_message_label.setText(SUCCESS) |
391 | 789 | self.view.header.set_title(self._title) | ||
392 | 790 | self.view.header.set_subtitle(self._subtitle) | ||
393 | 784 | #pylint: enable=C0103 | 791 | #pylint: enable=C0103 |
394 | 785 | 792 | ||
395 | 786 | 793 | ||
396 | @@ -806,7 +813,8 @@ | |||
397 | 806 | def on_login_success(self, app_name, email): | 813 | def on_login_success(self, app_name, email): |
398 | 807 | """Process the success of a login.""" | 814 | """Process the success of a login.""" |
399 | 808 | logger.debug('UbuntuSSOWizardController.on_login_success') | 815 | logger.debug('UbuntuSSOWizardController.on_login_success') |
401 | 809 | result = yield self.login_success_callback(str(app_name), str(email)) | 816 | result = yield self.login_success_callback( |
402 | 817 | unicode(app_name), unicode(email)) | ||
403 | 810 | logger.debug('Result from callback is %s', result) | 818 | logger.debug('Result from callback is %s', result) |
404 | 811 | if result == 0: | 819 | if result == 0: |
405 | 812 | logger.info('Success in calling the given success_callback') | 820 | logger.info('Success in calling the given success_callback') |
406 | @@ -819,8 +827,8 @@ | |||
407 | 819 | def on_registration_success(self, app_name, email): | 827 | def on_registration_success(self, app_name, email): |
408 | 820 | """Process the success of a registration.""" | 828 | """Process the success of a registration.""" |
409 | 821 | logger.debug('UbuntuSSOWizardController.on_registration_success') | 829 | logger.debug('UbuntuSSOWizardController.on_registration_success') |
412 | 822 | result = yield self.registration_success_callback(str(app_name), | 830 | result = yield self.registration_success_callback(unicode(app_name), |
413 | 823 | str(email)) | 831 | unicode(email)) |
414 | 824 | # TODO: what to do? | 832 | # TODO: what to do? |
415 | 825 | logger.debug('Result from callback is %s', result) | 833 | logger.debug('Result from callback is %s', result) |
416 | 826 | if result == 0: | 834 | if result == 0: |
417 | 827 | 835 | ||
418 | === modified file 'ubuntu_sso/qt/gui.py' | |||
419 | --- ubuntu_sso/qt/gui.py 2011-07-27 19:20:57 +0000 | |||
420 | +++ ubuntu_sso/qt/gui.py 2011-08-04 16:27:35 +0000 | |||
421 | @@ -19,13 +19,16 @@ | |||
422 | 19 | from PyQt4.QtCore import pyqtSignal | 19 | from PyQt4.QtCore import pyqtSignal |
423 | 20 | from PyQt4.QtGui import ( | 20 | from PyQt4.QtGui import ( |
424 | 21 | QApplication, | 21 | QApplication, |
425 | 22 | QWidget, | ||
426 | 22 | QCursor, | 23 | QCursor, |
427 | 23 | QHBoxLayout, | 24 | QHBoxLayout, |
428 | 25 | QVBoxLayout, | ||
429 | 24 | QPixmap, | 26 | QPixmap, |
430 | 25 | QPushButton, | 27 | QPushButton, |
431 | 26 | QStyle, | 28 | QStyle, |
432 | 27 | QWizard, | 29 | QWizard, |
434 | 28 | QWizardPage) | 30 | QWizardPage, |
435 | 31 | QLabel) | ||
436 | 29 | 32 | ||
437 | 30 | from ubuntu_sso.logger import setup_logging | 33 | from ubuntu_sso.logger import setup_logging |
438 | 31 | # pylint: disable=F0401,E0611 | 34 | # pylint: disable=F0401,E0611 |
439 | @@ -55,6 +58,38 @@ | |||
440 | 55 | logger = setup_logging('ubuntu_sso.gui') | 58 | logger = setup_logging('ubuntu_sso.gui') |
441 | 56 | 59 | ||
442 | 57 | 60 | ||
443 | 61 | class Header(QWidget): | ||
444 | 62 | """Header Class for Title and Subtitle in all wizard pages.""" | ||
445 | 63 | |||
446 | 64 | def __init__(self): | ||
447 | 65 | """Create a new instance.""" | ||
448 | 66 | QWidget.__init__(self) | ||
449 | 67 | vbox = QVBoxLayout(self) | ||
450 | 68 | self.title_label = QLabel() | ||
451 | 69 | self.title_label.setObjectName('title_label') | ||
452 | 70 | self.subtitle_label = QLabel() | ||
453 | 71 | vbox.addWidget(self.title_label) | ||
454 | 72 | vbox.addWidget(self.subtitle_label) | ||
455 | 73 | self.title_label.setVisible(False) | ||
456 | 74 | self.subtitle_label.setVisible(False) | ||
457 | 75 | |||
458 | 76 | def set_title(self, title): | ||
459 | 77 | """Set the Title of the page or hide it otherwise""" | ||
460 | 78 | if title: | ||
461 | 79 | self.title_label.setText(title) | ||
462 | 80 | self.title_label.setVisible(True) | ||
463 | 81 | else: | ||
464 | 82 | self.title_label.setVisible(False) | ||
465 | 83 | |||
466 | 84 | def set_subtitle(self, subtitle): | ||
467 | 85 | """Set the Subtitle of the page or hide it otherwise""" | ||
468 | 86 | if subtitle: | ||
469 | 87 | self.subtitle_label.setText(subtitle) | ||
470 | 88 | self.subtitle_label.setVisible(True) | ||
471 | 89 | else: | ||
472 | 90 | self.subtitle_label.setVisible(False) | ||
473 | 91 | |||
474 | 92 | |||
475 | 58 | class SSOWizardPage(QWizardPage): | 93 | class SSOWizardPage(QWizardPage): |
476 | 59 | """Root class for all wizard pages.""" | 94 | """Root class for all wizard pages.""" |
477 | 60 | 95 | ||
478 | @@ -63,8 +98,11 @@ | |||
479 | 63 | QWizardPage.__init__(self, parent) | 98 | QWizardPage.__init__(self, parent) |
480 | 64 | self.ui = ui | 99 | self.ui = ui |
481 | 65 | self.ui.setupUi(self) | 100 | self.ui.setupUi(self) |
484 | 66 | self.controller = controller | 101 | self.header = Header() |
485 | 67 | self.controller.setupUi(self) | 102 | self.layout().insertWidget(0, self.header) |
486 | 103 | if controller: | ||
487 | 104 | self.controller = controller | ||
488 | 105 | self.controller.setupUi(self) | ||
489 | 68 | self.next = -1 | 106 | self.next = -1 |
490 | 69 | 107 | ||
491 | 70 | # pylint: disable=C0103 | 108 | # pylint: disable=C0103 |
492 | @@ -76,7 +114,20 @@ | |||
493 | 76 | # pylint: disable=C0103 | 114 | # pylint: disable=C0103 |
494 | 77 | def initializePage(self): | 115 | def initializePage(self): |
495 | 78 | """Called to prepare the page just before it is shown.""" | 116 | """Called to prepare the page just before it is shown.""" |
497 | 79 | self.controller.pageInitialized() | 117 | if self.controller: |
498 | 118 | self.controller.pageInitialized() | ||
499 | 119 | # pylint: enable=C0103 | ||
500 | 120 | |||
501 | 121 | # pylint: disable=C0103 | ||
502 | 122 | def setTitle(self, title=''): | ||
503 | 123 | """Set the Wizard Page Title.""" | ||
504 | 124 | self.header.set_title(title) | ||
505 | 125 | # pylint: enable=C0103 | ||
506 | 126 | |||
507 | 127 | # pylint: disable=C0103 | ||
508 | 128 | def setSubTitle(self, subtitle=''): | ||
509 | 129 | """Set the Wizard Page Subtitle.""" | ||
510 | 130 | self.header.set_subtitle(subtitle) | ||
511 | 80 | # pylint: enable=C0103 | 131 | # pylint: enable=C0103 |
512 | 81 | 132 | ||
513 | 82 | 133 | ||
514 | 83 | 134 | ||
515 | === modified file 'ubuntu_sso/qt/tests/test_windows.py' | |||
516 | --- ubuntu_sso/qt/tests/test_windows.py 2011-07-28 22:50:33 +0000 | |||
517 | +++ ubuntu_sso/qt/tests/test_windows.py 2011-08-04 16:27:35 +0000 | |||
518 | @@ -205,14 +205,13 @@ | |||
519 | 205 | 205 | ||
520 | 206 | def test_set_titles(self): | 206 | def test_set_titles(self): |
521 | 207 | """Test how the different titles are set.""" | 207 | """Test how the different titles are set.""" |
525 | 208 | self.view.wizard() | 208 | self.view.wizard().app_name |
523 | 209 | self.mocker.result(self.view) | ||
524 | 210 | self.view.app_name | ||
526 | 211 | self.mocker.result(self.app_name) | 209 | self.mocker.result(self.app_name) |
528 | 212 | self.view.help_text | 210 | self.view.wizard().help_text |
529 | 213 | self.mocker.result(self.help) | 211 | self.mocker.result(self.help) |
532 | 214 | self.view.setTitle(JOIN_HEADER_LABEL % {'app_name': self.app_name}) | 212 | self.view.header.set_title( |
533 | 215 | self.view.setSubTitle(self.help) | 213 | JOIN_HEADER_LABEL % {'app_name': self.app_name}) |
534 | 214 | self.view.header.set_subtitle(self.help) | ||
535 | 216 | self.mocker.replay() | 215 | self.mocker.replay() |
536 | 217 | self.controller._set_titles() | 216 | self.controller._set_titles() |
537 | 218 | 217 | ||
538 | @@ -520,8 +519,8 @@ | |||
539 | 520 | 519 | ||
540 | 521 | def test_setup_ui(self): | 520 | def test_setup_ui(self): |
541 | 522 | """Test the set up of the ui.""" | 521 | """Test the set up of the ui.""" |
544 | 523 | self.view.setTitle(self.title) | 522 | self.view.header.set_title(self.title) |
545 | 524 | self.view.setSubTitle(self.subtitle) | 523 | self.view.header.set_subtitle(self.subtitle) |
546 | 525 | self.view.ui.terms_webkit.load(ANY) | 524 | self.view.ui.terms_webkit.load(ANY) |
547 | 526 | self.view.ui.tos_link_label.setText( | 525 | self.view.ui.tos_link_label.setText( |
548 | 527 | TOS_LABEL % | 526 | TOS_LABEL % |
549 | @@ -561,15 +560,17 @@ | |||
550 | 561 | 560 | ||
551 | 562 | def test_set_titles(self): | 561 | def test_set_titles(self): |
552 | 563 | """Test that the titles are set.""" | 562 | """Test that the titles are set.""" |
557 | 564 | self.view.setTitle(VERIFY_EMAIL_TITLE) | 563 | self.view.header.set_title(VERIFY_EMAIL_CONTENT) |
558 | 565 | self.view.wizard().app_name | 564 | self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % { |
555 | 566 | self.view.wizard().field("email_address").toString() | ||
556 | 567 | self.view.setSubTitle(VERIFY_EMAIL_CONTENT % { | ||
559 | 568 | "app_name": None, | 565 | "app_name": None, |
560 | 569 | "email": None, | 566 | "email": None, |
561 | 570 | }) | 567 | }) |
562 | 571 | self.mocker.replay() | 568 | self.mocker.replay() |
564 | 572 | self.controller._set_titles() | 569 | self.view.header.set_title(VERIFY_EMAIL_CONTENT) |
565 | 570 | self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % { | ||
566 | 571 | "app_name": None, | ||
567 | 572 | "email": None, | ||
568 | 573 | }) | ||
569 | 573 | 574 | ||
570 | 574 | def test_validate_email(self): | 575 | def test_validate_email(self): |
571 | 575 | """Test the callback.""" | 576 | """Test the callback.""" |
572 | @@ -626,10 +627,21 @@ | |||
573 | 626 | 627 | ||
574 | 627 | def test_set_ui(self): | 628 | def test_set_ui(self): |
575 | 628 | """Test the process that sets the ui.""" | 629 | """Test the process that sets the ui.""" |
580 | 629 | self.view.next = -1 | 630 | self.controller._title = ERROR |
581 | 630 | self.view.ui.error_message_label | 631 | self.controller._subtitle = ERROR |
582 | 631 | self.mocker.result(self.view) | 632 | self.view.next = -1 |
583 | 632 | self.view.setText(ERROR) | 633 | self.view.ui.error_message_label.setText(ERROR) |
584 | 634 | self.view.header.set_title(ERROR) | ||
585 | 635 | self.view.header.set_subtitle(ERROR) | ||
586 | 636 | self.mocker.replay() | ||
587 | 637 | self.controller.setupUi(self.view) | ||
588 | 638 | |||
589 | 639 | def test_hide_titles(self): | ||
590 | 640 | """Test how the different titles are set.""" | ||
591 | 641 | self.view.next = -1 | ||
592 | 642 | self.view.ui.error_message_label.setText(ERROR) | ||
593 | 643 | self.view.header.set_title('') | ||
594 | 644 | self.view.header.set_subtitle('') | ||
595 | 633 | self.mocker.replay() | 645 | self.mocker.replay() |
596 | 634 | self.controller.setupUi(self.view) | 646 | self.controller.setupUi(self.view) |
597 | 635 | 647 | ||
598 | @@ -648,10 +660,21 @@ | |||
599 | 648 | 660 | ||
600 | 649 | def test_set_ui(self): | 661 | def test_set_ui(self): |
601 | 650 | """Test the process that sets the ui.""" | 662 | """Test the process that sets the ui.""" |
606 | 651 | self.view.next = -1 | 663 | self.controller._title = SUCCESS |
607 | 652 | self.view.ui.success_message_label | 664 | self.controller._subtitle = SUCCESS |
608 | 653 | self.mocker.result(self.view) | 665 | self.view.next = -1 |
609 | 654 | self.view.setText(SUCCESS) | 666 | self.view.ui.success_message_label.setText(SUCCESS) |
610 | 667 | self.view.header.set_title(SUCCESS) | ||
611 | 668 | self.view.header.set_subtitle(SUCCESS) | ||
612 | 669 | self.mocker.replay() | ||
613 | 670 | self.controller.setupUi(self.view) | ||
614 | 671 | |||
615 | 672 | def test_hide_titles(self): | ||
616 | 673 | """Test how the different titles are set.""" | ||
617 | 674 | self.view.next = -1 | ||
618 | 675 | self.view.ui.success_message_label.setText(SUCCESS) | ||
619 | 676 | self.view.header.set_title('') | ||
620 | 677 | self.view.header.set_subtitle('') | ||
621 | 655 | self.mocker.replay() | 678 | self.mocker.replay() |
622 | 656 | self.controller.setupUi(self.view) | 679 | self.controller.setupUi(self.view) |
623 | 657 | 680 | ||
624 | @@ -851,6 +874,7 @@ | |||
625 | 851 | 874 | ||
626 | 852 | def test_set_translated_strings(self): | 875 | def test_set_translated_strings(self): |
627 | 853 | """Ensure that the correct strings are set.""" | 876 | """Ensure that the correct strings are set.""" |
628 | 877 | self.controller._subtitle = PASSWORD_HELP | ||
629 | 854 | self.view.ui.reset_code_line_edit.setPlaceholderText(RESET_CODE_ENTRY) | 878 | self.view.ui.reset_code_line_edit.setPlaceholderText(RESET_CODE_ENTRY) |
630 | 855 | self.view.ui.password_line_edit.setPlaceholderText(PASSWORD1_ENTRY) | 879 | self.view.ui.password_line_edit.setPlaceholderText(PASSWORD1_ENTRY) |
631 | 856 | self.view.ui.confirm_password_line_edit.setPlaceholderText( | 880 | self.view.ui.confirm_password_line_edit.setPlaceholderText( |
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?