summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-03-04 19:12:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-07 17:39:27 +0100
commit88bb2aa7030d2958056f4e6b588e796e1f4538b1 (patch)
treeca24fd0da6d2573d9eb147a3804a31d422fbd4d0 /src
parent50899263b50ec8a8bff9ed0fbbf69b6c1d8aa9f7 (diff)
Popup Window: Privately expose popup geometry
Change-Id: I28a8edd657f02cecbd0c31965bd4085429cf4537 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/qquickmenu.cpp9
-rw-r--r--src/controls/qquickmenu_p.h4
-rw-r--r--src/controls/qquickmenupopupwindow.cpp1
-rw-r--r--src/controls/qquickpopupwindow.cpp2
-rw-r--r--src/controls/qquickpopupwindow_p.h1
5 files changed, 17 insertions, 0 deletions
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index 7aa52d56a..bb4c79b64 100644
--- a/src/controls/qquickmenu.cpp
+++ b/src/controls/qquickmenu.cpp
@@ -398,6 +398,7 @@ void QQuickMenu::__popup(qreal x, qreal y, int atItemIndex)
m_popupWindow->setItemAt(atItem ? atItem->visualItem() : 0);
connect(m_popupWindow, SIGNAL(visibleChanged(bool)), this, SLOT(windowVisibleChanged(bool)));
+ connect(m_popupWindow, SIGNAL(geometryChanged()), this, SIGNAL(__popupGeometryChanged()));
m_popupWindow->setPosition(x + m_xOffset, y + m_yOffset);
m_popupWindow->show();
@@ -420,6 +421,14 @@ void QQuickMenu::setPopupVisible(bool v)
}
}
+QRect QQuickMenu::popupGeometry() const
+{
+ if (!m_popupWindow || !m_popupVisible)
+ return QRect();
+
+ return m_popupWindow->geometry();
+}
+
void QQuickMenu::__closeMenu()
{
setPopupVisible(false);
diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h
index c6bf24e29..85cc0107f 100644
--- a/src/controls/qquickmenu_p.h
+++ b/src/controls/qquickmenu_p.h
@@ -74,6 +74,7 @@ class QQuickMenu : public QQuickMenuText
Q_PROPERTY(qreal __xOffset READ xOffset WRITE setXOffset)
Q_PROPERTY(qreal __yOffset READ yOffset WRITE setYOffset)
Q_PROPERTY(QQuickAction *__action READ action CONSTANT)
+ Q_PROPERTY(QRect __popupGeometry READ popupGeometry NOTIFY __popupGeometryChanged)
public:
Q_INVOKABLE void popup();
@@ -99,6 +100,7 @@ Q_SIGNALS:
void __selectedIndexChanged();
void __menuClosed();
void popupVisibleChanged();
+ void __popupGeometryChanged();
void menuContentItemChanged();
void minimumWidthChanged();
@@ -134,6 +136,8 @@ public:
bool isNative() { return m_platformMenu != 0; }
+ QRect popupGeometry() const;
+
protected Q_SLOTS:
void updateSelectedIndex();
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index 1c2ea15c2..ec33b0c14 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -117,6 +117,7 @@ void QQuickMenuPopupWindow::setGeometry(int posx, int posy, int w, int h)
posy = qBound(g.top(), posy, g.bottom() - h);
QQuickWindow::setGeometry(posx, posy, w, h);
+ emit geometryChanged();
}
void QQuickMenuPopupWindow::updateSize()
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index 02c50a85a..efc378b6d 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -86,6 +86,7 @@ void QQuickPopupWindow::show()
} else {
setPosition(posx, posy);
}
+ emit geometryChanged();
if (!qobject_cast<QQuickPopupWindow *>(transientParent())) // No need for parent menu windows
if (QQuickWindow *w = qobject_cast<QQuickWindow *>(transientParent()))
@@ -119,6 +120,7 @@ void QQuickPopupWindow::updateSize()
{
QSize contentSize = popupContentItem()->childrenRect().size().toSize();
setGeometry(x(), y(), contentSize.width(), contentSize.height());
+ emit geometryChanged();
}
void QQuickPopupWindow::dismissPopup()
diff --git a/src/controls/qquickpopupwindow_p.h b/src/controls/qquickpopupwindow_p.h
index 65ce01a06..1329a5479 100644
--- a/src/controls/qquickpopupwindow_p.h
+++ b/src/controls/qquickpopupwindow_p.h
@@ -70,6 +70,7 @@ public Q_SLOTS:
Q_SIGNALS:
void popupDismissed();
+ void geometryChanged();
protected:
void mousePressEvent(QMouseEvent *);