aboutsummaryrefslogtreecommitdiffstats
path: root/src/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-05-23 10:35:56 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-05-23 09:19:47 +0000
commitbd1e79de9c0b5073ca299d65e0696ecad94f6fc5 (patch)
treef29df90f87d63cb30fd27d8cabaf33bf69e790f9 /src/controls
parentafe4433ae7af5491a19e85d69dce1caa93c33cca (diff)
Add read-only Control::contentWidth and contentHeight
This is the control width and height without padding. Change-Id: Iebee2a0d3fd6b5475fef1dad507c72efba12d903 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/qquickcontainer.cpp28
-rw-r--r--src/controls/qquickcontainer_p.h3
-rw-r--r--src/controls/qquickcontainer_p_p.h3
-rw-r--r--src/controls/qquickcontrol.cpp34
-rw-r--r--src/controls/qquickcontrol_p.h7
-rw-r--r--src/controls/qquickcontrol_p_p.h3
6 files changed, 58 insertions, 20 deletions
diff --git a/src/controls/qquickcontainer.cpp b/src/controls/qquickcontainer.cpp
index 302a588e..b78e1104 100644
--- a/src/controls/qquickcontainer.cpp
+++ b/src/controls/qquickcontainer.cpp
@@ -53,6 +53,16 @@ QQuickContainerPrivate::QQuickContainerPrivate() :
{
}
+qreal QQuickContainerPrivate::getContentWidth() const
+{
+ return contentWidth;
+}
+
+qreal QQuickContainerPrivate::getContentHeight() const
+{
+ return contentHeight;
+}
+
QQuickContainer::QQuickContainer(QQuickItem *parent) :
QQuickControl(*(new QQuickContainerPrivate), parent)
{
@@ -65,15 +75,10 @@ QQuickContainer::QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent)
/*!
\qmlproperty real QtQuickControls2::Container::contentWidth
+ \qmlproperty real QtQuickControls2::Container::contentHeight
TODO
*/
-qreal QQuickContainer::contentWidth() const
-{
- Q_D(const QQuickContainer);
- return d->contentWidth;
-}
-
void QQuickContainer::setContentWidth(qreal width)
{
Q_D(QQuickContainer);
@@ -83,17 +88,6 @@ void QQuickContainer::setContentWidth(qreal width)
}
}
-/*!
- \qmlproperty real QtQuickControls2::Container::contentHeight
-
- TODO
-*/
-qreal QQuickContainer::contentHeight() const
-{
- Q_D(const QQuickContainer);
- return d->contentHeight;
-}
-
void QQuickContainer::setContentHeight(qreal height)
{
Q_D(QQuickContainer);
diff --git a/src/controls/qquickcontainer_p.h b/src/controls/qquickcontainer_p.h
index 6e3e224a..ad29982b 100644
--- a/src/controls/qquickcontainer_p.h
+++ b/src/controls/qquickcontainer_p.h
@@ -64,10 +64,7 @@ class Q_QUICKCONTROLS_EXPORT QQuickContainer : public QQuickControl
public:
explicit QQuickContainer(QQuickItem *parent = Q_NULLPTR);
- qreal contentWidth() const;
void setContentWidth(qreal width);
-
- qreal contentHeight() const;
void setContentHeight(qreal height);
QQuickItem *contentItem() const;
diff --git a/src/controls/qquickcontainer_p_p.h b/src/controls/qquickcontainer_p_p.h
index c0b52cec..f7b605f0 100644
--- a/src/controls/qquickcontainer_p_p.h
+++ b/src/controls/qquickcontainer_p_p.h
@@ -57,6 +57,9 @@ class Q_QUICKCONTROLS_EXPORT QQuickContainerPrivate : public QQuickControlPrivat
public:
QQuickContainerPrivate();
+ qreal getContentWidth() const Q_DECL_OVERRIDE;
+ qreal getContentHeight() const Q_DECL_OVERRIDE;
+
qreal contentWidth;
qreal contentHeight;
QQuickItem *contentItem;
diff --git a/src/controls/qquickcontrol.cpp b/src/controls/qquickcontrol.cpp
index b283032d..166201d6 100644
--- a/src/controls/qquickcontrol.cpp
+++ b/src/controls/qquickcontrol.cpp
@@ -64,6 +64,18 @@ void QQuickControlPrivate::mirrorChange()
emit q->mirroredChanged();
}
+qreal QQuickControlPrivate::getContentWidth() const
+{
+ Q_Q(const QQuickControl);
+ return q->width() - q->leftPadding() - q->rightPadding();
+}
+
+qreal QQuickControlPrivate::getContentHeight() const
+{
+ Q_Q(const QQuickControl);
+ return q->height() - q->topPadding() - q->bottomPadding();
+}
+
void QQuickControlPrivate::setTopPadding(qreal value, bool reset)
{
Q_Q(QQuickControl);
@@ -123,6 +135,24 @@ QQuickControl::QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent) :
}
/*!
+ \qmlproperty real QtQuickControls2::Control::contentWidth
+ \qmlproperty real QtQuickControls2::Control::contentHeight
+
+ TODO
+*/
+qreal QQuickControl::contentWidth() const
+{
+ Q_D(const QQuickControl);
+ return d->getContentWidth();
+}
+
+qreal QQuickControl::contentHeight() const
+{
+ Q_D(const QQuickControl);
+ return d->getContentHeight();
+}
+
+/*!
\qmlproperty real QtQuickControls2::Control::padding
\qmlproperty real QtQuickControls2::Control::topPadding
\qmlproperty real QtQuickControls2::Control::leftPadding
@@ -326,6 +356,8 @@ void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &old
p->heightValid = false;
}
}
+ emit contentWidthChanged();
+ emit contentHeightChanged();
}
void QQuickControl::mirrorChange()
@@ -334,6 +366,8 @@ void QQuickControl::mirrorChange()
void QQuickControl::paddingChange()
{
+ emit contentWidthChanged();
+ emit contentHeightChanged();
}
QT_END_NAMESPACE
diff --git a/src/controls/qquickcontrol_p.h b/src/controls/qquickcontrol_p.h
index f97cdbe4..737a917f 100644
--- a/src/controls/qquickcontrol_p.h
+++ b/src/controls/qquickcontrol_p.h
@@ -58,6 +58,8 @@ class QQuickControlPrivate;
class Q_QUICKCONTROLS_EXPORT QQuickControl : public QQuickItem
{
Q_OBJECT
+ Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentWidthChanged)
+ Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentHeightChanged)
Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged FINAL)
Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged FINAL)
Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL)
@@ -71,6 +73,9 @@ class Q_QUICKCONTROLS_EXPORT QQuickControl : public QQuickItem
public:
explicit QQuickControl(QQuickItem *parent = Q_NULLPTR);
+ qreal contentWidth() const;
+ qreal contentHeight() const;
+
qreal padding() const;
void setPadding(qreal padding);
void resetPadding();
@@ -101,6 +106,8 @@ public:
void setBackground(QQuickItem *background);
Q_SIGNALS:
+ void contentWidthChanged();
+ void contentHeightChanged();
void paddingChanged();
void topPaddingChanged();
void leftPaddingChanged();
diff --git a/src/controls/qquickcontrol_p_p.h b/src/controls/qquickcontrol_p_p.h
index 63d84b4b..353f38f2 100644
--- a/src/controls/qquickcontrol_p_p.h
+++ b/src/controls/qquickcontrol_p_p.h
@@ -61,6 +61,9 @@ public:
void mirrorChange() Q_DECL_OVERRIDE;
+ virtual qreal getContentWidth() const;
+ virtual qreal getContentHeight() const;
+
void setTopPadding(qreal value, bool reset = false);
void setLeftPadding(qreal value, bool reset = false);
void setRightPadding(qreal value, bool reset = false);