Merge lp:~ralsina/ubuntu-sso-client/ubuntu-font-in-windows into lp:ubuntu-sso-client

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 923
Merged at revision: 923
Proposed branch: lp:~ralsina/ubuntu-sso-client/ubuntu-font-in-windows
Merge into: lp:ubuntu-sso-client
Diff against target: 209 lines (+104/-13)
9 files modified
data/qt/linux.qss (+2/-0)
data/qt/resources.qrc (+2/-0)
data/qt/stylesheet.qss (+0/-1)
data/qt/windows.qss (+5/-0)
ubuntu_sso/qt/main.py (+6/-3)
ubuntu_sso/qt/tests/test_main.py (+44/-8)
ubuntu_sso/utils/__init__.py (+7/-1)
ubuntu_sso/utils/linux.py (+19/-0)
ubuntu_sso/utils/windows.py (+19/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntu-sso-client/ubuntu-font-in-windows
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
dobey (community) Approve
Review via email: mp+98010@code.launchpad.net

Commit message

 - Enable platform-specific styling (LP: #953318).

Description of the change

 - Enable platform-specific styling (LP: #953318).

Also, fixed and unskipped a test for main()

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'data/qt/linux.qss'
2--- data/qt/linux.qss 1970-01-01 00:00:00 +0000
3+++ data/qt/linux.qss 2012-03-16 22:41:20 +0000
4@@ -0,0 +1,2 @@
5+/* Styles specific to the linux platform */
6+
7
8=== modified file 'data/qt/resources.qrc'
9--- data/qt/resources.qrc 2012-02-16 14:13:36 +0000
10+++ data/qt/resources.qrc 2012-03-16 22:41:20 +0000
11@@ -6,5 +6,7 @@
12 <file>../Ubuntu-B.ttf</file>
13 <file>../balloon_shape.png</file>
14 <file>stylesheet.qss</file>
15+ <file>windows.qss</file>
16+ <file>linux.qss</file>
17 </qresource>
18 </RCC>
19
20=== modified file 'data/qt/stylesheet.qss'
21--- data/qt/stylesheet.qss 2012-03-16 14:30:51 +0000
22+++ data/qt/stylesheet.qss 2012-03-16 22:41:20 +0000
23@@ -1,5 +1,4 @@
24 QWidget {
25- font-family: "Ubuntu";
26 color: #333333;
27 }
28
29
30=== added file 'data/qt/windows.qss'
31--- data/qt/windows.qss 1970-01-01 00:00:00 +0000
32+++ data/qt/windows.qss 2012-03-16 22:41:20 +0000
33@@ -0,0 +1,5 @@
34+/* Styles specific to the windows platform */
35+
36+QWidget {
37+ font-family: "Ubuntu";
38+}
39
40=== modified file 'ubuntu_sso/qt/main.py'
41--- ubuntu_sso/qt/main.py 2012-02-24 19:54:48 +0000
42+++ ubuntu_sso/qt/main.py 2012-03-16 22:41:20 +0000
43@@ -25,6 +25,7 @@
44 from ubuntu_sso.qt.ui import resources_rc
45 # pylint: enable=W0611
46 from ubuntu_sso.qt.ubuntu_sso_wizard import UbuntuSSOClientGUI
47+from ubuntu_sso.utils import PLATFORM_QSS
48
49
50 def main(**kwargs):
51@@ -34,9 +35,11 @@
52 QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-R.ttf')
53 QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-B.ttf')
54
55- # Apply Style Sheet -- The windows version may be different
56- qss = QtCore.QResource(":/stylesheet.qss")
57- app.setStyleSheet(qss.data())
58+ data = []
59+ for qss_name in (PLATFORM_QSS, ":/stylesheet.qss"):
60+ qss = QtCore.QResource(qss_name)
61+ data.append(unicode(qss.data()))
62+ app.setStyleSheet('\n'.join(data))
63
64 # Unused variable 'ui', pylint: disable=W0612
65 ui = UbuntuSSOClientGUI(close_callback=app.exit, **kwargs)
66
67=== modified file 'ubuntu_sso/qt/tests/test_main.py'
68--- ubuntu_sso/qt/tests/test_main.py 2012-02-13 15:43:59 +0000
69+++ ubuntu_sso/qt/tests/test_main.py 2012-03-16 22:41:20 +0000
70@@ -16,27 +16,63 @@
71
72 """Tests for the main module."""
73
74+from PyQt4 import QtCore
75+from twisted.internet import defer
76 from twisted.trial.unittest import TestCase
77
78 from ubuntu_sso.qt import main
79
80
81+# pylint: disable=C0103
82+class FakeUi(object):
83+
84+ """A fake UI."""
85+
86+ def size(self):
87+ """Fake size."""
88+ return QtCore.QSize(100, 100)
89+
90+ def setGeometry(self, *args):
91+ """Fake setGeometry."""
92+
93+ show = setGeometry
94+# pylint: enable=C0103
95+
96+
97 class BasicTestCase(TestCase):
98 """Test case with a helper tracker."""
99
100+ @defer.inlineCallbacks
101+ def setUp(self):
102+ yield super(BasicTestCase, self).setUp()
103+ self.called = []
104+
105+ def called_ui(**kw):
106+ """record ui call."""
107+ self.called.append(('GUI', kw))
108+ return FakeUi()
109+
110+ self.patch(main, 'UbuntuSSOClientGUI', called_ui)
111+ self.patch(main.QtGui.QApplication, 'exec_',
112+ lambda *a: self.called.append('main'))
113+
114 def test_main(self):
115 """Calling main.main() a UI instance is created."""
116- called = []
117- self.patch(main, 'UbuntuSSOClientGUI',
118- lambda **kw: called.append(('GUI', kw)))
119- self.patch(main.QtGui.QApplication, 'exec_',
120- lambda *a: called.append('main'))
121
122 kwargs = dict(foo='foo', bar='bar', baz='yadda', yadda=0)
123 main.main(**kwargs)
124
125 kwargs['close_callback'] = main.QtGui.QApplication.instance().exit
126- self.assertEqual(called, [('GUI', kwargs), 'main'])
127+ self.assertEqual(self.called, [('GUI', kwargs), 'main'])
128
129- test_main.skip = 'Failing with QObject::startTimer: QTimer can only be ' \
130- 'used with threads started with QThread'
131+ def test_styles_load(self):
132+ """Test that all stylesheets load."""
133+ kwargs = dict(foo='foo', bar='bar', baz='yadda', yadda=0)
134+ main.main(**kwargs)
135+ data = []
136+ for qss_name in (main.PLATFORM_QSS, ":/stylesheet.qss"):
137+ qss = QtCore.QResource(qss_name)
138+ data.append(unicode(qss.data()))
139+ self.assertEqual(
140+ unicode(QtCore.QCoreApplication.instance().styleSheet()),
141+ '\n'.join(data))
142
143=== modified file 'ubuntu_sso/utils/__init__.py'
144--- ubuntu_sso/utils/__init__.py 2012-03-15 19:25:34 +0000
145+++ ubuntu_sso/utils/__init__.py 2012-03-16 22:41:20 +0000
146@@ -32,8 +32,14 @@
147
148
149 logger = setup_logging("ubuntu_sso.utils")
150+BIN_SUFFIX = 'bin'
151 DATA_SUFFIX = 'data'
152-BIN_SUFFIX = 'bin'
153+
154+if sys.platform == "win32":
155+ from ubuntu_sso.utils import windows as source
156+else:
157+ from ubuntu_sso.utils import linux as source
158+PLATFORM_QSS = source.PLATFORM_QSS
159
160
161 def _get_dir(dir_name, dir_constant):
162
163=== added file 'ubuntu_sso/utils/linux.py'
164--- ubuntu_sso/utils/linux.py 1970-01-01 00:00:00 +0000
165+++ ubuntu_sso/utils/linux.py 2012-03-16 22:41:20 +0000
166@@ -0,0 +1,19 @@
167+# -*- coding: utf-8 -*-
168+#
169+# Copyright 2010-2012 Canonical Ltd.
170+#
171+# This program is free software: you can redistribute it and/or modify it
172+# under the terms of the GNU General Public License version 3, as published
173+# by the Free Software Foundation.
174+#
175+# This program is distributed in the hope that it will be useful, but
176+# WITHOUT ANY WARRANTY; without even the implied warranties of
177+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
178+# PURPOSE. See the GNU General Public License for more details.
179+#
180+# You should have received a copy of the GNU General Public License along
181+# with this program. If not, see <http://www.gnu.org/licenses/>.
182+
183+"""Platform specific constants and functions (for Linux)."""
184+
185+PLATFORM_QSS = ":/linux.qss"
186
187=== added file 'ubuntu_sso/utils/windows.py'
188--- ubuntu_sso/utils/windows.py 1970-01-01 00:00:00 +0000
189+++ ubuntu_sso/utils/windows.py 2012-03-16 22:41:20 +0000
190@@ -0,0 +1,19 @@
191+# -*- coding: utf-8 -*-
192+#
193+# Copyright 2010-2012 Canonical Ltd.
194+#
195+# This program is free software: you can redistribute it and/or modify it
196+# under the terms of the GNU General Public License version 3, as published
197+# by the Free Software Foundation.
198+#
199+# This program is distributed in the hope that it will be useful, but
200+# WITHOUT ANY WARRANTY; without even the implied warranties of
201+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
202+# PURPOSE. See the GNU General Public License for more details.
203+#
204+# You should have received a copy of the GNU General Public License along
205+# with this program. If not, see <http://www.gnu.org/licenses/>.
206+
207+"""Platform specific constants and functions (for Windows)."""
208+
209+PLATFORM_QSS = ":/windows.qss"

Subscribers

People subscribed via source and target branches