diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-10-26 18:03:35 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-27 08:46:23 +0000 |
commit | c9e01c96e0010fc30a2ddc913b22d21a9495e01d (patch) | |
tree | b3ab64d38822b94dbca13cb9d90ee276e5f629ea /src/templates/qquickcontrol.cpp | |
parent | cc707a981e2ece079bf94c9817e2d42760cae60b (diff) |
Control: fix available size
First of all, don't allow negative available size, because it doesn't
make much sense. Secondly, geometryChanged() was comparing new width
to old height, so availableHeightChanged() was emitted under wrong
conditions. Furthermore, the comparisons should are better done fuzzy
to avoid unnecessary change notifiers.
Change-Id: Ic2bbc106670882b421f79db82d4b47d846e1c4e0
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates/qquickcontrol.cpp')
-rw-r--r-- | src/templates/qquickcontrol.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/templates/qquickcontrol.cpp b/src/templates/qquickcontrol.cpp index 1a90c8fe..966e63a3 100644 --- a/src/templates/qquickcontrol.cpp +++ b/src/templates/qquickcontrol.cpp @@ -395,7 +395,7 @@ void QQuickControl::resetFont() */ qreal QQuickControl::availableWidth() const { - return width() - leftPadding() - rightPadding(); + return qMax(0.0, width() - leftPadding() - rightPadding()); } /*! @@ -407,7 +407,7 @@ qreal QQuickControl::availableWidth() const */ qreal QQuickControl::availableHeight() const { - return height() - topPadding() - bottomPadding(); + return qMax(0.0, height() - topPadding() - bottomPadding()); } /*! @@ -731,9 +731,9 @@ void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &old QQuickItem::geometryChanged(newGeometry, oldGeometry); d->resizeBackground(); d->resizeContent(); - if (newGeometry.width() != oldGeometry.width()) + if (!qFuzzyCompare(newGeometry.width(), oldGeometry.width())) emit availableWidthChanged(); - if (newGeometry.width() != oldGeometry.height()) + if (!qFuzzyCompare(newGeometry.height(), oldGeometry.height())) emit availableHeightChanged(); } |