From c803830c02fb573582cd848185460ba65b4529e5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jun 2015 14:35:54 +0200 Subject: Frame, GroupBox, ToolBar: restore contentWidth & contentHeight Change-Id: I79a974c64f6ec57ebfa83cea0857b2a1590af61f Reviewed-by: J-P Nurmi --- src/controls/qquickframe.cpp | 42 ++++++++++++++++++++++++++++++++++++++- src/controls/qquickframe_p.h | 10 ++++++++++ src/controls/qquickframe_p_p.h | 2 ++ src/controls/qquicktoolbar.cpp | 4 ++-- src/controls/qquicktoolbar_p.h | 4 ++-- src/imports/controls/Frame.qml | 12 +++++------ src/imports/controls/GroupBox.qml | 12 +++++------ src/imports/controls/ToolBar.qml | 12 +++++------ 8 files changed, 75 insertions(+), 23 deletions(-) (limited to 'src') 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) { } @@ -64,6 +64,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 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 +#include 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 { -- cgit v1.2.3