aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-14 21:22:43 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-15 08:05:54 +0000
commitb793cbe460e311b3ed118b02635165db853696c4 (patch)
treee00699aefeadf62e9cbc65004a84174ba8f92dc9
parentd2b13164d85fffc7d379304ca5aefc9304e53a8a (diff)
GroupBox/Frame/ToolBar: use positioners as content item
Change-Id: I8f883dd0fd06172032dd78ff60437c906c2fe8dd Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--examples/quick/controls/mirroring/main.qml117
-rw-r--r--src/imports/controls/Frame.qml10
-rw-r--r--src/imports/controls/GroupBox.qml10
-rw-r--r--src/imports/controls/ToolBar.qml10
-rw-r--r--tests/auto/controls/data/tst_frame.qml10
-rw-r--r--tests/auto/controls/data/tst_groupbox.qml10
-rw-r--r--tests/auto/controls/data/tst_toolbar.qml10
7 files changed, 68 insertions, 109 deletions
diff --git a/examples/quick/controls/mirroring/main.qml b/examples/quick/controls/mirroring/main.qml
index 3deb3cae..5a351993 100644
--- a/examples/quick/controls/mirroring/main.qml
+++ b/examples/quick/controls/mirroring/main.qml
@@ -107,22 +107,19 @@ ApplicationWindow {
title: "CheckBox"
readonly property real preferredWidth: (flow.width - 12) / 2
width: window.width > window.height || implicitWidth > preferredWidth ? flow.width : preferredWidth
- ColumnLayout {
+ CheckBox {
width: parent.width
- CheckBox {
- width: parent.width
- text: "E-mail"
- checked: true
- }
- CheckBox {
- width: parent.width
- text: "Calendar"
- checked: true
- }
- CheckBox {
- width: parent.width
- text: "Contacts"
- }
+ text: "E-mail"
+ checked: true
+ }
+ CheckBox {
+ width: parent.width
+ text: "Calendar"
+ checked: true
+ }
+ CheckBox {
+ width: parent.width
+ text: "Contacts"
}
}
@@ -130,25 +127,22 @@ ApplicationWindow {
title: "RadioButton"
readonly property real preferredWidth: (flow.width - 12) / 2
width: window.width > window.height || implicitWidth > preferredWidth ? flow.width : preferredWidth
- ColumnLayout {
+ ExclusiveGroup { id: eg }
+ RadioButton {
width: parent.width
- ExclusiveGroup { id: eg }
- RadioButton {
- width: parent.width
- text: "Portrait"
- Exclusive.group: eg
- }
- RadioButton {
- width: parent.width
- text: "Landscape"
- Exclusive.group: eg
- }
- RadioButton {
- width: parent.width
- text: "Automatic"
- checked: true
- Exclusive.group: eg
- }
+ text: "Portrait"
+ Exclusive.group: eg
+ }
+ RadioButton {
+ width: parent.width
+ text: "Landscape"
+ Exclusive.group: eg
+ }
+ RadioButton {
+ width: parent.width
+ text: "Automatic"
+ checked: true
+ Exclusive.group: eg
}
}
@@ -160,7 +154,7 @@ ApplicationWindow {
spacing: Theme.spacing
readonly property real availableWidth: (flow.width - 12) / 2
readonly property real contentWidth: okButton.implicitWidth + cancelButton.implicitWidth + 12
- readonly property real buttonWidth: contentWidth > availableWidth ? (width / 2 - spacing) : (width / 2 - 2 * spacing) / 2
+ readonly property real buttonWidth: implicitWidth > availableWidth ? (width / 2 - spacing) : (width / 2 - 2 * spacing) / 2
Button {
id: okButton
text: "Ok"
@@ -177,54 +171,43 @@ ApplicationWindow {
GroupBox {
title: "Switch"
width: flow.width
- Column {
+ Switch {
width: parent.width
- Switch {
- width: parent.width
- text: "Wifi"
- checked: true
- }
- Switch {
- width: parent.width
- text: "Bluetooth"
- }
+ text: "Wifi"
+ checked: true
+ }
+ Switch {
+ width: parent.width
+ text: "Bluetooth"
}
}
GroupBox {
title: "ProgressBar"
width: flow.width
- Column {
+ ProgressBar {
width: parent.width
- spacing: Theme.spacing
- ProgressBar {
- width: parent.width
- indeterminate: true
- }
- ProgressBar {
- width: parent.width
- value: slider.position
- }
+ indeterminate: true
+ }
+ ProgressBar {
+ width: parent.width
+ value: slider.position
}
}
GroupBox {
title: "Slider"
width: flow.width
- Column {
+ Slider {
+ id: slider
+ value: 0.4
width: parent.width
- spacing: Theme.spacing
- Slider {
- id: slider
- value: 0.4
- width: parent.width
- }
- Slider {
- width: parent.width
- snapMode: AbstractSlider.SnapAlways
- stepSize: 0.2
- value: 0.8
- }
+ }
+ Slider {
+ width: parent.width
+ snapMode: AbstractSlider.SnapAlways
+ stepSize: 0.2
+ value: 0.8
}
}
}
diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml
index c1c2ea62..849b8e62 100644
--- a/src/imports/controls/Frame.qml
+++ b/src/imports/controls/Frame.qml
@@ -43,17 +43,15 @@ AbstractFrame {
default property alias data: content.data
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- contentWidth + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentHeight + topPadding + bottomPadding)
-
- contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
- contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
padding: Theme.padding
- contentItem: Item {
+ contentItem: Column {
id: content
+ spacing: control.Theme.spacing
}
frame: Rectangle {
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
index 78eb4393..e3068014 100644
--- a/src/imports/controls/GroupBox.qml
+++ b/src/imports/controls/GroupBox.qml
@@ -43,18 +43,16 @@ AbstractGroupBox {
default property alias data: content.data
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- contentWidth + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentHeight + topPadding + bottomPadding)
-
- contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
- contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
padding: Theme.padding
topPadding: Theme.padding + (label && title ? label.implicitHeight + Theme.spacing : 0)
- contentItem: Item {
+ contentItem: Column {
id: content
+ spacing: control.Theme.spacing
}
label: Text {
diff --git a/src/imports/controls/ToolBar.qml b/src/imports/controls/ToolBar.qml
index 43666db2..7677607d 100644
--- a/src/imports/controls/ToolBar.qml
+++ b/src/imports/controls/ToolBar.qml
@@ -43,17 +43,15 @@ AbstractToolBar {
default property alias data: content.data
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- contentWidth + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentHeight + topPadding + bottomPadding)
-
- contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
- contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
Accessible.role: Accessible.ToolBar
- contentItem: Item {
+ contentItem: Row {
id: content
+ spacing: control.Theme.spacing
}
background: Rectangle {
diff --git a/tests/auto/controls/data/tst_frame.qml b/tests/auto/controls/data/tst_frame.qml
index 43e0c298..5eb600de 100644
--- a/tests/auto/controls/data/tst_frame.qml
+++ b/tests/auto/controls/data/tst_frame.qml
@@ -82,15 +82,11 @@ TestCase {
function test_defaults() {
var control = frame.createObject(testCase)
verify(control.contentItem)
- compare(control.contentWidth, 0)
- compare(control.contentHeight, 0)
control.destroy()
}
function test_oneChild() {
var control = oneChildFrame.createObject(testCase)
- compare(control.contentWidth, 100)
- compare(control.contentHeight, 30)
verify(control.implicitWidth > 100)
verify(control.implicitHeight > 30)
control.destroy()
@@ -98,10 +94,8 @@ TestCase {
function test_twoChildren() {
var control = twoChildrenFrame.createObject(testCase)
- compare(control.contentWidth, 0)
- compare(control.contentHeight, 0)
- verify(control.implicitWidth > 0)
- verify(control.implicitHeight > 0)
+ verify(control.implicitWidth > 200)
+ verify(control.implicitHeight > 60)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml
index 65aa4e16..760450f0 100644
--- a/tests/auto/controls/data/tst_groupbox.qml
+++ b/tests/auto/controls/data/tst_groupbox.qml
@@ -83,15 +83,11 @@ TestCase {
var control = groupBox.createObject(testCase)
verify(control.contentItem)
compare(control.title, "")
- compare(control.contentWidth, 0)
- compare(control.contentHeight, 0)
control.destroy()
}
function test_oneChild() {
var control = oneChildBox.createObject(testCase)
- compare(control.contentWidth, 100)
- compare(control.contentHeight, 30)
verify(control.implicitWidth > 100)
verify(control.implicitHeight > 30)
control.destroy()
@@ -99,10 +95,8 @@ TestCase {
function test_twoChildren() {
var control = twoChildrenBox.createObject(testCase)
- compare(control.contentWidth, 0)
- compare(control.contentHeight, 0)
- verify(control.implicitWidth > 0)
- verify(control.implicitHeight > 0)
+ verify(control.implicitWidth > 200)
+ verify(control.implicitHeight > 60)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml
index 6b343894..694e6e24 100644
--- a/tests/auto/controls/data/tst_toolbar.qml
+++ b/tests/auto/controls/data/tst_toolbar.qml
@@ -82,15 +82,11 @@ TestCase {
function test_defaults() {
var control = toolBar.createObject(testCase)
verify(control.contentItem)
- compare(control.contentWidth, 0)
- compare(control.contentHeight, 0)
control.destroy()
}
function test_oneChild() {
var control = oneChildBar.createObject(testCase)
- compare(control.contentWidth, 100)
- compare(control.contentHeight, 30)
verify(control.implicitWidth > 100)
verify(control.implicitHeight > 30)
control.destroy()
@@ -98,10 +94,8 @@ TestCase {
function test_twoChildren() {
var control = twoChildrenBar.createObject(testCase)
- compare(control.contentWidth, 0)
- compare(control.contentHeight, 0)
- verify(control.implicitWidth > 0)
- verify(control.implicitHeight > 0)
+ verify(control.implicitWidth > 200)
+ verify(control.implicitHeight > 60)
control.destroy()
}
}