summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFilippo Cucchetto <filippocucchetto@gmail.com>2015-11-24 22:35:51 +0100
committerFilippo Cucchetto <filippocucchetto@gmail.com>2015-11-26 23:03:20 +0000
commit812f5779855d94cbe779f77003cc14935e02ef63 (patch)
tree931a601a7deb5125ef3d2ee8be286f6248f4f05f /src
parent2407d7ede10547025af05d875f33f4580cdbb565 (diff)
downloadqtquickcontrols-812f5779855d94cbe779f77003cc14935e02ef63.tar.gz
Menubar popups should handle only release events of a previous press event
When a popup is brought up by a press event for a menu inside the menubar it should not handle the relative next release event if it falls outside the popup. Before forwarding the release event we first check if a previous press event was seen, if not we simply discard the event. Task-number: QTBUG-47295 Task-number: QTBUG-45117 Change-Id: I632fab0a3abfdfc9872f85f99f9d7f50d41526cc Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/qquickpopupwindow.cpp15
-rw-r--r--src/controls/qquickpopupwindow_p.h1
2 files changed, 12 insertions, 4 deletions
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index 59cfe22b..cfab5bd5 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
QQuickPopupWindow::QQuickPopupWindow() :
QQuickWindow(), m_parentItem(0), m_contentItem(0),
m_mouseMoved(false), m_needsActivatedEvent(true),
- m_dismissed(false)
+ m_dismissed(false), m_pressed(false)
{
setFlags(Qt::Popup);
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
@@ -146,17 +146,22 @@ void QQuickPopupWindow::mouseMoveEvent(QMouseEvent *e)
{
QRect rect = QRect(QPoint(), size());
m_mouseMoved = true;
- if (rect.contains(e->pos()))
+ if (rect.contains(e->pos())) {
+ if (e->buttons() != Qt::NoButton)
+ m_pressed = true;
QQuickWindow::mouseMoveEvent(e);
+ }
else
forwardEventToTransientParent(e);
}
void QQuickPopupWindow::mousePressEvent(QMouseEvent *e)
{
+ m_pressed = true;
QRect rect = QRect(QPoint(), size());
- if (rect.contains(e->pos()))
+ if (rect.contains(e->pos())) {
QQuickWindow::mousePressEvent(e);
+ }
else
forwardEventToTransientParent(e);
}
@@ -173,8 +178,10 @@ void QQuickPopupWindow::mouseReleaseEvent(QMouseEvent *e)
}
m_mouseMoved = true; // Initial mouse release counts as move.
} else {
- forwardEventToTransientParent(e);
+ if (m_pressed)
+ forwardEventToTransientParent(e);
}
+ m_pressed = false;
}
void QQuickPopupWindow::forwardEventToTransientParent(QMouseEvent *e)
diff --git a/src/controls/qquickpopupwindow_p.h b/src/controls/qquickpopupwindow_p.h
index 617df53d..830ba382 100644
--- a/src/controls/qquickpopupwindow_p.h
+++ b/src/controls/qquickpopupwindow_p.h
@@ -88,6 +88,7 @@ private:
bool m_mouseMoved;
bool m_needsActivatedEvent;
bool m_dismissed;
+ bool m_pressed;
};
QT_END_NAMESPACE