diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/controls.pro | 2 | ||||
-rw-r--r-- | src/controls/qquickmenupopupwindow.cpp | 7 | ||||
-rw-r--r-- | src/controls/qquickpopupwindow.cpp | 24 |
3 files changed, 27 insertions, 6 deletions
diff --git a/src/controls/controls.pro b/src/controls/controls.pro index e7cd6ada..fd4aac0d 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -2,7 +2,7 @@ TARGET = qtquickcontrolsplugin TARGETPATH = QtQuick/Controls IMPORT_VERSION = 1.2 -QT += qml quick gui-private core-private +QT += qml quick quick-private gui-private core-private QMAKE_DOCS = $$PWD/doc/qtquickcontrols.qdocconf diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp index ec33b0c1..6a2a03bc 100644 --- a/src/controls/qquickmenupopupwindow.cpp +++ b/src/controls/qquickmenupopupwindow.cpp @@ -45,6 +45,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qquickitem.h> #include <QtGui/QScreen> +#include <QtQuick/private/qquickrendercontrol_p.h> QT_BEGIN_NAMESPACE @@ -84,8 +85,10 @@ void QQuickMenuPopupWindow::setItemAt(QQuickItem *menuItem) void QQuickMenuPopupWindow::setParentWindow(QQuickWindow *parentWindow) { - if (transientParent() != parentWindow) - setTransientParent(parentWindow); + QWindow *proxyWindow = QQuickRenderControl::renderWindowFor(parentWindow); + QWindow *renderWindow = proxyWindow ? proxyWindow : parentWindow; + if (transientParent() != renderWindow) + setTransientParent(renderWindow); if (parentWindow) { connect(parentWindow, SIGNAL(destroyed()), this, SLOT(dismissPopup())); if (QQuickMenuPopupWindow *pw = qobject_cast<QQuickMenuPopupWindow *>(parentWindow)) diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp index 27f4b34a..9a795d06 100644 --- a/src/controls/qquickpopupwindow.cpp +++ b/src/controls/qquickpopupwindow.cpp @@ -44,6 +44,7 @@ #include <qguiapplication.h> #include <qpa/qwindowsysteminterface.h> #include <QtQuick/qquickitem.h> +#include <QtQuick/private/qquickrendercontrol_p.h> QT_BEGIN_NAMESPACE @@ -85,6 +86,19 @@ void QQuickPopupWindow::show() posx += parentWindow->geometry().left(); posy += parentWindow->geometry().top(); } + } else if (m_parentItem && m_parentItem->window()) { + QPoint offset; + QQuickWindow *quickWindow = m_parentItem->window(); + QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, &offset); + + QPointF pos = m_parentItem->mapToItem(quickWindow->contentItem(), QPointF(posx, posy)); + posx = pos.x(); + posy = pos.y(); + if (renderWindow) { + QPoint parentWindowOffset = renderWindow->mapToGlobal(QPoint()); + posx += offset.x() + parentWindowOffset.x(); + posy += offset.y() + parentWindowOffset.y(); + } } if (m_contentItem) { @@ -96,11 +110,15 @@ void QQuickPopupWindow::show() } emit geometryChanged(); - if (!qobject_cast<QQuickPopupWindow *>(transientParent())) // No need for parent menu windows - if (QQuickWindow *w = qobject_cast<QQuickWindow *>(transientParent())) + if (!qobject_cast<QQuickPopupWindow *>(transientParent())) { // No need for parent menu windows + if (QQuickWindow *w = qobject_cast<QQuickWindow *>(transientParent())) { if (QQuickItem *mg = w->mouseGrabberItem()) mg->ungrabMouse(); - + } else if (m_parentItem && m_parentItem->window()) { + if (QQuickItem *mg = m_parentItem->window()->mouseGrabberItem()) + mg->ungrabMouse(); + } + } QQuickWindow::show(); setMouseGrabEnabled(true); // Needs to be done after calling show() setKeyboardGrabEnabled(true); |