Merge lp:~nataliabidart/ubuntuone-control-panel/fix-933576-1 into lp:ubuntuone-control-panel

Proposed by Natalia Bidart on 2012-03-02
Status: Merged
Approved by: Natalia Bidart on 2012-03-02
Approved revision: 272
Merged at revision: 271
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/fix-933576-1
Merge into: lp:ubuntuone-control-panel
Diff against target: 451 lines (+80/-152)
13 files modified
data/qt/account.ui (+6/-0)
data/qt/controlpanel.ui (+3/-0)
data/qt/devices.ui (+3/-0)
data/qt/folders.ui (+3/-0)
data/qt/images.qrc (+9/-11)
data/qt/mainwindow.ui (+1/-1)
data/qt/preferences.ui (+3/-0)
data/qt/ubuntuone.qss (+33/-31)
ubuntuone/controlpanel/gui/qt/__init__.py (+2/-1)
ubuntuone/controlpanel/gui/qt/filesyncstatus.py (+3/-13)
ubuntuone/controlpanel/gui/qt/systray.py (+1/-2)
ubuntuone/controlpanel/gui/qt/tests/__init__.py (+0/-67)
ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py (+13/-26)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/fix-933576-1
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve on 2012-03-02
Diego Sarmentero (community) 2012-03-02 Approve on 2012-03-02
Review via email: mp+95557@code.launchpad.net

Commit Message

- Handle properly default/non-default buttons (part of LP: #933576).

To post a comment you must log in.
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Manuel de la Peña (mandel) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'data/u1icon.png' => 'data/icon.png'
2=== modified file 'data/qt/account.ui'
3--- data/qt/account.ui 2012-02-22 15:35:13 +0000
4+++ data/qt/account.ui 2012-03-02 13:46:17 +0000
5@@ -27,6 +27,9 @@
6 <property name="text">
7 <string notr="true">Edit personal details online</string>
8 </property>
9+ <property name="default">
10+ <bool>true</bool>
11+ </property>
12 </widget>
13 </item>
14 <item row="2" column="0">
15@@ -111,6 +114,9 @@
16 <property name="text">
17 <string notr="true">Edit your services online</string>
18 </property>
19+ <property name="default">
20+ <bool>true</bool>
21+ </property>
22 </widget>
23 </item>
24 <item row="0" column="3">
25
26=== modified file 'data/qt/controlpanel.ui'
27--- data/qt/controlpanel.ui 2012-02-22 15:35:13 +0000
28+++ data/qt/controlpanel.ui 2012-03-02 13:46:17 +0000
29@@ -162,6 +162,9 @@
30 <property name="text">
31 <string notr="true">Get more storage</string>
32 </property>
33+ <property name="default">
34+ <bool>true</bool>
35+ </property>
36 </widget>
37 </item>
38 </layout>
39
40=== modified file 'data/qt/devices.ui'
41--- data/qt/devices.ui 2012-02-22 15:35:13 +0000
42+++ data/qt/devices.ui 2012-03-02 13:46:17 +0000
43@@ -92,6 +92,9 @@
44 <property name="text">
45 <string notr="true">Go to the web page to manage your other devices</string>
46 </property>
47+ <property name="default">
48+ <bool>true</bool>
49+ </property>
50 </widget>
51 </item>
52 <item>
53
54=== modified file 'data/qt/folders.ui'
55--- data/qt/folders.ui 2012-02-22 15:35:13 +0000
56+++ data/qt/folders.ui 2012-03-02 13:46:17 +0000
57@@ -155,6 +155,9 @@
58 <property name="text">
59 <string notr="true">Add a folder from this computer</string>
60 </property>
61+ <property name="default">
62+ <bool>true</bool>
63+ </property>
64 </widget>
65 </item>
66 <item>
67
68=== modified file 'data/qt/images.qrc'
69--- data/qt/images.qrc 2012-01-30 18:49:50 +0000
70+++ data/qt/images.qrc 2012-03-02 13:46:17 +0000
71@@ -1,20 +1,18 @@
72 <RCC>
73 <qresource prefix="/">
74- <file>../u1icon.png</file>
75+ <file>../computer.png</file>
76 <file>../external_icon_orange.png</file>
77+ <file>../external_icon_white.png</file>
78+ <file>../icon.png</file>
79+ <file>../folder.png</file>
80+ <file>../phone.png</file>
81+ <file>../sync_status_alert.png</file>
82 <file>../sync_status_disconnected.png</file>
83- <file>../sync_status_alert.png</file>
84+ <file>../sync_status_loading.png</file>
85 <file>../sync_status_sync_done.png</file>
86 <file>../sync_status_syncing.png</file>
87- <file>../sync_status_loading.png</file>
88- <file>../folder.png</file>
89- <file>../computer.png</file>
90- <file>../phone.png</file>
91- <file>../twitter.png</file>
92- <file>../twitter.png</file>
93- <file>../facebook.png</file>
94- <file>../facebook.png</file>
95- <file>../external_icon_white.png</file>
96+ <file>../twitter.png</file>
97+ <file>../facebook.png</file>
98 <file>../Ubuntu-R.ttf</file>
99 <file>../Ubuntu-B.ttf</file>
100 <file>ubuntuone.qss</file>
101
102=== modified file 'data/qt/mainwindow.ui'
103--- data/qt/mainwindow.ui 2012-02-22 14:58:25 +0000
104+++ data/qt/mainwindow.ui 2012-03-02 13:46:17 +0000
105@@ -27,7 +27,7 @@
106 </property>
107 <property name="windowIcon">
108 <iconset resource="images.qrc">
109- <normaloff>:/u1icon.png</normaloff>:/u1icon.png</iconset>
110+ <normaloff>:/icon.png</normaloff>:/icon.png</iconset>
111 </property>
112 <widget class="QWidget" name="centralwidget">
113 <property name="sizePolicy">
114
115=== modified file 'data/qt/preferences.ui'
116--- data/qt/preferences.ui 2012-02-22 14:58:25 +0000
117+++ data/qt/preferences.ui 2012-03-02 13:46:17 +0000
118@@ -195,6 +195,9 @@
119 <property name="text">
120 <string notr="true">Apply these settings</string>
121 </property>
122+ <property name="default">
123+ <bool>true</bool>
124+ </property>
125 </widget>
126 </item>
127 <item>
128
129=== modified file 'data/qt/ubuntuone.qss'
130--- data/qt/ubuntuone.qss 2011-11-23 17:22:33 +0000
131+++ data/qt/ubuntuone.qss 2012-03-02 13:46:17 +0000
132@@ -68,55 +68,57 @@
133 border-width: 1px;
134 }
135
136-QPushButton[enabled="true"] {
137+QPushButton:disabled {
138+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
139+ stop: 0 #eaeaea, stop: 1.0 #cacaca);
140+ color: #595959;
141+ border-color: #939389;
142+}
143+
144+QPushButton:enabled {
145+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
146+ stop: 0 #ffffff,stop: 1.0 #e6e6e6);
147+ color: #333333;
148+ border-color: #999999;
149+}
150+
151+QPushButton:enabled:focus,
152+QPushButton:enabled:hover {
153+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
154+ stop: 0 #ffffff,stop: 1.0 #ededed);
155+ color: #333333;
156+ border-color: #999999;
157+}
158+
159+QPushButton:enabled:pressed {
160+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
161+ stop: 0 #d9d9d9,stop: 1.0 #fefefe);
162+ color: #333333;
163+ border-color: #999999;
164+}
165+
166+QPushButton:default:enabled {
167 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
168 stop: 0 #fe9e84,stop: 1.0 #dd4814);
169 color: white;
170 border-color: #999999;
171 }
172
173-QPushButton:hover[enabled="true"] {
174+QPushButton:default:enabled:focus,
175+QPushButton:default:enabled:hover {
176 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
177 stop: 0 #ffb19c,stop: 1.0 #dd4814);
178 color: white;
179 border-color: #999999;
180 }
181
182-QPushButton:pressed[enabled="true"] {
183+QPushButton:default:enabled:pressed {
184 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
185 stop: 0 #b93f14,stop: 1.0 #dd4814);
186 color: white;
187 border-color: #999999;
188 }
189
190-QPushButton[secondary="true"] {
191- background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
192- stop: 0 #ffffff,stop: 1.0 #e6e6e6);
193- color: #333333;
194- border-color: #999999;
195-}
196-
197-QPushButton:hover[secondary="true"] {
198- background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
199- stop: 0 #ffffff,stop: 1.0 #ededed);
200- color: #333333;
201- border-color: #999999;
202-}
203-
204-QPushButton:pressed[secondary="true"] {
205- background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
206- stop: 0 #d9d9d9,stop: 1.0 #fefefe);
207- color: #333333;
208- border-color: #999999;
209-}
210-
211-QPushButton[enabled="false"] {
212- background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
213- stop: 0 #eaeaea, stop: 1.0 #cacaca);
214- color: #595959;
215- border-color: #939389;
216-}
217-
218 QPushButton#help_button {
219 background: transparent;
220 border: none;
221
222=== modified file 'ubuntuone/controlpanel/gui/qt/__init__.py'
223--- ubuntuone/controlpanel/gui/qt/__init__.py 2011-10-05 16:35:59 +0000
224+++ ubuntuone/controlpanel/gui/qt/__init__.py 2012-03-02 13:46:17 +0000
225@@ -93,7 +93,8 @@
226 try:
227 res = yield f(*args, **kwargs)
228 except Exception, e: # pylint: disable=W0703
229- logger.exception(f.__name__)
230+ msg = 'Error while invoking %r with args %r and kwargs %r:'
231+ logger.exception(msg, f, args, kwargs)
232 else:
233 defer.returnValue(res)
234
235
236=== modified file 'ubuntuone/controlpanel/gui/qt/filesyncstatus.py'
237--- ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2012-01-30 18:49:50 +0000
238+++ ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2012-03-02 13:46:17 +0000
239@@ -164,14 +164,8 @@
240 self.ui.sync_status_button.setText(action)
241 self.ui.sync_status_button.setEnabled(True)
242 self.ui.sync_status_button.show()
243- if status_key == backend.FILE_SYNC_DISCONNECTED:
244- self.ui.sync_status_button.setProperty("secondary", False)
245- else:
246- self.ui.sync_status_button.setProperty("secondary", True)
247- self.ui.sync_status_button.style().unpolish(
248- self.ui.sync_status_button)
249- self.ui.sync_status_button.style().polish(
250- self.ui.sync_status_button)
251+ default = (status_key == backend.FILE_SYNC_DISCONNECTED)
252+ self.ui.sync_status_button.setDefault(default)
253 else:
254 self.ui.sync_status_button.hide()
255
256@@ -190,11 +184,7 @@
257 self.ui.sync_status_button.setText(PLEASE_WAIT)
258 pixmap = pixmap_from_name('sync_status_loading')
259 self.ui.sync_status_icon.setPixmap(pixmap)
260- self.ui.sync_status_button.setProperty("secondary", True)
261- self.ui.sync_status_button.style().unpolish(
262- self.ui.sync_status_button)
263- self.ui.sync_status_button.style().polish(
264- self.ui.sync_status_button)
265+ self.ui.sync_status_button.setDefault(False)
266 self._backend_method()
267 else:
268 logger.error('on_sync_status_button_clicked: backend method is '
269
270=== modified file 'ubuntuone/controlpanel/gui/qt/systray.py'
271--- ubuntuone/controlpanel/gui/qt/systray.py 2012-02-22 14:58:25 +0000
272+++ ubuntuone/controlpanel/gui/qt/systray.py 2012-03-02 13:46:17 +0000
273@@ -17,7 +17,6 @@
274
275 from PyQt4 import QtGui
276 from twisted.internet.defer import inlineCallbacks
277-
278 from ubuntuone.platform.tools import SyncDaemonTool
279
280 from ubuntuone.controlpanel.gui import (
281@@ -32,7 +31,7 @@
282
283 def __init__(self, window=None, close_callback=lambda: None):
284 super(TrayIcon, self).__init__(None)
285- self.setIcon(QtGui.QIcon(":/u1icon.png"))
286+ self.setIcon(QtGui.QIcon(":/icon.png"))
287 self.setVisible(True)
288 self.window = window
289 self.activated.connect(self.on_activated)
290
291=== modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py'
292--- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-02-17 12:01:56 +0000
293+++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-03-02 13:46:17 +0000
294@@ -233,73 +233,6 @@
295 # pylint: enable=C0103
296
297
298-class FakePageUiStyle(object):
299- """Fake the page."""
300-
301- def __init__(self):
302- self.ui = self
303- self.properties = {}
304- super(FakePageUiStyle, self).__init__()
305-
306- def wizard(self):
307- """Use itself as a fake wizard, too."""
308- return self
309-
310- def text(self):
311- """Return text."""
312- return self.properties.get('text', '')
313-
314- # setText, setEnabled are inherited
315- # pylint: disable=C0103
316- def setText(self, text):
317- """Save text."""
318- self.properties['text'] = text
319-
320- def setEnabled(self, value):
321- """Fake setEnabled."""
322- self.properties['enabled'] = value
323-
324- def enabled(self):
325- """Fake enabled."""
326- return self.properties.get('enabled', False)
327-
328- def isEnabled(self):
329- """Fake isEnabled."""
330- return self.properties.get('enabled', False)
331-
332- def setProperty(self, key, val):
333- """Fake setProperty to restyle some widget."""
334- self.properties[key] = val
335-
336- def property(self, key):
337- """Fake property from widget style."""
338- return self.properties.get(key, False)
339-
340- def setDefault(self, val):
341- """Fake button setDefault."""
342- self.properties['default'] = val
343-
344- def style(self):
345- """Fake style."""
346- return self
347-
348- def unpolish(self, *args):
349- """Fake unpolish."""
350- self.properties['unpolish'] = len(args) > 0
351-
352- def polish(self, *args):
353- """Fake polish."""
354- self.properties['polish'] = len(args) > 0
355-
356- def setVisible(self, val):
357- """Fake setVisible from Qt."""
358- self.properties['visible'] = val
359-
360- def isVisible(self):
361- """Fake isVisible from Qt."""
362- return self.properties['visible']
363-
364-
365 class BaseTestCase(TestCase):
366 """Base Test Case."""
367
368
369=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py'
370--- ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2012-02-06 12:39:18 +0000
371+++ ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2012-03-02 13:46:17 +0000
372@@ -1,8 +1,6 @@
373 # -*- coding: utf-8 -*-
374-
375-# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
376 #
377-# Copyright 2011 Canonical Ltd.
378+# Copyright 2011-2012 Canonical Ltd.
379 #
380 # This program is free software: you can redistribute it and/or modify it
381 # under the terms of the GNU General Public License version 3, as published
382@@ -20,15 +18,12 @@
383
384 from twisted.internet import defer
385
386-from ubuntuone.controlpanel.gui.qt import filesyncstatus as gui
387-from ubuntuone.controlpanel.gui.qt.tests import (
388- BaseTestCase,
389- FakePageUiStyle,
390-)
391 from ubuntuone.controlpanel.gui import (
392 LOADING,
393 PLEASE_WAIT,
394 )
395+from ubuntuone.controlpanel.gui.qt import filesyncstatus as gui
396+from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase
397
398 backend = gui.backend # pylint: disable=C0103
399
400@@ -75,22 +70,17 @@
401
402 self.assertTrue(self.ui.ui.sync_status_button.isEnabled())
403 self.assertEqual(self.ui.ui.sync_status_button.text(), action)
404- if action == gui.FILE_SYNC_DISCONNECTED:
405- self.assertFalse(
406- self.ui.ui.sync_status_button.property("secondary"))
407- else:
408- self.assertTrue(
409- self.ui.ui.sync_status_button.property("secondary"))
410+
411+ is_default = self.ui.ui.sync_status_button.isDefault()
412+ expected_default = (action == gui.FILE_SYNC_CONNECT)
413+ self.assertEqual(expected_default, is_default)
414
415 self.ui.ui.sync_status_button.click()
416 self.assertFalse(self.ui.ui.sync_status_button.isEnabled())
417 self.assert_backend_called(callback)
418- if action == gui.FILE_SYNC_DISCONNECTED:
419- self.assertFalse(
420- self.ui.ui.sync_status_button.property("secondary"))
421- else:
422- self.assertTrue(
423- self.ui.ui.sync_status_button.property("secondary"))
424+
425+ is_default = self.ui.ui.sync_status_button.isDefault()
426+ self.assertFalse(is_default)
427
428 if tooltip is not None:
429 self.assertEqual(self.ui.ui.sync_status_button.toolTip(), tooltip)
430@@ -184,18 +174,15 @@
431 # Ensure the _backend_method is not None to execute the first
432 # part of the If.
433 self.ui._backend_method = lambda: 'Not None'
434- self.patch(self.ui.ui, "sync_status_button", FakePageUiStyle())
435+
436 # Simulate the click event
437 self.ui.on_sync_status_button_clicked()
438+
439 self.assertFalse(self.ui.ui.sync_status_button.isEnabled())
440- self.assertTrue(self.ui.ui.sync_status_button.property("secondary"))
441+ self.assertFalse(self.ui.ui.sync_status_button.isDefault())
442 actual_text = self.ui.ui.sync_status_label.text()
443 self.assertEqual(actual_text, LOADING)
444 self.assertEqual(self.ui.ui.sync_status_button.text(), PLEASE_WAIT)
445 actual_icon = self.ui.ui.sync_status_icon.pixmap()
446 expected_icon = gui.pixmap_from_name('sync_status_loading')
447 self.assertEqualPixmaps(expected_icon, actual_icon)
448- self.assertTrue(
449- self.ui.ui.sync_status_button.properties.get('unpolish', True))
450- self.assertTrue(
451- self.ui.ui.sync_status_button.properties.get('polish', True))

Subscribers

People subscribed via source and target branches