Merge lp:~diegosarmentero/ubuntuone-windows-installer/ui-improves into lp:ubuntuone-windows-installer
- ui-improves
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Roberto Alsina |
Approved revision: | 41 |
Merged at revision: | 29 |
Proposed branch: | lp:~diegosarmentero/ubuntuone-windows-installer/ui-improves |
Merge into: | lp:ubuntuone-windows-installer |
Diff against target: |
800 lines (+520/-33) 12 files modified
data/qt/folders.ui (+58/-0) data/qt/images.qrc (+1/-0) data/qt/local_folders.ui (+5/-2) data/qt/preferences.ui (+20/-0) data/qt/ubuntuone.qss (+36/-0) ubuntuone_installer/gui/qt/folders.py (+67/-0) ubuntuone_installer/gui/qt/gui.py (+7/-0) ubuntuone_installer/gui/qt/local_folders.py (+55/-15) ubuntuone_installer/gui/qt/preferences.py (+100/-0) ubuntuone_installer/gui/qt/setup_account.py (+0/-10) ubuntuone_installer/gui/qt/sync_now_or_later.py (+7/-0) ubuntuone_installer/gui/qt/tests/test_gui.py (+164/-6) |
To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/ui-improves |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart (community) | Approve | ||
Review via email: mp+71116@code.launchpad.net |
Commit message
Page 18 and 19 from the Installer complete.
Some Tests added and other fixed.
UI Bugs Fixed.
Description of the change
Page 18 and 19 from the Installer complete.
Some Tests added and other fixed.
UI Bugs Fixed.
- 34. By Diego Sarmentero
-
removing commented code.
- 35. By Diego Sarmentero
-
adding errback to show_hide_offer
- 36. By Diego Sarmentero
-
qss modified to remove unnecessary border.
- 37. By Diego Sarmentero
-
fixing import order.
removing twisted debug settings from local_folders. - 38. By Diego Sarmentero
-
fixing show_hide_offer docstring
- 39. By Diego Sarmentero
-
replacing show_hide_offer to use inlineCallbacks
- 40. By Diego Sarmentero
-
grouping together 3rd party imports
Diego Sarmentero (diegosarmentero) wrote : | # |
* The branch lacks of tests for the new modules local_folders.py and preferences.py.
* Why you removed the LocalFoldersTes
* Also, test for local_folders.py is needed: I understand there was no former tests for this module, so I request just a test for the new functionality added/modified (show_hide_offer and on_add_
- Local Folders Tests are going to be implemented in another branch because they have to be made from scratch (I'm adding that again and leave it as skipped)
* Question, why did you remove this code? set_button_
- This was an old implementation that didn't make the proper validation, now the validation function is working correctly and this code is no longer necessary.
- 41. By Diego Sarmentero
-
fixes in local_folders.
tests improved.
Natalia Bidart (nataliabidart) wrote : | # |
Looks good!
Preview Diff
1 | === added file 'data/folder.png' |
2 | Binary files data/folder.png 1970-01-01 00:00:00 +0000 and data/folder.png 2011-08-11 17:47:23 +0000 differ |
3 | === added file 'data/qt/folders.ui' |
4 | --- data/qt/folders.ui 1970-01-01 00:00:00 +0000 |
5 | +++ data/qt/folders.ui 2011-08-11 17:47:23 +0000 |
6 | @@ -0,0 +1,58 @@ |
7 | +<?xml version="1.0" encoding="UTF-8"?> |
8 | +<ui version="4.0"> |
9 | + <class>Form</class> |
10 | + <widget class="QWidget" name="Form"> |
11 | + <property name="geometry"> |
12 | + <rect> |
13 | + <x>0</x> |
14 | + <y>0</y> |
15 | + <width>480</width> |
16 | + <height>374</height> |
17 | + </rect> |
18 | + </property> |
19 | + <property name="windowTitle"> |
20 | + <string>Form</string> |
21 | + </property> |
22 | + <layout class="QVBoxLayout" name="verticalLayout"> |
23 | + <item> |
24 | + <layout class="QHBoxLayout" name="horizontalLayout"> |
25 | + <item> |
26 | + <spacer name="horizontalSpacer"> |
27 | + <property name="orientation"> |
28 | + <enum>Qt::Horizontal</enum> |
29 | + </property> |
30 | + <property name="sizeHint" stdset="0"> |
31 | + <size> |
32 | + <width>40</width> |
33 | + <height>20</height> |
34 | + </size> |
35 | + </property> |
36 | + </spacer> |
37 | + </item> |
38 | + <item> |
39 | + <widget class="QPushButton" name="check_settings_button"> |
40 | + <property name="text"> |
41 | + <string>Check bandwidth settings</string> |
42 | + </property> |
43 | + </widget> |
44 | + </item> |
45 | + <item> |
46 | + <spacer name="horizontalSpacer_2"> |
47 | + <property name="orientation"> |
48 | + <enum>Qt::Horizontal</enum> |
49 | + </property> |
50 | + <property name="sizeHint" stdset="0"> |
51 | + <size> |
52 | + <width>40</width> |
53 | + <height>20</height> |
54 | + </size> |
55 | + </property> |
56 | + </spacer> |
57 | + </item> |
58 | + </layout> |
59 | + </item> |
60 | + </layout> |
61 | + </widget> |
62 | + <resources/> |
63 | + <connections/> |
64 | +</ui> |
65 | |
66 | === modified file 'data/qt/images.qrc' |
67 | --- data/qt/images.qrc 2011-08-05 16:55:58 +0000 |
68 | +++ data/qt/images.qrc 2011-08-11 17:47:23 +0000 |
69 | @@ -15,5 +15,6 @@ |
70 | <file>../u1icon.png</file> |
71 | <file>../ubuntu_one_favicon.png</file> |
72 | <file>../win_installer_graphic.png</file> |
73 | + <file>../folder.png</file> |
74 | </qresource> |
75 | </RCC> |
76 | |
77 | === modified file 'data/qt/local_folders.ui' |
78 | --- data/qt/local_folders.ui 2011-08-04 15:32:35 +0000 |
79 | +++ data/qt/local_folders.ui 2011-08-11 17:47:23 +0000 |
80 | @@ -99,7 +99,10 @@ |
81 | <item> |
82 | <widget class="AddFolderButton" name="add_folder_button"> |
83 | <property name="text"> |
84 | - <string>Add a folder</string> |
85 | + <string>Add a folder from this computer</string> |
86 | + </property> |
87 | + <property name="DisabledState" stdset="0"> |
88 | + <bool>false</bool> |
89 | </property> |
90 | </widget> |
91 | </item> |
92 | @@ -159,7 +162,7 @@ |
93 | </spacer> |
94 | </item> |
95 | <item> |
96 | - <widget class="QPushButton" name="pushButton"> |
97 | + <widget class="QPushButton" name="add_storage_button"> |
98 | <property name="text"> |
99 | <string>Add more storage</string> |
100 | </property> |
101 | |
102 | === added file 'data/qt/preferences.ui' |
103 | --- data/qt/preferences.ui 1970-01-01 00:00:00 +0000 |
104 | +++ data/qt/preferences.ui 2011-08-11 17:47:23 +0000 |
105 | @@ -0,0 +1,20 @@ |
106 | +<?xml version="1.0" encoding="UTF-8"?> |
107 | +<ui version="4.0"> |
108 | + <class>Form</class> |
109 | + <widget class="QWidget" name="Form"> |
110 | + <property name="geometry"> |
111 | + <rect> |
112 | + <x>0</x> |
113 | + <y>0</y> |
114 | + <width>480</width> |
115 | + <height>374</height> |
116 | + </rect> |
117 | + </property> |
118 | + <property name="windowTitle"> |
119 | + <string>Form</string> |
120 | + </property> |
121 | + <layout class="QVBoxLayout" name="verticalLayout"/> |
122 | + </widget> |
123 | + <resources/> |
124 | + <connections/> |
125 | +</ui> |
126 | |
127 | === modified file 'data/qt/ubuntuone.qss' |
128 | --- data/qt/ubuntuone.qss 2011-08-05 19:54:27 +0000 |
129 | +++ data/qt/ubuntuone.qss 2011-08-11 17:47:23 +0000 |
130 | @@ -109,6 +109,20 @@ |
131 | border-color: #999999; |
132 | } |
133 | |
134 | +QPushButton:hover[DisabledState="false"] { |
135 | + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, |
136 | + stop: 0 #ffb19c,stop: 1.0 #dd4814); |
137 | + color: white; |
138 | + border-color: #999999; |
139 | +} |
140 | + |
141 | +QPushButton:pressed[DisabledState="false"] { |
142 | + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, |
143 | + stop: 0 #b93f14,stop: 1.0 #dd4814); |
144 | + color: white; |
145 | + border-color: #999999; |
146 | +} |
147 | + |
148 | QFrame#frm_box { |
149 | background: #ffffff; |
150 | border-radius: 5px; |
151 | @@ -133,3 +147,25 @@ |
152 | QLabel#title_label{ |
153 | font-size: 20px; |
154 | } |
155 | + |
156 | +QGroupBox { |
157 | + padding-top: 30px; |
158 | + border: none; |
159 | + margin-top: 1ex; |
160 | + font: bold 15px; |
161 | +} |
162 | + |
163 | +QGroupBox::title { |
164 | + color: #333333; |
165 | +} |
166 | + |
167 | +QGroupBox#bandwidth_settings{ |
168 | + border-style: dotted; |
169 | + border-color: #939389; |
170 | + border-bottom-width: 1px; |
171 | +} |
172 | + |
173 | +QTreeView { |
174 | + background: #f7f6f5; |
175 | + alternate-background-color: #efedec; |
176 | +} |
177 | |
178 | === added file 'ubuntuone_installer/gui/qt/folders.py' |
179 | --- ubuntuone_installer/gui/qt/folders.py 1970-01-01 00:00:00 +0000 |
180 | +++ ubuntuone_installer/gui/qt/folders.py 2011-08-11 17:47:23 +0000 |
181 | @@ -0,0 +1,67 @@ |
182 | +# -*- coding: utf-8 -*- |
183 | + |
184 | +# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
185 | +# Diego Sarmentero <diego.sarmentero@canonical.com> |
186 | +# |
187 | +# Copyright 2011 Canonical Ltd. |
188 | +# |
189 | +# This program is free software: you can redistribute it and/or modify it |
190 | +# under the terms of the GNU General Public License version 3, as published |
191 | +# by the Free Software Foundation. |
192 | +# |
193 | +# This program is distributed in the hope that it will be useful, but |
194 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
195 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
196 | +# PURPOSE. See the GNU General Public License for more details. |
197 | +# |
198 | +# You should have received a copy of the GNU General Public License along |
199 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
200 | + |
201 | +"""Page to list folders in a Ubuntu One account.""" |
202 | + |
203 | +import gettext |
204 | + |
205 | +from PyQt4 import QtCore, QtGui |
206 | +from ubuntu_sso.qt.gui import SSOWizardPage |
207 | +from ubuntuone.controlpanel.gui.qt import folders |
208 | + |
209 | +from ubuntuone_installer.gui.qt.ui import folders_ui |
210 | + |
211 | +_ = gettext.gettext |
212 | + |
213 | + |
214 | +class FoldersPage(SSOWizardPage): |
215 | + """Wizard page to list and manage an account's folders.""" |
216 | + |
217 | + def __init__(self, parent=None): |
218 | + super(FoldersPage, self).__init__(folders_ui.Ui_Form(), None, parent) |
219 | + self.setTitle(_("Syncing your computer with the cloud")) |
220 | + self.folders_widget = folders.FoldersPanel() |
221 | + self.layout().insertWidget( |
222 | + self.layout().count() - 1, self.folders_widget) |
223 | + self.folders_widget.ui.share_publish_button.hide() |
224 | + self.folders_widget.ui.add_folder_button.hide() |
225 | + self.folders_widget.ui.folders.setHeaderHidden(True) |
226 | + self.folders_widget.ui.folders.setColumnHidden(2, True) |
227 | + |
228 | + # Invalid name "initializePage" |
229 | + # pylint: disable=C0103 |
230 | + |
231 | + def initializePage(self): |
232 | + """Set Folders Page navigation buttons.""" |
233 | + self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False) |
234 | + self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, False) |
235 | + self.wizard().setButtonLayout([ |
236 | + QtGui.QWizard.BackButton, |
237 | + QtGui.QWizard.Stretch, |
238 | + QtGui.QWizard.NextButton]) |
239 | + self.wizard()._next_id = self.wizard().CONGRATULATIONS_PAGE |
240 | + |
241 | + # pylint: enable=C0103 |
242 | + |
243 | + @QtCore.pyqtSlot() |
244 | + def on_check_settings_button_clicked(self): |
245 | + """Show the Preferences Page when the user click on Settings button.""" |
246 | + self.wizard()._next_id = \ |
247 | + self.wizard().preferences_page_id |
248 | + self.wizard().next() |
249 | |
250 | === modified file 'ubuntuone_installer/gui/qt/gui.py' |
251 | --- ubuntuone_installer/gui/qt/gui.py 2011-08-10 19:56:42 +0000 |
252 | +++ ubuntuone_installer/gui/qt/gui.py 2011-08-11 17:47:23 +0000 |
253 | @@ -2,6 +2,7 @@ |
254 | |
255 | # Authors: Alejandro J. Cura <alecu@canonical.com> |
256 | # Roberto Alsina <roberto.alsina@canonical.com> |
257 | +# Diego Sarmentero <diego.sarmentero@canonical.com> |
258 | # |
259 | # Copyright 2011 Canonical Ltd. |
260 | # |
261 | @@ -72,8 +73,10 @@ |
262 | |
263 | from ubuntuone_installer.gui.qt.are_you_sure import AreYouSure |
264 | from ubuntuone_installer.gui.qt.currentuser import CurrentUserController |
265 | +from ubuntuone_installer.gui.qt.folders import FoldersPage |
266 | from ubuntuone_installer.gui.qt.forgotten import ForgottenPasswordController |
267 | from ubuntuone_installer.gui.qt.local_folders import LocalFoldersPage |
268 | +from ubuntuone_installer.gui.qt.preferences import PreferencesPage |
269 | from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage |
270 | from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage |
271 | from ubuntuone_installer.gui.qt.side_widget import SideWidget |
272 | @@ -388,6 +391,10 @@ |
273 | self.local_folders_page = LocalFoldersPage() |
274 | self.local_folders_page_id = self.addPage(self.local_folders_page) |
275 | self.SYNC_NOW_OR_LATER_PAGE = self.addPage(SyncNowOrLaterPage()) |
276 | + self.folders_page = FoldersPage() |
277 | + self.folders_page_id = self.addPage(self.folders_page) |
278 | + self.preferences_page = PreferencesPage() |
279 | + self.preferences_page_id = self.addPage(self.preferences_page) |
280 | self.CONGRATULATIONS_PAGE = self.addPage(CongratulationsPage()) |
281 | |
282 | self.currentIdChanged.connect(self.on_currentIdChanged) |
283 | |
284 | === modified file 'ubuntuone_installer/gui/qt/local_folders.py' |
285 | --- ubuntuone_installer/gui/qt/local_folders.py 2011-08-04 15:32:35 +0000 |
286 | +++ ubuntuone_installer/gui/qt/local_folders.py 2011-08-11 17:47:23 +0000 |
287 | @@ -24,10 +24,10 @@ |
288 | import threading |
289 | import Queue |
290 | |
291 | +from twisted.internet.defer import inlineCallbacks |
292 | from PyQt4 import QtCore, QtGui |
293 | - |
294 | -from ubuntuone.controlpanel.gui import humanize |
295 | - |
296 | +from ubuntuone.controlpanel.gui import humanize, sign_url |
297 | +from ubuntuone.platform.credentials import CredentialsManagementTool |
298 | from ubuntu_sso.qt.gui import SSOWizardPage |
299 | |
300 | from ubuntuone_installer.gui.qt.ui import local_folders_ui |
301 | @@ -38,6 +38,14 @@ |
302 | LOCAL_FOLDERS_CALCULATING, |
303 | ) |
304 | |
305 | +from ubuntuone_installer.logger import setup_logging |
306 | + |
307 | + |
308 | +# Invalid name logger |
309 | +# pylint: disable=C0103 |
310 | +logger = setup_logging('qt.local_folders') |
311 | +# pylint: enable=C0103 |
312 | + |
313 | |
314 | class FolderItem(QtGui.QTreeWidgetItem): |
315 | """Class representing a folder in the folder list UI.""" |
316 | @@ -90,14 +98,19 @@ |
317 | |
318 | # initializePage is inherited |
319 | # pylint: disable=C0103 |
320 | + @inlineCallbacks |
321 | def initializePage(self): |
322 | """UI details.""" |
323 | - self.wizard()._next_id = None |
324 | - |
325 | - def quota(self): |
326 | - """The quota available to the user.""" |
327 | - # FIXME: get this from real life |
328 | - return 2 * 1024 * 1024 |
329 | + self.wizard().setButtonLayout([ |
330 | + QtGui.QWizard.Stretch, |
331 | + QtGui.QWizard.NextButton]) |
332 | + self.wizard()._next_id = self.wizard().SYNC_NOW_OR_LATER_PAGE |
333 | + # Start with this invisible |
334 | + self.ui.offer_frame.setVisible(False) |
335 | + if not self.ui.folder_list.topLevelItemCount(): |
336 | + for folder_name in self.default_folders(): |
337 | + self.add_folder(folder_name) |
338 | + yield self.update_sizes() |
339 | |
340 | def default_folders(self): |
341 | """Return a list of the folders to add by default.""" |
342 | @@ -126,6 +139,7 @@ |
343 | self.items[path] = item |
344 | return item |
345 | |
346 | + @inlineCallbacks |
347 | def update_sizes(self): |
348 | """Poll the queue were the threads put the size info.""" |
349 | try: |
350 | @@ -144,22 +158,30 @@ |
351 | total += item.size |
352 | |
353 | if isinstance(total, long): |
354 | - self.show_hide_offer(total) |
355 | + yield self.show_hide_offer(total) |
356 | total = humanize(total) |
357 | else: |
358 | - self.show_hide_offer(0) |
359 | + yield self.show_hide_offer(0) |
360 | self.ui.folder_list.headerItem().setText( |
361 | 1, LOCAL_FOLDERS_SPACE_HEADER % total) |
362 | |
363 | + @inlineCallbacks |
364 | def show_hide_offer(self, cur_size): |
365 | - """Show or hide the offer to buy space according to the total size.""" |
366 | - quota = self.quota() |
367 | - |
368 | + """Show or hide the offer to buy space according to the total size. |
369 | + |
370 | + Returns a deferred that is triggered when the update is finished. |
371 | + |
372 | + """ |
373 | + try: |
374 | + user_info = yield self.ui.add_folder_button.backend.account_info() |
375 | + except: |
376 | + logger.exception('Error while trying to update que quota:') |
377 | + |
378 | + quota = user_info['quota_total'] |
379 | if cur_size > quota: |
380 | self.ui.offer_frame.setVisible(True) |
381 | else: |
382 | self.ui.offer_frame.setVisible(False) |
383 | - |
384 | self.ui.offer_label.setText(LOCAL_FOLDERS_OFFER_LABEL % |
385 | {"quota": humanize(quota)}) |
386 | |
387 | @@ -178,3 +200,21 @@ |
388 | self.ui.folder_list.takeTopLevelItem( |
389 | self.ui.folder_list.indexOfTopLevelItem(item)) |
390 | self.update_sizes() |
391 | + |
392 | + @inlineCallbacks |
393 | + @QtCore.pyqtSlot() |
394 | + def on_add_storage_button_clicked(self): |
395 | + """user clicked on the "Add more storage" button.""" |
396 | + |
397 | + try: |
398 | + credtool = CredentialsManagementTool() |
399 | + creds = yield credtool.find_credentials() |
400 | + except: |
401 | + logger.exception('Error while trying to update que quota:') |
402 | + |
403 | + if creds: |
404 | + signed_url = sign_url( |
405 | + "https://one.ubuntu.com/services/#storage_panel", creds) |
406 | + else: |
407 | + signed_url = "https://one.ubuntu.com/services/#storage_panel" |
408 | + QtGui.QDesktopServices.openUrl(QtCore.QUrl(signed_url)) |
409 | |
410 | === added file 'ubuntuone_installer/gui/qt/preferences.py' |
411 | --- ubuntuone_installer/gui/qt/preferences.py 1970-01-01 00:00:00 +0000 |
412 | +++ ubuntuone_installer/gui/qt/preferences.py 2011-08-11 17:47:23 +0000 |
413 | @@ -0,0 +1,100 @@ |
414 | +# -*- coding: utf-8 -*- |
415 | + |
416 | +# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
417 | +# Diego Sarmentero <diego.sarmentero@canonical.com> |
418 | +# |
419 | +# Copyright 2011 Canonical Ltd. |
420 | +# |
421 | +# This program is free software: you can redistribute it and/or modify it |
422 | +# under the terms of the GNU General Public License version 3, as published |
423 | +# by the Free Software Foundation. |
424 | +# |
425 | +# This program is distributed in the hope that it will be useful, but |
426 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
427 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
428 | +# PURPOSE. See the GNU General Public License for more details. |
429 | +# |
430 | +# You should have received a copy of the GNU General Public License along |
431 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
432 | + |
433 | +"""Page to list folders in a Ubuntu One account.""" |
434 | + |
435 | +import gettext |
436 | + |
437 | +from PyQt4 import QtGui |
438 | +from ubuntuone.controlpanel.gui.qt import preferences |
439 | +from ubuntu_sso.qt.gui import SSOWizardPage |
440 | + |
441 | +from ubuntuone_installer.gui.qt.ui import preferences_ui |
442 | + |
443 | +_ = gettext.gettext |
444 | + |
445 | + |
446 | +class PreferencesPage(SSOWizardPage): |
447 | + """Wizard page to list and manage an account's folders.""" |
448 | + |
449 | + def __init__(self, parent=None): |
450 | + super(PreferencesPage, self).__init__( |
451 | + preferences_ui.Ui_Form(), None, parent) |
452 | + self.preferences_widget = preferences.PreferencesPanel() |
453 | + self.layout().addWidget(self.preferences_widget) |
454 | + self.preferences_widget.ui.apply_changes_button.hide() |
455 | + self.preferences_widget.ui.restore_defaults_button.hide() |
456 | + |
457 | + # Invalid name "initializePage" |
458 | + # pylint: disable=C0103 |
459 | + |
460 | + def initializePage(self): |
461 | + self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, True) |
462 | + self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, True) |
463 | + # This is just to catch an exception thrown when nothing |
464 | + # is connected to the signal. It's not an exceptional |
465 | + # condition at all. |
466 | + try: |
467 | + self.wizard().customButtonClicked.disconnect() |
468 | + except TypeError: |
469 | + pass |
470 | + self.wizard()._next_id = None |
471 | + self.setButtonText(QtGui.QWizard.CustomButton1, |
472 | + _("Apply these settings >")) |
473 | + self.setButtonText(QtGui.QWizard.CustomButton2, _("Default settings")) |
474 | + |
475 | + self.wizard().setButtonLayout([ |
476 | + QtGui.QWizard.BackButton, |
477 | + QtGui.QWizard.Stretch, |
478 | + QtGui.QWizard.CustomButton2, |
479 | + QtGui.QWizard.CustomButton1]) |
480 | + self.wizard().button(QtGui.QWizard.CustomButton1).setDefault(True) |
481 | + self.wizard().button(QtGui.QWizard.CustomButton1).style().unpolish( |
482 | + self.wizard().button(QtGui.QWizard.CustomButton1)) |
483 | + self.wizard().button(QtGui.QWizard.CustomButton1).style().polish( |
484 | + self.wizard().button(QtGui.QWizard.CustomButton1)) |
485 | + |
486 | + self.wizard().customButtonClicked.connect(self._button_clicked) |
487 | + |
488 | + # pylint: enable=C0103 |
489 | + |
490 | + def _button_clicked(self, btn): |
491 | + """Receive custom wizard buttons clicks.""" |
492 | + if btn == QtGui.QWizard.CustomButton1: |
493 | + self.preferences_widget.on_apply_changes_button_clicked() |
494 | + self.cleanupPage() |
495 | + self.wizard().back() |
496 | + elif btn == QtGui.QWizard.CustomButton2: |
497 | + self.preferences_widget.on_restore_defaults_button_clicked() |
498 | + |
499 | + # Invalid name "cleanupPage" |
500 | + # pylint: disable=C0103 |
501 | + |
502 | + def cleanupPage(self): |
503 | + """Execute this cleanup function when the back button is pressed.""" |
504 | + self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False) |
505 | + self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, False) |
506 | + self.wizard().setButtonLayout([ |
507 | + QtGui.QWizard.BackButton, |
508 | + QtGui.QWizard.Stretch, |
509 | + QtGui.QWizard.NextButton]) |
510 | + self.wizard().setButtonText(QtGui.QWizard.NextButton, _("Sync Now!")) |
511 | + self.wizard()._next_id = self.wizard().CONGRATULATIONS_PAGE |
512 | + |
513 | + # pylint: enable=C0103 |
514 | |
515 | === modified file 'ubuntuone_installer/gui/qt/setup_account.py' |
516 | --- ubuntuone_installer/gui/qt/setup_account.py 2011-08-05 13:48:02 +0000 |
517 | +++ ubuntuone_installer/gui/qt/setup_account.py 2011-08-11 17:47:23 +0000 |
518 | @@ -22,7 +22,6 @@ |
519 | import re |
520 | |
521 | from PyQt4 import QtGui |
522 | -from PyQt4.QtCore import Qt |
523 | |
524 | from ubuntu_sso.qt import gui as sso_gui |
525 | |
526 | @@ -86,8 +85,6 @@ |
527 | self.ui.confirm_password_edit.textEdited.connect( |
528 | self.password_assistance) |
529 | self.password_assistance() |
530 | - self.ui.terms_checkbox.stateChanged.connect( |
531 | - self.set_button_setup_account_property) |
532 | |
533 | def name_assistance(self): |
534 | """Show help for the name field.""" |
535 | @@ -146,13 +143,6 @@ |
536 | |
537 | self.ui.password_assistance.setText("<br>".join(label_text)) |
538 | |
539 | - def set_button_setup_account_property(self, state): |
540 | - """Change the set_up_button disable property and reapply the style.""" |
541 | - self.ui.set_up_button.setProperty("DisabledState", |
542 | - state == Qt.Unchecked) |
543 | - self.ui.set_up_button.style().unpolish(self.ui.set_up_button) |
544 | - self.ui.set_up_button.style().polish(self.ui.set_up_button) |
545 | - |
546 | def showEvent(self, event): |
547 | """Set set_up_button as default button when the page is shown.""" |
548 | # This method should stays here because if we move it to initializePage |
549 | |
550 | === modified file 'ubuntuone_installer/gui/qt/sync_now_or_later.py' |
551 | --- ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-08-02 02:36:16 +0000 |
552 | +++ ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-08-11 17:47:23 +0000 |
553 | @@ -42,3 +42,10 @@ |
554 | self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False) |
555 | self.wizard().setOption(QtGui.QWizard.NoCancelButton, True) |
556 | self.wizard()._next_id = None |
557 | + |
558 | + def nextId(self): |
559 | + """Go to the next page depending on the select field.""" |
560 | + if self.field("sync_custom"): |
561 | + return self.wizard().folders_page_id |
562 | + else: |
563 | + return self.wizard().CONGRATULATIONS_PAGE |
564 | |
565 | === modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py' |
566 | --- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-10 20:12:08 +0000 |
567 | +++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-11 17:47:23 +0000 |
568 | @@ -25,10 +25,9 @@ |
569 | import tempfile |
570 | |
571 | from twisted.internet import defer |
572 | - |
573 | -from PyQt4 import QtCore |
574 | - |
575 | +from PyQt4 import QtGui, QtCore |
576 | from ubuntuone.platform.credentials import APP_NAME |
577 | +from ubuntuone.controlpanel.gui import qt |
578 | |
579 | from ubuntuone_installer.gui.qt import gui |
580 | from ubuntuone_installer.gui.qt.tests import BaseTestCase |
581 | @@ -108,6 +107,51 @@ |
582 | """Fake resize.""" |
583 | |
584 | |
585 | +class FakeLocalFoldersPage(QtGui.QWizardPage): |
586 | + """Fake Local Folders Page.""" |
587 | + |
588 | + |
589 | +class FakeUIFoldersPanel(QtGui.QWidget): |
590 | + """Fake UI Folders Page.""" |
591 | + |
592 | + def __init__(self, parent=None): |
593 | + QtGui.QWidget.__init__(self, parent) |
594 | + self.share_publish_button = QtGui.QPushButton() |
595 | + self.add_folder_button = QtGui.QPushButton() |
596 | + self.folders = QtGui.QTreeWidget() |
597 | + self.folders.setColumnCount(3) |
598 | + self.folders.setColumnHidden(2, True) |
599 | + |
600 | + |
601 | +class FakeFoldersPanel(QtGui.QWidget): |
602 | + """Fake Folders Page.""" |
603 | + |
604 | + ui = FakeUIFoldersPanel() |
605 | + |
606 | + |
607 | +class FakeUIPreferencesPanel(QtGui.QWidget): |
608 | + """Fake UI Preferences Page.""" |
609 | + |
610 | + apply_changes_button = QtGui.QPushButton() |
611 | + restore_defaults_button = QtGui.QPushButton() |
612 | + |
613 | + |
614 | +class FakePreferencesPanel(QtGui.QWidget): |
615 | + """Fake Preferences Page.""" |
616 | + |
617 | + ui = FakeUIPreferencesPanel() |
618 | + apply_button_clicked = False |
619 | + restore_button_clicked = False |
620 | + |
621 | + def on_apply_changes_button_clicked(self): |
622 | + """Set apply_button_clicked to True for PreferencesPage.""" |
623 | + self.apply_button_clicked = True |
624 | + |
625 | + def on_restore_defaults_button_clicked(self): |
626 | + """Set restore_button_clicked to True for PreferencesPage.""" |
627 | + self.restore_button_clicked = True |
628 | + |
629 | + |
630 | class MainWindowTestCase(BaseTestCase): |
631 | """Test the qt main window.""" |
632 | |
633 | @@ -126,10 +170,95 @@ |
634 | self.patch(gui, "ResetPasswordController", FakeController) |
635 | self.patch(gui, "AreYouSure", FakeAreYouSure) |
636 | self.patch(gui, "LoadingOverlay", FakeOverlay) |
637 | + self.patch(gui, "LocalFoldersPage", FakeLocalFoldersPage) |
638 | + self.patch(qt.preferences, "PreferencesPanel", FakePreferencesPanel) |
639 | + self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel) |
640 | self.patch(gui, "CredentialsManagementTool", |
641 | FakeFailureCredentialsManagementTool) |
642 | super(MainWindowTestCase, self).setUp() |
643 | |
644 | + def test_preferences_page(self): |
645 | + """Test Preferences Page UI display.""" |
646 | + preferences_page = self.ui.page(self.ui.preferences_page_id) |
647 | + |
648 | + # Show the preferences page |
649 | + self.ui.setStartId(self.ui.preferences_page_id) |
650 | + self.ui.restart() |
651 | + self.ui.show() |
652 | + |
653 | + btn_pref = preferences_page.preferences_widget.ui.apply_changes_button |
654 | + self.assertEqual(btn_pref.isVisible(), False) |
655 | + btn_pref = \ |
656 | + preferences_page.preferences_widget.ui.restore_defaults_button |
657 | + self.assertEqual(btn_pref.isVisible(), False) |
658 | + |
659 | + def test_preferences_page_navigation_buttons(self): |
660 | + """Check Preferences Page navigation buttons text.""" |
661 | + preferences_page = self.ui.page(self.ui.preferences_page_id) |
662 | + |
663 | + # Show the preferences page |
664 | + self.ui.setStartId(self.ui.preferences_page_id) |
665 | + self.ui.restart() |
666 | + self.ui.show() |
667 | + |
668 | + btn_pref = preferences_page.wizard().button( |
669 | + QtGui.QWizard.CustomButton1) |
670 | + self.assertEqual(btn_pref.text(), "Apply these settings >") |
671 | + btn_pref = preferences_page.wizard().button( |
672 | + QtGui.QWizard.CustomButton2) |
673 | + self.assertEqual(btn_pref.text(), "Default settings") |
674 | + |
675 | + def test_preferences_page_button_clicked(self): |
676 | + """Check Preferences Page navigation buttons text.""" |
677 | + preferences_page = self.ui.page(self.ui.preferences_page_id) |
678 | + |
679 | + # Show the preferences page |
680 | + self.ui.setStartId(self.ui.preferences_page_id) |
681 | + self.ui.restart() |
682 | + self.ui.show() |
683 | + |
684 | + preferences_page._button_clicked(QtGui.QWizard.CustomButton2) |
685 | + self.assertEqual( |
686 | + preferences_page.preferences_widget.restore_button_clicked, True) |
687 | + preferences_page._button_clicked(QtGui.QWizard.CustomButton1) |
688 | + self.assertEqual( |
689 | + preferences_page.preferences_widget.apply_button_clicked, True) |
690 | + # for Cleanup |
691 | + btn_pref = preferences_page.wizard().button(QtGui.QWizard.NextButton) |
692 | + self.assertEqual(btn_pref.text(), "Sync Now!") |
693 | + self.assertEqual(self.ui._next_id, self.ui.CONGRATULATIONS_PAGE) |
694 | + |
695 | + def test_folders_page(self): |
696 | + """Check Folders Page UI.""" |
697 | + folders_page = self.ui.page(self.ui.folders_page_id) |
698 | + |
699 | + # Show the preferences page |
700 | + self.ui.setStartId(self.ui.folders_page_id) |
701 | + self.ui.restart() |
702 | + self.ui.show() |
703 | + |
704 | + btn_folders = folders_page.folders_widget.ui.share_publish_button |
705 | + self.assertEqual(btn_folders.isVisible(), False) |
706 | + btn_folders = folders_page.folders_widget.ui.add_folder_button |
707 | + self.assertEqual(btn_folders.isVisible(), False) |
708 | + tree_folders = folders_page.folders_widget.ui.folders |
709 | + self.assertEqual(tree_folders.isHeaderHidden(), True) |
710 | + tree_folders = folders_page.folders_widget.ui.folders |
711 | + self.assertEqual(tree_folders.isColumnHidden(2), True) |
712 | + self.assertEqual(self.ui._next_id, self.ui.CONGRATULATIONS_PAGE) |
713 | + |
714 | + def test_folders_page_next_id(self): |
715 | + """Check Folders Page UI.""" |
716 | + folders_page = self.ui.page(self.ui.folders_page_id) |
717 | + |
718 | + # Show the preferences page |
719 | + self.ui.setStartId(self.ui.folders_page_id) |
720 | + self.ui.restart() |
721 | + self.ui.show() |
722 | + |
723 | + folders_page.on_check_settings_button_clicked() |
724 | + self.assertEqual(self.ui.currentId(), self.ui.preferences_page_id) |
725 | + |
726 | def test_critical(self): |
727 | """Show a critical popup, but first hide the overlay.""" |
728 | self.assertEqual(self.ui.overlay.hide_counter, 1) |
729 | @@ -165,19 +294,19 @@ |
730 | def test_overlay_connection_current_user(self): |
731 | """Make sure we don't lose connections to the overlay.""" |
732 | self.assertEqual(self.ui.overlay.show_counter, 0) |
733 | - self.ui.current_user.ui.sign_in_button.click() |
734 | + self.ui.current_user.ui.sign_in_button.clicked.emit(False) |
735 | self.assertEqual(self.ui.overlay.show_counter, 1) |
736 | |
737 | def test_overlay_connection_forgotten_password(self): |
738 | """Make sure we don't lose connections to the overlay.""" |
739 | self.assertEqual(self.ui.overlay.show_counter, 0) |
740 | - self.ui.forgotten.ui.send_button.click() |
741 | + self.ui.forgotten.ui.send_button.clicked.emit(False) |
742 | self.assertEqual(self.ui.overlay.show_counter, 1) |
743 | |
744 | def test_overlay_connection_reset_password(self): |
745 | """Make sure we don't lose connections to the overlay.""" |
746 | self.assertEqual(self.ui.overlay.show_counter, 0) |
747 | - self.ui.reset_password.ui.reset_password_button.click() |
748 | + self.ui.reset_password.ui.reset_password_button.clicked.emit(False) |
749 | self.assertEqual(self.ui.overlay.show_counter, 1) |
750 | |
751 | def test_next_hides_overlay(self): |
752 | @@ -276,6 +405,19 @@ |
753 | self.assertEqual( |
754 | congrats_page.ui.progressContainer.isVisible(), True) |
755 | |
756 | + def test_sync_page_custom_field(self): |
757 | + """If the user selects 'Sync Custom' we move to Folders page.""" |
758 | + sync_page = self.ui.page(self.ui.SYNC_NOW_OR_LATER_PAGE) |
759 | + sync_page.setField("sync_custom", True) |
760 | + |
761 | + # Show the Sync Now page |
762 | + self.ui.setStartId(self.ui.SYNC_NOW_OR_LATER_PAGE) |
763 | + self.ui.restart() |
764 | + self.ui.show() |
765 | + |
766 | + # Check the navigation is correct |
767 | + self.assertEqual(sync_page.nextId(), self.ui.folders_page_id) |
768 | + |
769 | def test_sync_later_hides_message(self): |
770 | """Selecting 'Sync Later' the congrats page hides a message.""" |
771 | congrats_page = self.ui.page(self.ui.CONGRATULATIONS_PAGE) |
772 | @@ -413,6 +555,18 @@ |
773 | self.shown = True |
774 | |
775 | |
776 | +class FakeCPBackend(object): |
777 | + """Fake Control Panel backend.""" |
778 | + |
779 | + def account_info(*args): |
780 | + return defer.succeed({"quota_total": 1000}) |
781 | + |
782 | + |
783 | +class FakeAddFolderButton(object): |
784 | + """Fake Control Panel "Add Folder" button.""" |
785 | + backend = FakeCPBackend() |
786 | + |
787 | + |
788 | class LocalFoldersTestCase(BaseTestCase): |
789 | """Test the LocalFoldersPage code.""" |
790 | |
791 | @@ -512,6 +666,10 @@ |
792 | self.assertEqual(self._called, ((True,), {})) |
793 | |
794 | |
795 | +LocalFoldersTestCase.skip = 'We need to re-write this test case entirely,' \ |
796 | + 'see bug #824675 for reference.' |
797 | + |
798 | + |
799 | class SetupAccountTestCase(BaseTestCase): |
800 | """Test the SetupAccountPage code.""" |
801 |
(01:08:39 PM) nessita: gatox: so, as an exercise, can you please change on_add_ storage_ button_ clicked to use inlineCallbacks + yield instead of: gementTool( ) find_credential s() open_url)
(01:08:39 PM) nessita: credtool = CredentialsMana
(01:08:39 PM) nessita: d = credtool.
(01:08:39 PM) nessita: d.addCallback(
Also, these imports
from twisted.internet import defer
from twisted.internet import reactor
from PyQt4 import QtGui
from PyQt4 import QtCore
should be:
from twisted.internet import defer, reactor
from PyQt4 import QtGui, QtCore
* This code is not needed:
def tearDown(self):
BaseTestCase. tearDown( self)
"""Clean up the reactor."""
* This assert has not effect!
* This code:
def account_ info(*args) :
reactor. callLater( .1, d.callback, {"quota_total": 1000})
d = defer.Deferred()
return d
should be:
def account_ info(*args) : {"quota_ total": 1000})
return defer.succeed(
* The branch lacks of tests for the new modules local_folders.py and preferences.py.
* Why you removed the LocalFoldersTes tCase?
* Also, test for local_folders.py is needed: I understand there was no former tests for this module, so I request just a test for the new functionality added/modified (show_hide_offer and on_add_ storage_ button_ clicked) .
* Question, why did you remove this code? set_button_ setup_account_ property