Merge lp:~diegosarmentero/ubuntuone-windows-installer/bug-820872 into lp:ubuntuone-windows-installer

Proposed by Diego Sarmentero
Status: Merged
Approved by: Roberto Alsina
Approved revision: 38
Merged at revision: 33
Proposed branch: lp:~diegosarmentero/ubuntuone-windows-installer/bug-820872
Merge into: lp:ubuntuone-windows-installer
Diff against target: 125 lines (+42/-11)
3 files modified
data/qt/ubuntuone.qss (+5/-0)
ubuntuone_installer/gui/qt/gui.py (+16/-6)
ubuntuone_installer/gui/qt/tests/test_gui.py (+21/-5)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/bug-820872
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+71773@code.launchpad.net

Commit message

Show Form Errors at the bottom of each Page.

Description of the change

Show Form Errors at the bottom of each Page.

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

adding tests for adding and removing the form error message.

37. By Diego Sarmentero

reverting changes in qss and setup_account.ui

38. By Diego Sarmentero

adding missing style to qss

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

Looks great!

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

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/qt/ubuntuone.qss'
--- data/qt/ubuntuone.qss 2011-08-11 11:58:23 +0000
+++ data/qt/ubuntuone.qss 2011-08-17 14:36:24 +0000
@@ -169,3 +169,8 @@
169 background: #f7f6f5;169 background: #f7f6f5;
170 alternate-background-color: #efedec;170 alternate-background-color: #efedec;
171}171}
172
173QLabel#form_errors{
174 font: bold 14px;
175 color: #dd4814;
176}
172177
=== modified file 'ubuntuone_installer/gui/qt/gui.py'
--- ubuntuone_installer/gui/qt/gui.py 2011-08-15 21:41:54 +0000
+++ ubuntuone_installer/gui/qt/gui.py 2011-08-17 14:36:24 +0000
@@ -302,6 +302,11 @@
302 self.setWizardStyle(self.ModernStyle)302 self.setWizardStyle(self.ModernStyle)
303 self.close_callback = close_callback303 self.close_callback = close_callback
304304
305 # Label for Form Errors
306 self.form_errors_label = QtGui.QLabel()
307 self.form_errors_label.setObjectName("form_errors")
308 self.form_errors_label.hide()
309
305 self.setSideWidget(SideWidget())310 self.setSideWidget(SideWidget())
306 self.overlay = LoadingOverlay(self)311 self.overlay = LoadingOverlay(self)
307312
@@ -412,8 +417,7 @@
412 def creds_eb(self, exc):417 def creds_eb(self, exc):
413 """Handle credentials error."""418 """Handle credentials error."""
414 self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE419 self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE
415 self.critical(self, CREDENTIALS_ERROR_TITLE,420 self.critical(CREDENTIALS_ERROR % exc.value)
416 CREDENTIALS_ERROR % exc.value)
417 logger.error(421 logger.error(
418 'Error while getting the credentials: %r', exc.value)422 'Error while getting the credentials: %r', exc.value)
419 self.close()423 self.close()
@@ -426,14 +430,20 @@
426 else:430 else:
427 self.LICENSE_PAGE._next_id = self.local_folders_page_id431 self.LICENSE_PAGE._next_id = self.local_folders_page_id
428432
429 def critical(self, *args, **kwargs):433 def critical(self, message):
430 """Wrapper for QMessageBox.critical that hides the overlay."""434 """Show a message at the bottom of the page on form errors."""
431 self.overlay.hide()435 self.overlay.hide()
432 QtGui.QMessageBox.critical(*args, **kwargs)436 self.form_errors_label.setText(message)
437 self.form_errors_label.show()
438 if self.currentPage():
439 self.currentPage().layout().addWidget(self.form_errors_label)
433440
434 def next(self):441 def next(self):
435 """Show the next page to display."""442 """Show the next page to display and remove the form errors label."""
436 self.overlay.hide()443 self.overlay.hide()
444 self.form_errors_label.hide()
445 self.currentPage().layout().removeWidget(self.form_errors_label)
446 self.form_errors_label.setParent(None)
437 super(MainWindow, self).next()447 super(MainWindow, self).next()
438448
439 def nextId(self):449 def nextId(self):
440450
=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-15 21:41:54 +0000
+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-17 14:36:24 +0000
@@ -262,10 +262,9 @@
262 def test_critical(self):262 def test_critical(self):
263 """Show a critical popup, but first hide the overlay."""263 """Show a critical popup, but first hide the overlay."""
264 self.assertEqual(self.ui.overlay.hide_counter, 1)264 self.assertEqual(self.ui.overlay.hide_counter, 1)
265 self.patch(gui.QtGui.QMessageBox, "critical", self._set_called)
266 self.ui.critical("WORRY!")265 self.ui.critical("WORRY!")
267 self.assertEqual(self.ui.overlay.hide_counter, 2)266 self.assertEqual(self.ui.overlay.hide_counter, 2)
268 self.assertEqual(self._called, (('WORRY!',), {}))267 self.assertEqual(self.ui.form_errors_label.text(), "WORRY!")
269268
270 def test_forgotten_password_controller_error(self):269 def test_forgotten_password_controller_error(self):
271 """When there is an error, it should hide the overlay."""270 """When there is an error, it should hide the overlay."""
@@ -311,11 +310,29 @@
311310
312 def test_next_hides_overlay(self):311 def test_next_hides_overlay(self):
313 """Make sure next() hides the overlay."""312 """Make sure next() hides the overlay."""
313 self.ui.setStartId(self.ui.LICENSE_PAGE_ID)
314 self.ui.restart()
315 self.ui.show()
314 self.ui.next()316 self.ui.next()
315 # This is 2 because we hide it once on __init__()317 # This is 2 because we hide it once on __init__()
316 # and then again on next()318 # and then again on next()
317 self.assertEqual(self.ui.overlay.hide_counter, 2)319 self.assertEqual(self.ui.overlay.hide_counter, 2)
318320
321 def test_insert_remove_critical_message(self):
322 """Make sure critical message is added and next() removes it."""
323 self.ui.setStartId(self.ui.LICENSE_PAGE_ID)
324 self.ui.restart()
325 self.ui.show()
326 license_page = self.ui.page(self.ui.LICENSE_PAGE_ID)
327 self.assertEqual(self.ui.form_errors_label.parentWidget(), None)
328 self.ui.critical("test critical message")
329 self.assertEqual(self.ui.form_errors_label.parentWidget(),
330 license_page)
331 self.assertEqual(self.ui.form_errors_label.text(),
332 "test critical message")
333 self.ui.next()
334 self.assertEqual(self.ui.form_errors_label.parentWidget(), None)
335
319 def test_done_calls_custom_close_callback(self):336 def test_done_calls_custom_close_callback(self):
320 """When closing the window, close_callback is called."""337 """When closing the window, close_callback is called."""
321 gui.AreYouSure.result = 0338 gui.AreYouSure.result = 0
@@ -938,7 +955,6 @@
938 self.patch(gui, "LocalFoldersPage", FakeLocalFoldersPage)955 self.patch(gui, "LocalFoldersPage", FakeLocalFoldersPage)
939 self.patch(qt.preferences, "PreferencesPanel", FakePreferencesPanel)956 self.patch(qt.preferences, "PreferencesPanel", FakePreferencesPanel)
940 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)957 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)
941 self.patch(gui.QtGui.QMessageBox, "critical", self._set_called)
942 self.patch(gui, "CredentialsManagementTool",958 self.patch(gui, "CredentialsManagementTool",
943 FakeFailingCredentialsManagementTool)959 FakeFailingCredentialsManagementTool)
944 super(CredsFailureMainWindowTestCase, self).setUp()960 super(CredsFailureMainWindowTestCase, self).setUp()
@@ -949,5 +965,5 @@
949965
950 def test_critical(self):966 def test_critical(self):
951 """Credential errors should display a critical message."""967 """Credential errors should display a critical message."""
952 self.assertEqual(self._called, ((self.ui, 'Error getting credentials',968 self.assertEqual(self.ui.form_errors_label.text(),
953 "Application will close.\n\nException()"), {}))969 "Application will close.\n\nException()")

Subscribers

People subscribed via source and target branches