Merge lp:~mandel/ubuntuone-control-panel/double-gathering into lp:ubuntuone-control-panel

Proposed by Manuel de la Peña on 2012-10-16
Status: Merged
Approved by: Roberto Alsina on 2012-10-17
Approved revision: 371
Merged at revision: 371
Proposed branch: lp:~mandel/ubuntuone-control-panel/double-gathering
Merge into: lp:ubuntuone-control-panel
Diff against target: 215 lines (+132/-4)
5 files modified
data/qt/controlpanel.ui (+8/-2)
ubuntuone/controlpanel/gui/qt/controlpanel.py (+6/-1)
ubuntuone/controlpanel/gui/qt/tabbed_panel.py (+45/-0)
ubuntuone/controlpanel/gui/qt/tests/test_tabbed_panel.py (+55/-0)
ubuntuone/controlpanel/gui/qt/ubuntuonebin.py (+18/-1)
To merge this branch: bzr merge lp:~mandel/ubuntuone-control-panel/double-gathering
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve on 2012-10-17
Diego Sarmentero (community) 2012-10-16 Approve on 2012-10-16
Review via email: mp+129871@code.launchpad.net

Commit Message

- Stop showing double overlay by ensuring that we can tell the different panels not to show it via the tabbed panel (LP: #1065513).
- Set the username label before the overlay is removed (LP: #1067329).

Description of the Change

- Stop showing double overlay by ensuring that we can tell the different panels not to show it via their parent (LP: #1065513).
- Set the username label before the overlay is removed (LP: #1067329).

To post a comment you must log in.
371. By Manuel de la Peña on 2012-10-16

Don't change things from the ui that should not change.

Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/qt/controlpanel.ui'
2--- data/qt/controlpanel.ui 2012-08-24 19:39:19 +0000
3+++ data/qt/controlpanel.ui 2012-10-16 12:47:22 +0000
4@@ -221,7 +221,7 @@
5 </widget>
6 </item>
7 <item>
8- <widget class="QTabWidget" name="tab_widget">
9+ <widget class="TabbedPanel" name="tab_widget">
10 <property name="sizePolicy">
11 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
12 <horstretch>0</horstretch>
13@@ -238,7 +238,7 @@
14 </widget>
15 <widget class="ShareLinksPanel" name="share_links_tab">
16 <attribute name="title">
17- <string>Share Links</string>
18+ <string notr="true">Share Links</string>
19 </attribute>
20 </widget>
21 <widget class="DevicesPanel" name="devices_tab">
22@@ -427,6 +427,12 @@
23 <header>ubuntuone.controlpanel.gui.qt.share_links</header>
24 <container>1</container>
25 </customwidget>
26+ <customwidget>
27+ <class>TabbedPanel</class>
28+ <extends>QTabWidget</extends>
29+ <header>ubuntuone.controlpanel.gui.qt.tabbed_panel</header>
30+ <container>1</container>
31+ </customwidget>
32 </customwidgets>
33 <tabstops>
34 <tabstop>help_button</tabstop>
35
36=== modified file 'ubuntuone/controlpanel/gui/qt/controlpanel.py'
37--- ubuntuone/controlpanel/gui/qt/controlpanel.py 2012-10-08 18:11:55 +0000
38+++ ubuntuone/controlpanel/gui/qt/controlpanel.py 2012-10-16 12:47:22 +0000
39@@ -87,6 +87,10 @@
40 self.ui.tab_widget.setTabText(
41 self.ui.tab_widget.indexOf(self.ui.account_tab), MAIN_ACCOUNT_TAB)
42
43+ # in the setup lets not show the overlay in the tabs until we got the
44+ # account info
45+ self.ui.tab_widget.show_overlay = False
46+
47 @defer.inlineCallbacks
48 def connect_file_sync(self):
49 """Connect file sync service if the setting autoconnect is enabled."""
50@@ -112,10 +116,11 @@
51 """Credentials are not found or were removed."""
52 self.ui.switcher.setCurrentWidget(self.ui.management)
53 self.connect_file_sync()
54- self.is_processing = False
55
56 info = yield self.backend.account_info()
57 self.process_info(info)
58+ self.is_processing = False
59+ self.ui.tab_widget.show_overlay = True
60
61 # pylint: disable=E0202
62 @defer.inlineCallbacks
63
64=== added file 'ubuntuone/controlpanel/gui/qt/tabbed_panel.py'
65--- ubuntuone/controlpanel/gui/qt/tabbed_panel.py 1970-01-01 00:00:00 +0000
66+++ ubuntuone/controlpanel/gui/qt/tabbed_panel.py 2012-10-16 12:47:22 +0000
67@@ -0,0 +1,45 @@
68+# -*- coding: utf-8 -*-
69+#
70+# Copyright 2012 Canonical Ltd.
71+#
72+# This program is free software: you can redistribute it and/or modify it
73+# under the terms of the GNU General Public License version 3, as published
74+# by the Free Software Foundation.
75+#
76+# This program is distributed in the hope that it will be useful, but
77+# WITHOUT ANY WARRANTY; without even the implied warranties of
78+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
79+# PURPOSE. See the GNU General Public License for more details.
80+#
81+# You should have received a copy of the GNU General Public License along
82+# with this program. If not, see <http://www.gnu.org/licenses/>.
83+
84+"""Tabbed panel used to show the information optained via rest services."""
85+
86+from PyQt4 import QtGui
87+
88+
89+class TabbedPanel(QtGui.QTabWidget):
90+ """Widget that shows tabs that use rest services to get the info."""
91+
92+ def __init__(self, *args, **kwargs):
93+ super(TabbedPanel, self).__init__(*args, **kwargs)
94+ self._show_overlay = False
95+
96+ def _get_show_overlay(self):
97+ """Get if the overlay is shown."""
98+ return self._show_overlay
99+
100+ def _set_show_overlay(self, is_shown):
101+ """Set if the overlay is shown."""
102+ # we need to loop over the differet tabs and get their widgets, if the
103+ # widet does have an overlay, lets set the value
104+ for index in range(self.count()):
105+ widget = self.widget(index)
106+ show_overlay = getattr(widget, 'show_overlay', None)
107+ if show_overlay is not None:
108+ widget.show_overlay = is_shown
109+
110+ self._show_overlay = is_shown
111+
112+ show_overlay = property(fget=_get_show_overlay, fset=_set_show_overlay)
113
114=== added file 'ubuntuone/controlpanel/gui/qt/tests/test_tabbed_panel.py'
115--- ubuntuone/controlpanel/gui/qt/tests/test_tabbed_panel.py 1970-01-01 00:00:00 +0000
116+++ ubuntuone/controlpanel/gui/qt/tests/test_tabbed_panel.py 2012-10-16 12:47:22 +0000
117@@ -0,0 +1,55 @@
118+# -*- coding: utf-8 -*-
119+
120+#
121+# Copyright 2011 Canonical Ltd.
122+#
123+# This program is free software: you can redistribute it and/or modify it
124+# under the terms of the GNU General Public License version 3, as published
125+# by the Free Software Foundation.
126+#
127+# This program is distributed in the hope that it will be useful, but
128+# WITHOUT ANY WARRANTY; without even the implied warranties of
129+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
130+# PURPOSE. See the GNU General Public License for more details.
131+#
132+# You should have received a copy of the GNU General Public License along
133+# with this program. If not, see <http://www.gnu.org/licenses/>.
134+
135+"""Tests for the tabbed panel."""
136+
137+from PyQt4 import QtGui
138+from twisted.internet import defer
139+from twisted.trial.unittest import TestCase
140+
141+from ubuntuone.controlpanel.gui.qt import tabbed_panel
142+
143+
144+class FakeOverlayWidget(QtGui.QLabel):
145+ """Fake a widget that does have the show_orvelay attribute."""
146+
147+ def __init__(self, *args, **kwargs):
148+ super(FakeOverlayWidget, self).__init__(*args, **kwargs)
149+ self.show_overlay = False
150+
151+
152+class TabbedPanelTestCase(TestCase):
153+ """Test the tabbed panel."""
154+
155+ @defer.inlineCallbacks
156+ def setUp(self):
157+ """Set the tests."""
158+ yield super(TabbedPanelTestCase, self).setUp()
159+ self.tab_widget = tabbed_panel.TabbedPanel()
160+
161+ def test_all_overlay_supported(self):
162+ """Test when all the widgets support the overlay feature."""
163+ labels = [FakeOverlayWidget("Test"),
164+ FakeOverlayWidget("Test"),
165+ FakeOverlayWidget("Test")]
166+ for lab in labels:
167+ self.tab_widget.addTab(lab, 'label')
168+
169+ self.tab_widget.show_overlay = True
170+ self.assertTrue(all([l.show_overlay for l in labels]))
171+ self.tab_widget.show_overlay = False
172+ self.assertFalse(any([l.show_overlay for l in labels]))
173
174=== modified file 'ubuntuone/controlpanel/gui/qt/ubuntuonebin.py'
175--- ubuntuone/controlpanel/gui/qt/ubuntuonebin.py 2012-04-05 22:20:40 +0000
176+++ ubuntuone/controlpanel/gui/qt/ubuntuonebin.py 2012-10-16 12:47:22 +0000
177@@ -40,6 +40,7 @@
178
179 self.overlay = LoadingOverlay(self)
180 self.overlay.hide()
181+ self._show_overlay = True
182
183 self._is_processing = None
184 self.is_processing = False
185@@ -51,6 +52,21 @@
186
187 self._setup()
188
189+ def _get_show_overlay(self):
190+ """Get if the overlay will be shown."""
191+ return self._show_overlay
192+
193+ def _set_show_overlay(self, is_shown):
194+ """Set if the overlay will be shown."""
195+ self._show_overlay = is_shown
196+
197+ if self._show_overlay and self._is_processing:
198+ self.overlay.setVisible(is_shown)
199+ else:
200+ self.overlay.hide()
201+
202+ show_overlay = property(fget=_get_show_overlay, fset=_set_show_overlay)
203+
204 def _get_is_processing(self):
205 """Get the value of is_processing."""
206 return self._is_processing
207@@ -62,7 +78,8 @@
208 If not is_processing, enable the UI and hide the spinner.
209
210 """
211- self.overlay.setVisible(new_value)
212+ if self._show_overlay:
213+ self.overlay.setVisible(new_value)
214 self.setEnabled(not new_value)
215 self._is_processing = new_value
216

Subscribers

People subscribed via source and target branches

to all changes: