diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-08-22 08:59:15 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2014-08-26 06:10:07 +0200 |
commit | 3035fd9ad9f1212c0eccd6a81a727727b2b38472 (patch) | |
tree | 37144e65717ee4b9d16f7af0f05070af2c4cbae2 /src | |
parent | d28a3b7b195da3ef7c4c23ddb0add94aff72a368 (diff) |
Clamp QQuickItem::opacity to [0,1].
This was an oversight the the implementation of
setOpacity. QSGOpacityNode already does the right thing.
[ChangeLog][QtQuick][Item] When Item.opacity is set to a value outside
the range of 0 to 1, it will be clamped.
Change-Id: Ib7f23c5d8860c76e009a25e5ab2c36db20301faf
Reviewed-by: Raine Mäkeläinen <raine.makelainen@gmail.com>
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index a6c83fbd34..b6939ddaba 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -5177,6 +5177,8 @@ void QQuickItem::setScale(qreal s) rectangle has specified an opacity of 0.5, which affects the opacity of its blue child rectangle even though the child has not specified an opacity. + Values outside the range of 0 to 1 will be clamped. + \table \row \li \image declarative-item_opacity1.png @@ -5224,9 +5226,10 @@ qreal QQuickItem::opacity() const return d->opacity(); } -void QQuickItem::setOpacity(qreal o) +void QQuickItem::setOpacity(qreal newOpacity) { Q_D(QQuickItem); + qreal o = qBound<qreal>(0, newOpacity, 1); if (d->opacity() == o) return; |