← Back to team overview

ubuntu-sdk-team team mailing list archive

[Merge] lp:~daker/ubuntu-ui-toolkit/fix.1333228 into lp:ubuntu-ui-toolkit/staging

 

Adnane Belmadiaf has proposed merging lp:~daker/ubuntu-ui-toolkit/fix.1333228 into lp:ubuntu-ui-toolkit/staging.

Requested reviews:
  Ubuntu SDK team (ubuntu-sdk-team)
Related bugs:
  Bug #1333228 in unity8 (Ubuntu): "[sdk] Clicking on checkbox label should toggle the checkbox"
  https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1333228

For more details, see:
https://code.launchpad.net/~daker/ubuntu-ui-toolkit/fix.1333228/+merge/318311
-- 
Your team Ubuntu SDK team is requested to review the proposed merge of lp:~daker/ubuntu-ui-toolkit/fix.1333228 into lp:ubuntu-ui-toolkit/staging.
=== modified file 'examples/ubuntu-ui-toolkit-gallery/Toggles.qml'
--- examples/ubuntu-ui-toolkit-gallery/Toggles.qml	2015-04-25 08:18:45 +0000
+++ examples/ubuntu-ui-toolkit-gallery/Toggles.qml	2017-02-25 16:48:07 +0000
@@ -55,6 +55,38 @@
                 checked: true
             }
         }
+
+        TemplateRow {
+            title: i18n.tr("Checkbox with label")
+
+            CheckBox {
+                objectName: "checkbox_checked_lbl"
+                checked: true
+                text: "This a checkbox label"
+            }
+        }
+
+        TemplateRow {
+            title: i18n.tr("Disabled checkbox with label")
+
+            CheckBox {
+                objectName: "checkbox_disabled_checked_lbl"
+                checked: true
+                enabled: false
+                text: "This a checkbox label"
+            }
+        }
+
+        TemplateRow {
+            title: i18n.tr("Disabled checkbox with label")
+
+            CheckBox {
+                objectName: "checkbox_disabled_checked_lbl"
+                checked: false
+                enabled: false
+                text: "This a checkbox label"
+            }
+        }
     }
 
 

=== modified file 'src/imports/Components/Themes/Ambiance/1.3/CheckBoxStyle.qml'
--- src/imports/Components/Themes/Ambiance/1.3/CheckBoxStyle.qml	2016-01-27 15:17:56 +0000
+++ src/imports/Components/Themes/Ambiance/1.3/CheckBoxStyle.qml	2017-02-25 16:48:07 +0000
@@ -65,9 +65,12 @@
     UbuntuShape {
         id: background
         anchors {
+            margins: checkBoxStyle.backgroundPadding
+            left: parent.left
+            right: checkBoxLbl.left
             fill: parent
-            margins: checkBoxStyle.backgroundPadding
         }
+
         property real iconSize: Math.min(width, height) - 2*checkBoxStyle.iconPadding
 
         Icon {
@@ -164,4 +167,17 @@
             }
         ]
     }
+
+    Label {
+        id: parent
+        text: styledItem.text
+        anchors.left: background.right
+        anchors.leftMargin: units.gu(1)
+        enabled: styledItem.enabled
+        visible: styledItem.text != ""
+        MouseArea {
+            anchors.fill: parent
+            onClicked: styledItem.checked = !styledItem.checked
+        }
+    }
 }

=== modified file 'tests/unit/visual/tst_toggles.13.qml'
--- tests/unit/visual/tst_toggles.13.qml	2016-06-15 13:46:51 +0000
+++ tests/unit/visual/tst_toggles.13.qml	2017-02-25 16:48:07 +0000
@@ -39,6 +39,23 @@
             property bool checkedNow: true
             onClicked: checkedNow = checked
         }
+
+        CheckBox {
+            id: testCheckLbl
+            checked: true
+            text: "This a checkbox label"
+            property bool checkedNow: true
+            onClicked: checkedNow = checked
+        }
+
+        CheckBox {
+            id: testCheckLblDisabled
+            checked: false
+            enabled: false
+            text: "This a checkbox label"
+            property bool checkedNow: false
+            onClicked: checkedNow = checked
+        }
     }
 
     UbuntuTestCase {
@@ -75,6 +92,38 @@
             clickedSpy.wait(400);
             compare(data.testItem.checkedNow, data.testItem.checked);
         }
+
+
+        function test_toggle_lbl_checked_data() {
+            return [
+                {tag: "CheckBox", testItem: testCheckLbl, mouse: true},
+            ];
+        }
+
+        function test_toggle_lbl_checked(data) {
+            data.testItem.checkedNow = data.testItem.checked;
+            data.testItem.forceActiveFocus();
+            clickedSpy.target = data.testItem;
+            mouseClick(data.testItem, centerOf(data.testItem).x, centerOf(data.testItem).y);
+            clickedSpy.wait(400);
+            compare(data.testItem.checkedNow, data.testItem.checked);
+        }
+
+        function test_toggle_lbl_checked_disabled_data() {
+            return [
+                {tag: "CheckBox", testItem: testCheckLblDisabled, mouse: true},
+            ];
+        }
+
+        function test_toggle_lbl_checked_disabled(data) {
+            data.testItem.checkedNow = data.testItem.checked;
+            data.testItem.forceActiveFocus();
+            clickedSpy.target = data.testItem;
+            mouseClick(data.testItem, centerOf(data.testItem).x, centerOf(data.testItem).y);
+            compare(clickedSpy.count, 0);
+            compare(data.testItem.checkedNow, data.testItem.checked);
+        }
+
     }
 }
 


Follow ups