aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickpopup.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-05-09 12:06:42 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-05-09 12:16:46 +0000
commitf6aed94ff0e134fe6bd2309aa5d23fa1c6250305 (patch)
tree2b1c1c5d3c5a94fe63fe9218adf001305e47953d /src/quicktemplates2/qquickpopup.cpp
parenta57c31e5ed5a4b4649084aa528ed75f25d0881e1 (diff)
Popup: make x() and y() return the effective coordinates
And trigger change signals appropriately. This makes it possible for the iOS style to know where the ComboBox popup is actually positioned so it can visualize the popup curve appropriately. Change-Id: I6cec6cbf220736c658357aee10f6d31e08531ba2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpopup.cpp')
-rw-r--r--src/quicktemplates2/qquickpopup.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 47e85e73..f614c0af 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -773,7 +773,10 @@ void QQuickPopup::close()
qreal QQuickPopup::x() const
{
Q_D(const QQuickPopup);
- return d->x;
+ qreal x = d->popupItem->x();
+ if (d->parentItem)
+ x = d->parentItem->mapFromScene(QPointF(x, 0)).x();
+ return x;
}
void QQuickPopup::setX(qreal x)
@@ -785,7 +788,8 @@ void QQuickPopup::setX(qreal x)
d->x = x;
if (d->popupItem->isVisible())
d->reposition();
- emit xChanged();
+ else
+ emit xChanged();
}
/*!
@@ -796,7 +800,10 @@ void QQuickPopup::setX(qreal x)
qreal QQuickPopup::y() const
{
Q_D(const QQuickPopup);
- return d->y;
+ qreal y = d->popupItem->y();
+ if (d->parentItem)
+ y = d->parentItem->mapFromScene(QPointF(0, y)).y();
+ return y;
}
void QQuickPopup::setY(qreal y)
@@ -808,7 +815,8 @@ void QQuickPopup::setY(qreal y)
d->y = y;
if (d->popupItem->isVisible())
d->reposition();
- emit yChanged();
+ else
+ emit yChanged();
}
QPointF QQuickPopup::position() const
@@ -1889,6 +1897,10 @@ void QQuickPopup::geometryChanged(const QRectF &newGeometry, const QRectF &oldGe
{
Q_D(QQuickPopup);
d->reposition();
+ if (!qFuzzyCompare(newGeometry.x(), oldGeometry.x()))
+ emit xChanged();
+ if (!qFuzzyCompare(newGeometry.y(), oldGeometry.y()))
+ emit yChanged();
if (!qFuzzyCompare(newGeometry.width(), oldGeometry.width())) {
emit widthChanged();
emit availableWidthChanged();