Merge lp:~diegosarmentero/ubuntu-sso-client/check-cut-off into lp:ubuntu-sso-client

Proposed by Diego Sarmentero on 2012-03-13
Status: Merged
Approved by: Alejandro J. Cura on 2012-03-13
Approved revision: 905
Merged at revision: 909
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/check-cut-off
Merge into: lp:ubuntu-sso-client
Diff against target: 96 lines (+31/-9)
4 files modified
ubuntu_sso/qt/enhanced_check_box.py (+9/-3)
ubuntu_sso/qt/setup_account_page.py (+1/-1)
ubuntu_sso/qt/tests/test_enhanced_check_box.py (+19/-1)
ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py (+2/-4)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/check-cut-off
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve on 2012-03-13
Roberto Alsina (community) 2012-03-13 Approve on 2012-03-13
Review via email: mp+97231@code.launchpad.net

Commit message

- Removing the align property from the label that wasn't necessary and was breakint the work wrap.
Also adjust the height of the widget depending if it has more than one line (LP: #940392).

To post a comment you must log in.
Roberto Alsina (ralsina) wrote :

+1

review: Approve
Alejandro J. Cura (alecu) wrote :

== Python Lint Notices ==

ubuntu_sso/qt/tests/test_enhanced_check_box.py:
    48: [C0103, EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_small_height] Invalid name "w" (should match [a-z_][a-z0-9_]{1,30}$)
    51: [E1101, EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_small_height] Instance of 'EnhancedCheckBoxTestCase' has no 'assertGreater' member
    57: [C0103, EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_big_height] Invalid name "w" (should match [a-z_][a-z0-9_]{1,30}$)
    60: [E1101, EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_big_height] Instance of 'EnhancedCheckBoxTestCase' has no 'assertLess' member

review: Needs Fixing
Diego Sarmentero (diegosarmentero) wrote :

> == Python Lint Notices ==
>
> ubuntu_sso/qt/tests/test_enhanced_check_box.py:
> 48: [C0103,
> EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_small_height]
> Invalid name "w" (should match [a-z_][a-z0-9_]{1,30}$)
> 51: [E1101,
> EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_small_height]
> Instance of 'EnhancedCheckBoxTestCase' has no 'assertGreater' member
> 57: [C0103,
> EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_big_height]
> Invalid name "w" (should match [a-z_][a-z0-9_]{1,30}$)
> 60: [E1101,
> EnhancedCheckBoxTestCase.test_enhanced_check_size_adjust_with_big_height]
> Instance of 'EnhancedCheckBoxTestCase' has no 'assertLess' member

fixed

904. By Diego Sarmentero on 2012-03-13

Fixed lint issues.

905. By Diego Sarmentero on 2012-03-13

Change assertGreater* to assertTrue

Alejandro J. Cura (alecu) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/qt/enhanced_check_box.py'
2--- ubuntu_sso/qt/enhanced_check_box.py 2012-03-01 16:53:29 +0000
3+++ ubuntu_sso/qt/enhanced_check_box.py 2012-03-13 19:55:36 +0000
4@@ -24,11 +24,12 @@
5 class EnhancedCheckBox(QtGui.QCheckBox):
6 """Enhanced QCheckBox to support links in the message displayed."""
7
8- def __init__(self, text=""):
9- QtGui.QCheckBox.__init__(self)
10+ def __init__(self, text="", parent=None):
11+ QtGui.QCheckBox.__init__(self, parent)
12 hbox = QtGui.QHBoxLayout()
13+ hbox.setAlignment(QtCore.Qt.AlignLeft)
14 self.text_label = QtGui.QLabel(text)
15- self.text_label.setAlignment(QtCore.Qt.AlignTop)
16+ self.text_label.setWordWrap(True)
17 self.text_label.setOpenExternalLinks(True)
18 padding = self.iconSize().width()
19 self.text_label.setStyleSheet("margin-top: -3px;"
20@@ -37,6 +38,11 @@
21 hbox.addWidget(self.text_label)
22 self.setLayout(hbox)
23
24+ if parent is not None:
25+ lines = self.text_label.width() / float(parent.width())
26+ self.text_label.setMinimumWidth(parent.width())
27+ self.setMinimumHeight(self.height() * lines)
28+
29 self.stateChanged.connect(self.text_label.setFocus)
30
31 def text(self):
32
33=== modified file 'ubuntu_sso/qt/setup_account_page.py'
34--- ubuntu_sso/qt/setup_account_page.py 2012-03-12 14:53:00 +0000
35+++ ubuntu_sso/qt/setup_account_page.py 2012-03-13 19:55:36 +0000
36@@ -195,7 +195,7 @@
37 terms = AGREE_TO_PRIVACY_POLICY.format(app_name=self.app_name,
38 privacy_policy=privacy_policy_link)
39
40- self.terms_checkbox = enhanced_check_box.EnhancedCheckBox(terms)
41+ self.terms_checkbox = enhanced_check_box.EnhancedCheckBox(terms, self)
42 self.ui.hlayout_check.addWidget(self.terms_checkbox)
43 self.terms_checkbox.setVisible(bool(self.tc_url or self.policy_url))
44
45
46=== modified file 'ubuntu_sso/qt/tests/test_enhanced_check_box.py'
47--- ubuntu_sso/qt/tests/test_enhanced_check_box.py 2012-02-16 18:40:41 +0000
48+++ ubuntu_sso/qt/tests/test_enhanced_check_box.py 2012-03-13 19:55:36 +0000
49@@ -16,7 +16,7 @@
50
51 """Tests for the EnhancedCheckBox widget."""
52
53-from PyQt4 import QtCore
54+from PyQt4 import QtGui, QtCore
55
56 from ubuntu_sso.qt import enhanced_check_box
57 from ubuntu_sso.qt.tests import BaseTestCase
58@@ -40,3 +40,21 @@
59 check.setText("text")
60 self.assertEqual(check.text(), "text")
61 self.assertEqual(check.text(), check.text_label.text())
62+
63+ def test_enhanced_check_size_adjust_with_small_height(self):
64+ """Check if the size of the EnhancedCheckBox is adjusted correctly."""
65+ text = 't' * 200
66+ height = 10
67+ widget = QtGui.QWidget()
68+ widget.setFixedSize(200, height)
69+ check = enhanced_check_box.EnhancedCheckBox(text, widget)
70+ self.assertTrue(check.height() > height)
71+
72+ def test_enhanced_check_size_adjust_with_big_height(self):
73+ """Check if the size of the EnhancedCheckBox is adjusted correctly."""
74+ text = 't' * 20
75+ height = 200
76+ widget = QtGui.QWidget()
77+ widget.setFixedSize(200, height)
78+ check = enhanced_check_box.EnhancedCheckBox(text, widget)
79+ self.assertTrue(check.height() < height)
80
81=== modified file 'ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py'
82--- ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py 2012-03-09 18:36:07 +0000
83+++ ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py 2012-03-13 19:55:36 +0000
84@@ -115,10 +115,8 @@
85 self.ui.show()
86 self.addCleanup(self.ui.hide)
87 size = self.ui.size()
88- # pylint: disable=E1101
89- self.assertGreaterEqual(size.height(), PREFERED_UI_SIZE['height'])
90- self.assertGreaterEqual(size.width(), PREFERED_UI_SIZE['width'])
91- # pylint: enable=E1101
92+ self.assertTrue(size.height() >= PREFERED_UI_SIZE['height'])
93+ self.assertTrue(size.width() >= PREFERED_UI_SIZE['width'])
94
95 def test_move_to_success_page_state(self):
96 """Test _move_to_success_page method."""

Subscribers

People subscribed via source and target branches