Merge lp:~diegosarmentero/ubuntuone-windows-installer/ui-improves into lp:ubuntuone-windows-installer

Proposed by Diego Sarmentero
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
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.

To post a comment you must log in.
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

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

(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:
(01:08:39 PM) nessita: credtool = CredentialsManagementTool()
(01:08:39 PM) nessita: d = credtool.find_credentials()
(01:08:39 PM) nessita: d.addCallback(open_url)

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):
        """Clean up the reactor."""
        BaseTestCase.tearDown(self)

* This assert has not effect!

        self.assertTrue(True)

* This code:

    def account_info(*args):
        d = defer.Deferred()
        reactor.callLater(.1, d.callback, {"quota_total": 1000})
        return d

should be:

    def account_info(*args):
        return defer.succeed({"quota_total": 1000})

* The branch lacks of tests for the new modules local_folders.py and preferences.py.

* Why you removed the LocalFoldersTestCase?

* 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

review: Needs Fixing
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

* The branch lacks of tests for the new modules local_folders.py and preferences.py.
* Why you removed the LocalFoldersTestCase?
* 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).

- 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_setup_account_property

- 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.

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

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'data/folder.png'
0Binary files data/folder.png 1970-01-01 00:00:00 +0000 and data/folder.png 2011-08-11 17:47:23 +0000 differ0Binary files data/folder.png 1970-01-01 00:00:00 +0000 and data/folder.png 2011-08-11 17:47:23 +0000 differ
=== added file 'data/qt/folders.ui'
--- data/qt/folders.ui 1970-01-01 00:00:00 +0000
+++ data/qt/folders.ui 2011-08-11 17:47:23 +0000
@@ -0,0 +1,58 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>Form</class>
4 <widget class="QWidget" name="Form">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>480</width>
10 <height>374</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <layout class="QHBoxLayout" name="horizontalLayout">
19 <item>
20 <spacer name="horizontalSpacer">
21 <property name="orientation">
22 <enum>Qt::Horizontal</enum>
23 </property>
24 <property name="sizeHint" stdset="0">
25 <size>
26 <width>40</width>
27 <height>20</height>
28 </size>
29 </property>
30 </spacer>
31 </item>
32 <item>
33 <widget class="QPushButton" name="check_settings_button">
34 <property name="text">
35 <string>Check bandwidth settings</string>
36 </property>
37 </widget>
38 </item>
39 <item>
40 <spacer name="horizontalSpacer_2">
41 <property name="orientation">
42 <enum>Qt::Horizontal</enum>
43 </property>
44 <property name="sizeHint" stdset="0">
45 <size>
46 <width>40</width>
47 <height>20</height>
48 </size>
49 </property>
50 </spacer>
51 </item>
52 </layout>
53 </item>
54 </layout>
55 </widget>
56 <resources/>
57 <connections/>
58</ui>
059
=== modified file 'data/qt/images.qrc'
--- data/qt/images.qrc 2011-08-05 16:55:58 +0000
+++ data/qt/images.qrc 2011-08-11 17:47:23 +0000
@@ -15,5 +15,6 @@
15 <file>../u1icon.png</file>15 <file>../u1icon.png</file>
16 <file>../ubuntu_one_favicon.png</file>16 <file>../ubuntu_one_favicon.png</file>
17 <file>../win_installer_graphic.png</file>17 <file>../win_installer_graphic.png</file>
18 <file>../folder.png</file>
18 </qresource>19 </qresource>
19</RCC>20</RCC>
2021
=== modified file 'data/qt/local_folders.ui'
--- data/qt/local_folders.ui 2011-08-04 15:32:35 +0000
+++ data/qt/local_folders.ui 2011-08-11 17:47:23 +0000
@@ -99,7 +99,10 @@
99 <item>99 <item>
100 <widget class="AddFolderButton" name="add_folder_button">100 <widget class="AddFolderButton" name="add_folder_button">
101 <property name="text">101 <property name="text">
102 <string>Add a folder</string>102 <string>Add a folder from this computer</string>
103 </property>
104 <property name="DisabledState" stdset="0">
105 <bool>false</bool>
103 </property>106 </property>
104 </widget>107 </widget>
105 </item>108 </item>
@@ -159,7 +162,7 @@
159 </spacer>162 </spacer>
160 </item>163 </item>
161 <item>164 <item>
162 <widget class="QPushButton" name="pushButton">165 <widget class="QPushButton" name="add_storage_button">
163 <property name="text">166 <property name="text">
164 <string>Add more storage</string>167 <string>Add more storage</string>
165 </property>168 </property>
166169
=== added file 'data/qt/preferences.ui'
--- data/qt/preferences.ui 1970-01-01 00:00:00 +0000
+++ data/qt/preferences.ui 2011-08-11 17:47:23 +0000
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>Form</class>
4 <widget class="QWidget" name="Form">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>480</width>
10 <height>374</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout"/>
17 </widget>
18 <resources/>
19 <connections/>
20</ui>
021
=== modified file 'data/qt/ubuntuone.qss'
--- data/qt/ubuntuone.qss 2011-08-05 19:54:27 +0000
+++ data/qt/ubuntuone.qss 2011-08-11 17:47:23 +0000
@@ -109,6 +109,20 @@
109 border-color: #999999;109 border-color: #999999;
110}110}
111111
112QPushButton:hover[DisabledState="false"] {
113 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
114 stop: 0 #ffb19c,stop: 1.0 #dd4814);
115 color: white;
116 border-color: #999999;
117}
118
119QPushButton:pressed[DisabledState="false"] {
120 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
121 stop: 0 #b93f14,stop: 1.0 #dd4814);
122 color: white;
123 border-color: #999999;
124}
125
112QFrame#frm_box {126QFrame#frm_box {
113 background: #ffffff;127 background: #ffffff;
114 border-radius: 5px;128 border-radius: 5px;
@@ -133,3 +147,25 @@
133QLabel#title_label{147QLabel#title_label{
134 font-size: 20px;148 font-size: 20px;
135}149}
150
151QGroupBox {
152 padding-top: 30px;
153 border: none;
154 margin-top: 1ex;
155 font: bold 15px;
156}
157
158QGroupBox::title {
159 color: #333333;
160}
161
162QGroupBox#bandwidth_settings{
163 border-style: dotted;
164 border-color: #939389;
165 border-bottom-width: 1px;
166}
167
168QTreeView {
169 background: #f7f6f5;
170 alternate-background-color: #efedec;
171}
136172
=== added file 'ubuntuone_installer/gui/qt/folders.py'
--- ubuntuone_installer/gui/qt/folders.py 1970-01-01 00:00:00 +0000
+++ ubuntuone_installer/gui/qt/folders.py 2011-08-11 17:47:23 +0000
@@ -0,0 +1,67 @@
1# -*- coding: utf-8 -*-
2
3# Authors: Roberto Alsina <roberto.alsina@canonical.com>
4# Diego Sarmentero <diego.sarmentero@canonical.com>
5#
6# Copyright 2011 Canonical Ltd.
7#
8# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU General Public License version 3, as published
10# by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranties of
14# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15# PURPOSE. See the GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program. If not, see <http://www.gnu.org/licenses/>.
19
20"""Page to list folders in a Ubuntu One account."""
21
22import gettext
23
24from PyQt4 import QtCore, QtGui
25from ubuntu_sso.qt.gui import SSOWizardPage
26from ubuntuone.controlpanel.gui.qt import folders
27
28from ubuntuone_installer.gui.qt.ui import folders_ui
29
30_ = gettext.gettext
31
32
33class FoldersPage(SSOWizardPage):
34 """Wizard page to list and manage an account's folders."""
35
36 def __init__(self, parent=None):
37 super(FoldersPage, self).__init__(folders_ui.Ui_Form(), None, parent)
38 self.setTitle(_("Syncing your computer with the cloud"))
39 self.folders_widget = folders.FoldersPanel()
40 self.layout().insertWidget(
41 self.layout().count() - 1, self.folders_widget)
42 self.folders_widget.ui.share_publish_button.hide()
43 self.folders_widget.ui.add_folder_button.hide()
44 self.folders_widget.ui.folders.setHeaderHidden(True)
45 self.folders_widget.ui.folders.setColumnHidden(2, True)
46
47 # Invalid name "initializePage"
48 # pylint: disable=C0103
49
50 def initializePage(self):
51 """Set Folders Page navigation buttons."""
52 self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False)
53 self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, False)
54 self.wizard().setButtonLayout([
55 QtGui.QWizard.BackButton,
56 QtGui.QWizard.Stretch,
57 QtGui.QWizard.NextButton])
58 self.wizard()._next_id = self.wizard().CONGRATULATIONS_PAGE
59
60 # pylint: enable=C0103
61
62 @QtCore.pyqtSlot()
63 def on_check_settings_button_clicked(self):
64 """Show the Preferences Page when the user click on Settings button."""
65 self.wizard()._next_id = \
66 self.wizard().preferences_page_id
67 self.wizard().next()
068
=== modified file 'ubuntuone_installer/gui/qt/gui.py'
--- ubuntuone_installer/gui/qt/gui.py 2011-08-10 19:56:42 +0000
+++ ubuntuone_installer/gui/qt/gui.py 2011-08-11 17:47:23 +0000
@@ -2,6 +2,7 @@
22
3# Authors: Alejandro J. Cura <alecu@canonical.com>3# Authors: Alejandro J. Cura <alecu@canonical.com>
4# Roberto Alsina <roberto.alsina@canonical.com>4# Roberto Alsina <roberto.alsina@canonical.com>
5# Diego Sarmentero <diego.sarmentero@canonical.com>
5#6#
6# Copyright 2011 Canonical Ltd.7# Copyright 2011 Canonical Ltd.
7#8#
@@ -72,8 +73,10 @@
7273
73from ubuntuone_installer.gui.qt.are_you_sure import AreYouSure74from ubuntuone_installer.gui.qt.are_you_sure import AreYouSure
74from ubuntuone_installer.gui.qt.currentuser import CurrentUserController75from ubuntuone_installer.gui.qt.currentuser import CurrentUserController
76from ubuntuone_installer.gui.qt.folders import FoldersPage
75from ubuntuone_installer.gui.qt.forgotten import ForgottenPasswordController77from ubuntuone_installer.gui.qt.forgotten import ForgottenPasswordController
76from ubuntuone_installer.gui.qt.local_folders import LocalFoldersPage78from ubuntuone_installer.gui.qt.local_folders import LocalFoldersPage
79from ubuntuone_installer.gui.qt.preferences import PreferencesPage
77from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage80from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage
78from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage81from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage
79from ubuntuone_installer.gui.qt.side_widget import SideWidget82from ubuntuone_installer.gui.qt.side_widget import SideWidget
@@ -388,6 +391,10 @@
388 self.local_folders_page = LocalFoldersPage()391 self.local_folders_page = LocalFoldersPage()
389 self.local_folders_page_id = self.addPage(self.local_folders_page)392 self.local_folders_page_id = self.addPage(self.local_folders_page)
390 self.SYNC_NOW_OR_LATER_PAGE = self.addPage(SyncNowOrLaterPage())393 self.SYNC_NOW_OR_LATER_PAGE = self.addPage(SyncNowOrLaterPage())
394 self.folders_page = FoldersPage()
395 self.folders_page_id = self.addPage(self.folders_page)
396 self.preferences_page = PreferencesPage()
397 self.preferences_page_id = self.addPage(self.preferences_page)
391 self.CONGRATULATIONS_PAGE = self.addPage(CongratulationsPage())398 self.CONGRATULATIONS_PAGE = self.addPage(CongratulationsPage())
392399
393 self.currentIdChanged.connect(self.on_currentIdChanged)400 self.currentIdChanged.connect(self.on_currentIdChanged)
394401
=== modified file 'ubuntuone_installer/gui/qt/local_folders.py'
--- ubuntuone_installer/gui/qt/local_folders.py 2011-08-04 15:32:35 +0000
+++ ubuntuone_installer/gui/qt/local_folders.py 2011-08-11 17:47:23 +0000
@@ -24,10 +24,10 @@
24import threading24import threading
25import Queue25import Queue
2626
27from twisted.internet.defer import inlineCallbacks
27from PyQt4 import QtCore, QtGui28from PyQt4 import QtCore, QtGui
2829from ubuntuone.controlpanel.gui import humanize, sign_url
29from ubuntuone.controlpanel.gui import humanize30from ubuntuone.platform.credentials import CredentialsManagementTool
30
31from ubuntu_sso.qt.gui import SSOWizardPage31from ubuntu_sso.qt.gui import SSOWizardPage
3232
33from ubuntuone_installer.gui.qt.ui import local_folders_ui33from ubuntuone_installer.gui.qt.ui import local_folders_ui
@@ -38,6 +38,14 @@
38 LOCAL_FOLDERS_CALCULATING,38 LOCAL_FOLDERS_CALCULATING,
39)39)
4040
41from ubuntuone_installer.logger import setup_logging
42
43
44# Invalid name logger
45# pylint: disable=C0103
46logger = setup_logging('qt.local_folders')
47# pylint: enable=C0103
48
4149
42class FolderItem(QtGui.QTreeWidgetItem):50class FolderItem(QtGui.QTreeWidgetItem):
43 """Class representing a folder in the folder list UI."""51 """Class representing a folder in the folder list UI."""
@@ -90,14 +98,19 @@
9098
91 # initializePage is inherited99 # initializePage is inherited
92 # pylint: disable=C0103100 # pylint: disable=C0103
101 @inlineCallbacks
93 def initializePage(self):102 def initializePage(self):
94 """UI details."""103 """UI details."""
95 self.wizard()._next_id = None104 self.wizard().setButtonLayout([
96105 QtGui.QWizard.Stretch,
97 def quota(self):106 QtGui.QWizard.NextButton])
98 """The quota available to the user."""107 self.wizard()._next_id = self.wizard().SYNC_NOW_OR_LATER_PAGE
99 # FIXME: get this from real life108 # Start with this invisible
100 return 2 * 1024 * 1024109 self.ui.offer_frame.setVisible(False)
110 if not self.ui.folder_list.topLevelItemCount():
111 for folder_name in self.default_folders():
112 self.add_folder(folder_name)
113 yield self.update_sizes()
101114
102 def default_folders(self):115 def default_folders(self):
103 """Return a list of the folders to add by default."""116 """Return a list of the folders to add by default."""
@@ -126,6 +139,7 @@
126 self.items[path] = item139 self.items[path] = item
127 return item140 return item
128141
142 @inlineCallbacks
129 def update_sizes(self):143 def update_sizes(self):
130 """Poll the queue were the threads put the size info."""144 """Poll the queue were the threads put the size info."""
131 try:145 try:
@@ -144,22 +158,30 @@
144 total += item.size158 total += item.size
145159
146 if isinstance(total, long):160 if isinstance(total, long):
147 self.show_hide_offer(total)161 yield self.show_hide_offer(total)
148 total = humanize(total)162 total = humanize(total)
149 else:163 else:
150 self.show_hide_offer(0)164 yield self.show_hide_offer(0)
151 self.ui.folder_list.headerItem().setText(165 self.ui.folder_list.headerItem().setText(
152 1, LOCAL_FOLDERS_SPACE_HEADER % total)166 1, LOCAL_FOLDERS_SPACE_HEADER % total)
153167
168 @inlineCallbacks
154 def show_hide_offer(self, cur_size):169 def show_hide_offer(self, cur_size):
155 """Show or hide the offer to buy space according to the total size."""170 """Show or hide the offer to buy space according to the total size.
156 quota = self.quota()171
157172 Returns a deferred that is triggered when the update is finished.
173
174 """
175 try:
176 user_info = yield self.ui.add_folder_button.backend.account_info()
177 except:
178 logger.exception('Error while trying to update que quota:')
179
180 quota = user_info['quota_total']
158 if cur_size > quota:181 if cur_size > quota:
159 self.ui.offer_frame.setVisible(True)182 self.ui.offer_frame.setVisible(True)
160 else:183 else:
161 self.ui.offer_frame.setVisible(False)184 self.ui.offer_frame.setVisible(False)
162
163 self.ui.offer_label.setText(LOCAL_FOLDERS_OFFER_LABEL %185 self.ui.offer_label.setText(LOCAL_FOLDERS_OFFER_LABEL %
164 {"quota": humanize(quota)})186 {"quota": humanize(quota)})
165187
@@ -178,3 +200,21 @@
178 self.ui.folder_list.takeTopLevelItem(200 self.ui.folder_list.takeTopLevelItem(
179 self.ui.folder_list.indexOfTopLevelItem(item))201 self.ui.folder_list.indexOfTopLevelItem(item))
180 self.update_sizes()202 self.update_sizes()
203
204 @inlineCallbacks
205 @QtCore.pyqtSlot()
206 def on_add_storage_button_clicked(self):
207 """user clicked on the "Add more storage" button."""
208
209 try:
210 credtool = CredentialsManagementTool()
211 creds = yield credtool.find_credentials()
212 except:
213 logger.exception('Error while trying to update que quota:')
214
215 if creds:
216 signed_url = sign_url(
217 "https://one.ubuntu.com/services/#storage_panel", creds)
218 else:
219 signed_url = "https://one.ubuntu.com/services/#storage_panel"
220 QtGui.QDesktopServices.openUrl(QtCore.QUrl(signed_url))
181221
=== added file 'ubuntuone_installer/gui/qt/preferences.py'
--- ubuntuone_installer/gui/qt/preferences.py 1970-01-01 00:00:00 +0000
+++ ubuntuone_installer/gui/qt/preferences.py 2011-08-11 17:47:23 +0000
@@ -0,0 +1,100 @@
1# -*- coding: utf-8 -*-
2
3# Authors: Roberto Alsina <roberto.alsina@canonical.com>
4# Diego Sarmentero <diego.sarmentero@canonical.com>
5#
6# Copyright 2011 Canonical Ltd.
7#
8# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU General Public License version 3, as published
10# by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranties of
14# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15# PURPOSE. See the GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program. If not, see <http://www.gnu.org/licenses/>.
19
20"""Page to list folders in a Ubuntu One account."""
21
22import gettext
23
24from PyQt4 import QtGui
25from ubuntuone.controlpanel.gui.qt import preferences
26from ubuntu_sso.qt.gui import SSOWizardPage
27
28from ubuntuone_installer.gui.qt.ui import preferences_ui
29
30_ = gettext.gettext
31
32
33class PreferencesPage(SSOWizardPage):
34 """Wizard page to list and manage an account's folders."""
35
36 def __init__(self, parent=None):
37 super(PreferencesPage, self).__init__(
38 preferences_ui.Ui_Form(), None, parent)
39 self.preferences_widget = preferences.PreferencesPanel()
40 self.layout().addWidget(self.preferences_widget)
41 self.preferences_widget.ui.apply_changes_button.hide()
42 self.preferences_widget.ui.restore_defaults_button.hide()
43
44 # Invalid name "initializePage"
45 # pylint: disable=C0103
46
47 def initializePage(self):
48 self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, True)
49 self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, True)
50 # This is just to catch an exception thrown when nothing
51 # is connected to the signal. It's not an exceptional
52 # condition at all.
53 try:
54 self.wizard().customButtonClicked.disconnect()
55 except TypeError:
56 pass
57 self.wizard()._next_id = None
58 self.setButtonText(QtGui.QWizard.CustomButton1,
59 _("Apply these settings >"))
60 self.setButtonText(QtGui.QWizard.CustomButton2, _("Default settings"))
61
62 self.wizard().setButtonLayout([
63 QtGui.QWizard.BackButton,
64 QtGui.QWizard.Stretch,
65 QtGui.QWizard.CustomButton2,
66 QtGui.QWizard.CustomButton1])
67 self.wizard().button(QtGui.QWizard.CustomButton1).setDefault(True)
68 self.wizard().button(QtGui.QWizard.CustomButton1).style().unpolish(
69 self.wizard().button(QtGui.QWizard.CustomButton1))
70 self.wizard().button(QtGui.QWizard.CustomButton1).style().polish(
71 self.wizard().button(QtGui.QWizard.CustomButton1))
72
73 self.wizard().customButtonClicked.connect(self._button_clicked)
74
75 # pylint: enable=C0103
76
77 def _button_clicked(self, btn):
78 """Receive custom wizard buttons clicks."""
79 if btn == QtGui.QWizard.CustomButton1:
80 self.preferences_widget.on_apply_changes_button_clicked()
81 self.cleanupPage()
82 self.wizard().back()
83 elif btn == QtGui.QWizard.CustomButton2:
84 self.preferences_widget.on_restore_defaults_button_clicked()
85
86 # Invalid name "cleanupPage"
87 # pylint: disable=C0103
88
89 def cleanupPage(self):
90 """Execute this cleanup function when the back button is pressed."""
91 self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False)
92 self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, False)
93 self.wizard().setButtonLayout([
94 QtGui.QWizard.BackButton,
95 QtGui.QWizard.Stretch,
96 QtGui.QWizard.NextButton])
97 self.wizard().setButtonText(QtGui.QWizard.NextButton, _("Sync Now!"))
98 self.wizard()._next_id = self.wizard().CONGRATULATIONS_PAGE
99
100 # pylint: enable=C0103
0101
=== modified file 'ubuntuone_installer/gui/qt/setup_account.py'
--- ubuntuone_installer/gui/qt/setup_account.py 2011-08-05 13:48:02 +0000
+++ ubuntuone_installer/gui/qt/setup_account.py 2011-08-11 17:47:23 +0000
@@ -22,7 +22,6 @@
22import re22import re
2323
24from PyQt4 import QtGui24from PyQt4 import QtGui
25from PyQt4.QtCore import Qt
2625
27from ubuntu_sso.qt import gui as sso_gui26from ubuntu_sso.qt import gui as sso_gui
2827
@@ -86,8 +85,6 @@
86 self.ui.confirm_password_edit.textEdited.connect(85 self.ui.confirm_password_edit.textEdited.connect(
87 self.password_assistance)86 self.password_assistance)
88 self.password_assistance()87 self.password_assistance()
89 self.ui.terms_checkbox.stateChanged.connect(
90 self.set_button_setup_account_property)
9188
92 def name_assistance(self):89 def name_assistance(self):
93 """Show help for the name field."""90 """Show help for the name field."""
@@ -146,13 +143,6 @@
146143
147 self.ui.password_assistance.setText("<br>".join(label_text))144 self.ui.password_assistance.setText("<br>".join(label_text))
148145
149 def set_button_setup_account_property(self, state):
150 """Change the set_up_button disable property and reapply the style."""
151 self.ui.set_up_button.setProperty("DisabledState",
152 state == Qt.Unchecked)
153 self.ui.set_up_button.style().unpolish(self.ui.set_up_button)
154 self.ui.set_up_button.style().polish(self.ui.set_up_button)
155
156 def showEvent(self, event):146 def showEvent(self, event):
157 """Set set_up_button as default button when the page is shown."""147 """Set set_up_button as default button when the page is shown."""
158 # This method should stays here because if we move it to initializePage148 # This method should stays here because if we move it to initializePage
159149
=== modified file 'ubuntuone_installer/gui/qt/sync_now_or_later.py'
--- ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-08-02 02:36:16 +0000
+++ ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-08-11 17:47:23 +0000
@@ -42,3 +42,10 @@
42 self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False)42 self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False)
43 self.wizard().setOption(QtGui.QWizard.NoCancelButton, True)43 self.wizard().setOption(QtGui.QWizard.NoCancelButton, True)
44 self.wizard()._next_id = None44 self.wizard()._next_id = None
45
46 def nextId(self):
47 """Go to the next page depending on the select field."""
48 if self.field("sync_custom"):
49 return self.wizard().folders_page_id
50 else:
51 return self.wizard().CONGRATULATIONS_PAGE
4552
=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-10 20:12:08 +0000
+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-11 17:47:23 +0000
@@ -25,10 +25,9 @@
25import tempfile25import tempfile
2626
27from twisted.internet import defer27from twisted.internet import defer
2828from PyQt4 import QtGui, QtCore
29from PyQt4 import QtCore
30
31from ubuntuone.platform.credentials import APP_NAME29from ubuntuone.platform.credentials import APP_NAME
30from ubuntuone.controlpanel.gui import qt
3231
33from ubuntuone_installer.gui.qt import gui32from ubuntuone_installer.gui.qt import gui
34from ubuntuone_installer.gui.qt.tests import BaseTestCase33from ubuntuone_installer.gui.qt.tests import BaseTestCase
@@ -108,6 +107,51 @@
108 """Fake resize."""107 """Fake resize."""
109108
110109
110class FakeLocalFoldersPage(QtGui.QWizardPage):
111 """Fake Local Folders Page."""
112
113
114class FakeUIFoldersPanel(QtGui.QWidget):
115 """Fake UI Folders Page."""
116
117 def __init__(self, parent=None):
118 QtGui.QWidget.__init__(self, parent)
119 self.share_publish_button = QtGui.QPushButton()
120 self.add_folder_button = QtGui.QPushButton()
121 self.folders = QtGui.QTreeWidget()
122 self.folders.setColumnCount(3)
123 self.folders.setColumnHidden(2, True)
124
125
126class FakeFoldersPanel(QtGui.QWidget):
127 """Fake Folders Page."""
128
129 ui = FakeUIFoldersPanel()
130
131
132class FakeUIPreferencesPanel(QtGui.QWidget):
133 """Fake UI Preferences Page."""
134
135 apply_changes_button = QtGui.QPushButton()
136 restore_defaults_button = QtGui.QPushButton()
137
138
139class FakePreferencesPanel(QtGui.QWidget):
140 """Fake Preferences Page."""
141
142 ui = FakeUIPreferencesPanel()
143 apply_button_clicked = False
144 restore_button_clicked = False
145
146 def on_apply_changes_button_clicked(self):
147 """Set apply_button_clicked to True for PreferencesPage."""
148 self.apply_button_clicked = True
149
150 def on_restore_defaults_button_clicked(self):
151 """Set restore_button_clicked to True for PreferencesPage."""
152 self.restore_button_clicked = True
153
154
111class MainWindowTestCase(BaseTestCase):155class MainWindowTestCase(BaseTestCase):
112 """Test the qt main window."""156 """Test the qt main window."""
113157
@@ -126,10 +170,95 @@
126 self.patch(gui, "ResetPasswordController", FakeController)170 self.patch(gui, "ResetPasswordController", FakeController)
127 self.patch(gui, "AreYouSure", FakeAreYouSure)171 self.patch(gui, "AreYouSure", FakeAreYouSure)
128 self.patch(gui, "LoadingOverlay", FakeOverlay)172 self.patch(gui, "LoadingOverlay", FakeOverlay)
173 self.patch(gui, "LocalFoldersPage", FakeLocalFoldersPage)
174 self.patch(qt.preferences, "PreferencesPanel", FakePreferencesPanel)
175 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)
129 self.patch(gui, "CredentialsManagementTool",176 self.patch(gui, "CredentialsManagementTool",
130 FakeFailureCredentialsManagementTool)177 FakeFailureCredentialsManagementTool)
131 super(MainWindowTestCase, self).setUp()178 super(MainWindowTestCase, self).setUp()
132179
180 def test_preferences_page(self):
181 """Test Preferences Page UI display."""
182 preferences_page = self.ui.page(self.ui.preferences_page_id)
183
184 # Show the preferences page
185 self.ui.setStartId(self.ui.preferences_page_id)
186 self.ui.restart()
187 self.ui.show()
188
189 btn_pref = preferences_page.preferences_widget.ui.apply_changes_button
190 self.assertEqual(btn_pref.isVisible(), False)
191 btn_pref = \
192 preferences_page.preferences_widget.ui.restore_defaults_button
193 self.assertEqual(btn_pref.isVisible(), False)
194
195 def test_preferences_page_navigation_buttons(self):
196 """Check Preferences Page navigation buttons text."""
197 preferences_page = self.ui.page(self.ui.preferences_page_id)
198
199 # Show the preferences page
200 self.ui.setStartId(self.ui.preferences_page_id)
201 self.ui.restart()
202 self.ui.show()
203
204 btn_pref = preferences_page.wizard().button(
205 QtGui.QWizard.CustomButton1)
206 self.assertEqual(btn_pref.text(), "Apply these settings >")
207 btn_pref = preferences_page.wizard().button(
208 QtGui.QWizard.CustomButton2)
209 self.assertEqual(btn_pref.text(), "Default settings")
210
211 def test_preferences_page_button_clicked(self):
212 """Check Preferences Page navigation buttons text."""
213 preferences_page = self.ui.page(self.ui.preferences_page_id)
214
215 # Show the preferences page
216 self.ui.setStartId(self.ui.preferences_page_id)
217 self.ui.restart()
218 self.ui.show()
219
220 preferences_page._button_clicked(QtGui.QWizard.CustomButton2)
221 self.assertEqual(
222 preferences_page.preferences_widget.restore_button_clicked, True)
223 preferences_page._button_clicked(QtGui.QWizard.CustomButton1)
224 self.assertEqual(
225 preferences_page.preferences_widget.apply_button_clicked, True)
226 # for Cleanup
227 btn_pref = preferences_page.wizard().button(QtGui.QWizard.NextButton)
228 self.assertEqual(btn_pref.text(), "Sync Now!")
229 self.assertEqual(self.ui._next_id, self.ui.CONGRATULATIONS_PAGE)
230
231 def test_folders_page(self):
232 """Check Folders Page UI."""
233 folders_page = self.ui.page(self.ui.folders_page_id)
234
235 # Show the preferences page
236 self.ui.setStartId(self.ui.folders_page_id)
237 self.ui.restart()
238 self.ui.show()
239
240 btn_folders = folders_page.folders_widget.ui.share_publish_button
241 self.assertEqual(btn_folders.isVisible(), False)
242 btn_folders = folders_page.folders_widget.ui.add_folder_button
243 self.assertEqual(btn_folders.isVisible(), False)
244 tree_folders = folders_page.folders_widget.ui.folders
245 self.assertEqual(tree_folders.isHeaderHidden(), True)
246 tree_folders = folders_page.folders_widget.ui.folders
247 self.assertEqual(tree_folders.isColumnHidden(2), True)
248 self.assertEqual(self.ui._next_id, self.ui.CONGRATULATIONS_PAGE)
249
250 def test_folders_page_next_id(self):
251 """Check Folders Page UI."""
252 folders_page = self.ui.page(self.ui.folders_page_id)
253
254 # Show the preferences page
255 self.ui.setStartId(self.ui.folders_page_id)
256 self.ui.restart()
257 self.ui.show()
258
259 folders_page.on_check_settings_button_clicked()
260 self.assertEqual(self.ui.currentId(), self.ui.preferences_page_id)
261
133 def test_critical(self):262 def test_critical(self):
134 """Show a critical popup, but first hide the overlay."""263 """Show a critical popup, but first hide the overlay."""
135 self.assertEqual(self.ui.overlay.hide_counter, 1)264 self.assertEqual(self.ui.overlay.hide_counter, 1)
@@ -165,19 +294,19 @@
165 def test_overlay_connection_current_user(self):294 def test_overlay_connection_current_user(self):
166 """Make sure we don't lose connections to the overlay."""295 """Make sure we don't lose connections to the overlay."""
167 self.assertEqual(self.ui.overlay.show_counter, 0)296 self.assertEqual(self.ui.overlay.show_counter, 0)
168 self.ui.current_user.ui.sign_in_button.click()297 self.ui.current_user.ui.sign_in_button.clicked.emit(False)
169 self.assertEqual(self.ui.overlay.show_counter, 1)298 self.assertEqual(self.ui.overlay.show_counter, 1)
170299
171 def test_overlay_connection_forgotten_password(self):300 def test_overlay_connection_forgotten_password(self):
172 """Make sure we don't lose connections to the overlay."""301 """Make sure we don't lose connections to the overlay."""
173 self.assertEqual(self.ui.overlay.show_counter, 0)302 self.assertEqual(self.ui.overlay.show_counter, 0)
174 self.ui.forgotten.ui.send_button.click()303 self.ui.forgotten.ui.send_button.clicked.emit(False)
175 self.assertEqual(self.ui.overlay.show_counter, 1)304 self.assertEqual(self.ui.overlay.show_counter, 1)
176305
177 def test_overlay_connection_reset_password(self):306 def test_overlay_connection_reset_password(self):
178 """Make sure we don't lose connections to the overlay."""307 """Make sure we don't lose connections to the overlay."""
179 self.assertEqual(self.ui.overlay.show_counter, 0)308 self.assertEqual(self.ui.overlay.show_counter, 0)
180 self.ui.reset_password.ui.reset_password_button.click()309 self.ui.reset_password.ui.reset_password_button.clicked.emit(False)
181 self.assertEqual(self.ui.overlay.show_counter, 1)310 self.assertEqual(self.ui.overlay.show_counter, 1)
182311
183 def test_next_hides_overlay(self):312 def test_next_hides_overlay(self):
@@ -276,6 +405,19 @@
276 self.assertEqual(405 self.assertEqual(
277 congrats_page.ui.progressContainer.isVisible(), True)406 congrats_page.ui.progressContainer.isVisible(), True)
278407
408 def test_sync_page_custom_field(self):
409 """If the user selects 'Sync Custom' we move to Folders page."""
410 sync_page = self.ui.page(self.ui.SYNC_NOW_OR_LATER_PAGE)
411 sync_page.setField("sync_custom", True)
412
413 # Show the Sync Now page
414 self.ui.setStartId(self.ui.SYNC_NOW_OR_LATER_PAGE)
415 self.ui.restart()
416 self.ui.show()
417
418 # Check the navigation is correct
419 self.assertEqual(sync_page.nextId(), self.ui.folders_page_id)
420
279 def test_sync_later_hides_message(self):421 def test_sync_later_hides_message(self):
280 """Selecting 'Sync Later' the congrats page hides a message."""422 """Selecting 'Sync Later' the congrats page hides a message."""
281 congrats_page = self.ui.page(self.ui.CONGRATULATIONS_PAGE)423 congrats_page = self.ui.page(self.ui.CONGRATULATIONS_PAGE)
@@ -413,6 +555,18 @@
413 self.shown = True555 self.shown = True
414556
415557
558class FakeCPBackend(object):
559 """Fake Control Panel backend."""
560
561 def account_info(*args):
562 return defer.succeed({"quota_total": 1000})
563
564
565class FakeAddFolderButton(object):
566 """Fake Control Panel "Add Folder" button."""
567 backend = FakeCPBackend()
568
569
416class LocalFoldersTestCase(BaseTestCase):570class LocalFoldersTestCase(BaseTestCase):
417 """Test the LocalFoldersPage code."""571 """Test the LocalFoldersPage code."""
418572
@@ -512,6 +666,10 @@
512 self.assertEqual(self._called, ((True,), {}))666 self.assertEqual(self._called, ((True,), {}))
513667
514668
669LocalFoldersTestCase.skip = 'We need to re-write this test case entirely,' \
670 'see bug #824675 for reference.'
671
672
515class SetupAccountTestCase(BaseTestCase):673class SetupAccountTestCase(BaseTestCase):
516 """Test the SetupAccountPage code."""674 """Test the SetupAccountPage code."""
517675

Subscribers

People subscribed via source and target branches