diff options
-rw-r--r-- | examples/quick/controls/mirroring/main.qml | 117 | ||||
-rw-r--r-- | src/controls/qquickframe.cpp | 42 | ||||
-rw-r--r-- | src/controls/qquickframe_p.h | 10 | ||||
-rw-r--r-- | src/controls/qquickframe_p_p.h | 2 | ||||
-rw-r--r-- | src/controls/qquicktoolbar.cpp | 4 | ||||
-rw-r--r-- | src/controls/qquicktoolbar_p.h | 4 | ||||
-rw-r--r-- | src/imports/controls/Frame.qml | 12 | ||||
-rw-r--r-- | src/imports/controls/GroupBox.qml | 12 | ||||
-rw-r--r-- | src/imports/controls/ToolBar.qml | 12 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_frame.qml | 10 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_groupbox.qml | 10 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_toolbar.qml | 10 |
12 files changed, 166 insertions, 79 deletions
diff --git a/examples/quick/controls/mirroring/main.qml b/examples/quick/controls/mirroring/main.qml index 5a351993..cf691486 100644 --- a/examples/quick/controls/mirroring/main.qml +++ b/examples/quick/controls/mirroring/main.qml @@ -106,43 +106,49 @@ ApplicationWindow { GroupBox { title: "CheckBox" readonly property real preferredWidth: (flow.width - 12) / 2 - width: window.width > window.height || implicitWidth > preferredWidth ? flow.width : preferredWidth - CheckBox { + width: window.width > window.height || contentWidth > preferredWidth ? flow.width : preferredWidth + ColumnLayout { width: parent.width - text: "E-mail" - checked: true - } - CheckBox { - width: parent.width - text: "Calendar" - checked: true - } - CheckBox { - width: parent.width - text: "Contacts" + CheckBox { + width: parent.width + text: "E-mail" + checked: true + } + CheckBox { + width: parent.width + text: "Calendar" + checked: true + } + CheckBox { + width: parent.width + text: "Contacts" + } } } GroupBox { title: "RadioButton" readonly property real preferredWidth: (flow.width - 12) / 2 - width: window.width > window.height || implicitWidth > preferredWidth ? flow.width : preferredWidth + width: window.width > window.height || contentWidth > preferredWidth ? flow.width : preferredWidth ExclusiveGroup { id: eg } - RadioButton { + ColumnLayout { 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 + 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 + } } } @@ -171,43 +177,54 @@ ApplicationWindow { GroupBox { title: "Switch" width: flow.width - Switch { + Column { width: parent.width - text: "Wifi" - checked: true - } - Switch { - width: parent.width - text: "Bluetooth" + Switch { + width: parent.width + text: "Wifi" + checked: true + } + Switch { + width: parent.width + text: "Bluetooth" + } } } GroupBox { title: "ProgressBar" width: flow.width - ProgressBar { + Column { width: parent.width - indeterminate: true - } - ProgressBar { - width: parent.width - value: slider.position + spacing: Theme.spacing + ProgressBar { + width: parent.width + indeterminate: true + } + ProgressBar { + width: parent.width + value: slider.position + } } } GroupBox { title: "Slider" width: flow.width - Slider { - id: slider - value: 0.4 - width: parent.width - } - Slider { + Column { width: parent.width - snapMode: AbstractSlider.SnapAlways - stepSize: 0.2 - value: 0.8 + 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 + } } } } diff --git a/src/controls/qquickframe.cpp b/src/controls/qquickframe.cpp index 2f2ec65d..ae642b61 100644 --- a/src/controls/qquickframe.cpp +++ b/src/controls/qquickframe.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE TODO */ -QQuickFramePrivate::QQuickFramePrivate() : frame(Q_NULLPTR) +QQuickFramePrivate::QQuickFramePrivate() : contentWidth(0), contentHeight(0), frame(Q_NULLPTR) { } @@ -65,6 +65,46 @@ QQuickFrame::QQuickFrame(QQuickFramePrivate &dd, QQuickItem *parent) : } /*! + \qmlproperty real QtQuickControls2::Frame::contentWidth + + TODO +*/ +qreal QQuickFrame::contentWidth() const +{ + Q_D(const QQuickFrame); + return d->contentWidth; +} + +void QQuickFrame::setContentWidth(qreal width) +{ + Q_D(QQuickFrame); + if (d->contentWidth != width) { + d->contentWidth = width; + emit contentWidthChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::Frame::contentHeight + + TODO +*/ +qreal QQuickFrame::contentHeight() const +{ + Q_D(const QQuickFrame); + return d->contentHeight; +} + +void QQuickFrame::setContentHeight(qreal height) +{ + Q_D(QQuickFrame); + if (d->contentHeight != height) { + d->contentHeight = height; + emit contentHeightChanged(); + } +} + +/*! \qmlproperty Item QtQuickControls2::Frame::frame TODO diff --git a/src/controls/qquickframe_p.h b/src/controls/qquickframe_p.h index d7bcc490..b56f9fcb 100644 --- a/src/controls/qquickframe_p.h +++ b/src/controls/qquickframe_p.h @@ -57,15 +57,25 @@ class QQuickFramePrivate; class Q_QUICKCONTROLS_EXPORT QQuickFrame : public QQuickControl { Q_OBJECT + Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL) + Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL) Q_PROPERTY(QQuickItem *frame READ frame WRITE setFrame NOTIFY frameChanged FINAL) public: explicit QQuickFrame(QQuickItem *parent = Q_NULLPTR); + qreal contentWidth() const; + void setContentWidth(qreal width); + + qreal contentHeight() const; + void setContentHeight(qreal height); + QQuickItem *frame() const; void setFrame(QQuickItem *frame); Q_SIGNALS: + void contentWidthChanged(); + void contentHeightChanged(); void frameChanged(); protected: diff --git a/src/controls/qquickframe_p_p.h b/src/controls/qquickframe_p_p.h index 19a9af84..60b0775f 100644 --- a/src/controls/qquickframe_p_p.h +++ b/src/controls/qquickframe_p_p.h @@ -57,6 +57,8 @@ class Q_QUICKCONTROLS_EXPORT QQuickFramePrivate : public QQuickControlPrivate public: QQuickFramePrivate(); + qreal contentWidth; + qreal contentHeight; QQuickItem *frame; }; diff --git a/src/controls/qquicktoolbar.cpp b/src/controls/qquicktoolbar.cpp index 90959ba9..9418c491 100644 --- a/src/controls/qquicktoolbar.cpp +++ b/src/controls/qquicktoolbar.cpp @@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype ToolBar - \inherits Container + \inherits Frame \instantiates QQuickToolBar \inqmlmodule QtQuick.Controls \ingroup containers @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE */ QQuickToolBar::QQuickToolBar(QQuickItem *parent) : - QQuickContainer(parent) + QQuickFrame(parent) { } diff --git a/src/controls/qquicktoolbar_p.h b/src/controls/qquicktoolbar_p.h index 50352186..878ffe8c 100644 --- a/src/controls/qquicktoolbar_p.h +++ b/src/controls/qquicktoolbar_p.h @@ -48,11 +48,11 @@ // We mean it. // -#include <QtQuickControls/private/qquickcontainer_p.h> +#include <QtQuickControls/private/qquickframe_p.h> QT_BEGIN_NAMESPACE -class Q_QUICKCONTROLS_EXPORT QQuickToolBar : public QQuickContainer +class Q_QUICKCONTROLS_EXPORT QQuickToolBar : public QQuickFrame { Q_OBJECT diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml index 849b8e62..9fad13dc 100644 --- a/src/imports/controls/Frame.qml +++ b/src/imports/controls/Frame.qml @@ -42,16 +42,16 @@ AbstractFrame { default property alias data: content.data - implicitWidth: Math.max(background ? background.implicitWidth : 0, - contentItem.implicitWidth + leftPadding + rightPadding) - implicitHeight: Math.max(background ? background.implicitHeight : 0, - contentItem.implicitHeight + topPadding + bottomPadding) + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.children.length === 1 ? contentItem.children[0].implicitWidth : 0 + contentHeight: contentItem.children.length === 1 ? contentItem.children[0].implicitHeight : 0 padding: Theme.padding - contentItem: Column { + contentItem: Item { id: content - spacing: control.Theme.spacing } frame: Rectangle { diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml index e3068014..a0af61da 100644 --- a/src/imports/controls/GroupBox.qml +++ b/src/imports/controls/GroupBox.qml @@ -42,17 +42,17 @@ AbstractGroupBox { default property alias data: content.data - implicitWidth: Math.max(background ? background.implicitWidth : 0, - contentItem.implicitWidth + leftPadding + rightPadding) - implicitHeight: Math.max(background ? background.implicitHeight : 0, - contentItem.implicitHeight + topPadding + bottomPadding) + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.children.length === 1 ? contentItem.children[0].implicitWidth : 0 + contentHeight: contentItem.children.length === 1 ? contentItem.children[0].implicitHeight : 0 padding: Theme.padding topPadding: Theme.padding + (label && title ? label.implicitHeight + Theme.spacing : 0) - contentItem: Column { + contentItem: Item { id: content - spacing: control.Theme.spacing } label: Text { diff --git a/src/imports/controls/ToolBar.qml b/src/imports/controls/ToolBar.qml index 7677607d..e2bf8eac 100644 --- a/src/imports/controls/ToolBar.qml +++ b/src/imports/controls/ToolBar.qml @@ -42,16 +42,16 @@ AbstractToolBar { default property alias data: content.data - implicitWidth: Math.max(background ? background.implicitWidth : 0, - contentItem.implicitWidth + leftPadding + rightPadding) - implicitHeight: Math.max(background ? background.implicitHeight : 0, - contentItem.implicitHeight + topPadding + bottomPadding) + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.children.length === 1 ? contentItem.children[0].implicitWidth : 0 + contentHeight: contentItem.children.length === 1 ? contentItem.children[0].implicitHeight : 0 Accessible.role: Accessible.ToolBar - contentItem: Row { + contentItem: Item { 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 5eb600de..43e0c298 100644 --- a/tests/auto/controls/data/tst_frame.qml +++ b/tests/auto/controls/data/tst_frame.qml @@ -82,11 +82,15 @@ 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() @@ -94,8 +98,10 @@ TestCase { function test_twoChildren() { var control = twoChildrenFrame.createObject(testCase) - verify(control.implicitWidth > 200) - verify(control.implicitHeight > 60) + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) + verify(control.implicitWidth > 0) + verify(control.implicitHeight > 0) control.destroy() } } diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml index 760450f0..1a2f2efb 100644 --- a/tests/auto/controls/data/tst_groupbox.qml +++ b/tests/auto/controls/data/tst_groupbox.qml @@ -82,12 +82,16 @@ TestCase { function test_defaults() { var control = groupBox.createObject(testCase) verify(control.contentItem) + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) compare(control.title, "") 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() @@ -95,8 +99,10 @@ TestCase { function test_twoChildren() { var control = twoChildrenBox.createObject(testCase) - verify(control.implicitWidth > 200) - verify(control.implicitHeight > 60) + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) + verify(control.implicitWidth > 0) + verify(control.implicitHeight > 0) control.destroy() } } diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml index 694e6e24..6b343894 100644 --- a/tests/auto/controls/data/tst_toolbar.qml +++ b/tests/auto/controls/data/tst_toolbar.qml @@ -82,11 +82,15 @@ 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() @@ -94,8 +98,10 @@ TestCase { function test_twoChildren() { var control = twoChildrenBar.createObject(testCase) - verify(control.implicitWidth > 200) - verify(control.implicitHeight > 60) + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) + verify(control.implicitWidth > 0) + verify(control.implicitHeight > 0) control.destroy() } } |