aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/qquickpopup_p_p.h
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-01-22 15:20:04 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-01-23 13:37:12 +0000
commit3bbd90c753fba9cc43c34ca9c509bcc35858b566 (patch)
tree2701ecf16fdad2c6131795ede0842f03432a53a0 /src/templates/qquickpopup_p_p.h
parent4d26036772f897c293d8f71d728ed41c720a85e8 (diff)
Add Popup::parent
The parent defaults to the QML parent object where Popup is declared. Popup::x/y are relative to the parent, and the popup also automatically follows the parent as appropriate. QQuickPopupPositioner has been adapted from Qt Quick Controls 1. It was called QQuickScenePosListener, and it was implemented for the text selection handle popups. ComboBox's popup now follows the control eg. when scrolling, but the below/above positioning feature is temporarily gone missing. It will be restored in a follow up commit. Change-Id: I8a6b58cd74e07f33930abc35d0ab9da056685128 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/templates/qquickpopup_p_p.h')
-rw-r--r--src/templates/qquickpopup_p_p.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/templates/qquickpopup_p_p.h b/src/templates/qquickpopup_p_p.h
index 70274ff6..e3e9470e 100644
--- a/src/templates/qquickpopup_p_p.h
+++ b/src/templates/qquickpopup_p_p.h
@@ -52,6 +52,7 @@
#include <QtCore/private/qobject_p.h>
#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquickitemchangelistener_p.h>
#include <QtQuick/private/qquicktransitionmanager_p_p.h>
QT_BEGIN_NAMESPACE
@@ -107,6 +108,41 @@ private:
QQuickPopup *popup;
};
+class QQuickPopupPositioner : public QQuickItemChangeListener
+{
+public:
+ explicit QQuickPopupPositioner(QQuickPopupPrivate *popup);
+ ~QQuickPopupPositioner();
+
+ qreal x() const;
+ void setX(qreal x);
+
+ qreal y() const;
+ void setY(qreal y);
+
+ QQuickItem *parentItem() const;
+ void setParentItem(QQuickItem *parent);
+
+protected:
+ void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &);
+ void itemParentChanged(QQuickItem *, QQuickItem *parent);
+ void itemChildRemoved(QQuickItem *, QQuickItem *child);
+ void itemDestroyed(QQuickItem *item);
+
+private:
+ void repositionPopup();
+
+ void removeAncestorListeners(QQuickItem *item);
+ void addAncestorListeners(QQuickItem *item);
+
+ bool isAncestor(QQuickItem *item) const;
+
+ qreal m_x;
+ qreal m_y;
+ QQuickItem *m_parentItem;
+ QQuickPopupPrivate *m_popup;
+};
+
class QQuickPopupPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QQuickPopup)
@@ -144,12 +180,14 @@ public:
qreal leftPadding;
qreal rightPadding;
qreal bottomPadding;
+ QQuickItem *parentItem;
QQuickItem *background;
QQuickItem *contentItem;
QQuickOverlay *overlay;
QQuickTransition *enter;
QQuickTransition *exit;
QQuickPopupItem *popupItem;
+ QQuickPopupPositioner positioner;
QQuickPopupTransitionManager transitionManager;
};