From 21cf7b4c4317421da4b7ba63473b639e33386ffc Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 9 Sep 2009 13:57:16 +0200 Subject: QMenubar could popup a menu when undocking a toolbar This is due to the fact that it receives a mousemoveevent. But as it doesn't receive a mousepress event, we can detect whether it should popup or not. Task-number: 260873 Reviewed-by: prasanth --- src/gui/widgets/qmenubar.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 720bd62..d5a7982 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1094,6 +1094,8 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) if(e->button() != Qt::LeftButton) return; + d->mouseDown = true; + QAction *action = d->actionAt(e->pos()); if (!action || !d->isVisible(action)) { d->setCurrentAction(0); @@ -1104,8 +1106,6 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) return; } - d->mouseDown = true; - if(d->currentAction == action && d->popupState) { if(QMenu *menu = d->activeMenu) { d->activeMenu = 0; @@ -1252,10 +1252,11 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) void QMenuBar::mouseMoveEvent(QMouseEvent *e) { Q_D(QMenuBar); - d->mouseDown = e->buttons() & Qt::LeftButton; + bool popupState = d->popupState || e->buttons() & Qt::LeftButton; + if (!d->mouseDown || !popupState) + return; QAction *action = d->actionAt(e->pos()); - bool popupState = d->popupState || d->mouseDown; - if ((action && d->isVisible(action)) || !popupState) + if (action && d->isVisible(action)) d->setCurrentAction(action, popupState); } -- cgit v0.12