diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-24 16:36:23 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-25 07:21:29 +0000 |
commit | cb80c055e7d8a242c529c9f72c9a9b8d87a90f31 (patch) | |
tree | 39ad3246eda83e0c505bcb8b807c92ee9e3130bb /src/quicktemplates2/qquickpage.cpp | |
parent | 32810acaa191ba00be5aac5d771c23b87628292c (diff) |
Page: provide implicit size
Even though the control was designed to be used as full-screen page, it
can be sometimes useful to have non-fullscreen pages. In order to make
Page behave well in layouts, it must provide a suitable implicit size.
[ChangeLog][Controls][Page] Page has been made to calculate its
implicit size based on the implicit size of the header, content, and
footer plus paddings, and the implicit size of the background item.
Task-number: QTBUG-56709
Change-Id: I0f40897df6e54d7bde01a464e24f0398b12bc865
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpage.cpp')
-rw-r--r-- | src/quicktemplates2/qquickpage.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index 88eb03bf..0098cb93 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -87,12 +87,22 @@ class QQuickPagePrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickPage) public: + QQuickPagePrivate(); + QQuickItem *getContentItem() override; + qreal contentWidth; + qreal contentHeight; QString title; QScopedPointer<QQuickPageLayout> layout; }; +QQuickPagePrivate::QQuickPagePrivate() + : contentWidth(0), + contentHeight(0) +{ +} + QQuickItem *QQuickPagePrivate::getContentItem() { Q_Q(QQuickPage); @@ -219,6 +229,56 @@ void QQuickPage::setFooter(QQuickItem *footer) } /*! + \qmlproperty real QtQuick.Controls::Page::contentWidth + \since QtQuick.Controls 2.1 + + This property holds the content width. It is used for calculating the total + implicit width of the page. + + \sa contentHeight +*/ +qreal QQuickPage::contentWidth() const +{ + Q_D(const QQuickPage); + return d->contentWidth; +} + +void QQuickPage::setContentWidth(qreal width) +{ + Q_D(QQuickPage); + if (qFuzzyCompare(d->contentWidth, width)) + return; + + d->contentWidth = width; + emit contentWidthChanged(); +} + +/*! + \qmlproperty real QtQuick.Controls::Page::contentHeight + \since QtQuick.Controls 2.1 + + This property holds the content height. It is used for calculating the total + implicit height of the page. + + \sa contentWidth +*/ +qreal QQuickPage::contentHeight() const +{ + Q_D(const QQuickPage); + return d->contentHeight; +} + +void QQuickPage::setContentHeight(qreal height) +{ + Q_D(QQuickPage); + if (qFuzzyCompare(d->contentHeight, height)) + return; + + d->contentHeight = height; + emit contentHeightChanged(); +} + +/*! \qmlproperty list<Object> QtQuick.Controls::Page::contentData \default |