Skip to content

Commit

Permalink
Fixes: NB#284160 - Incorrectly detected taps on status area when stat…
Browse files Browse the repository at this point in the history
…us menu is open

Bug: NB#284160 - Incorrectly detected taps on status area when status menu is open
RevBy: TrustMe
  • Loading branch information
Vesa Halttunen committed Sep 30, 2011
1 parent 5c0a2fe commit fd6f374
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
system-ui (1.2.3~1) unstable; urgency=low

* [UNRELEASED]
* Fixes: NB#284160 - Incorrectly detected taps on status area when status menu is open

-- Vesa Halttunen <[email protected]> Fri, 23 Sep 2011 12:38:43 +0300

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,19 @@ bool StatusIndicatorMenuWindow::event(QEvent *event)
return windowIsHandlingEvent;
}

void StatusIndicatorMenuWindow::mousePressEvent(QMouseEvent * event)
void StatusIndicatorMenuWindow::mousePressEvent(QMouseEvent *event)
{
mousePressPosition = event->pos();
MWindow::mousePressEvent(event);
}

void StatusIndicatorMenuWindow::mouseReleaseEvent(QMouseEvent * event)
void StatusIndicatorMenuWindow::mouseReleaseEvent(QMouseEvent *event)
{
if (itemAt(mousePressPosition) == statusBar && menuWidget) {
if (itemAt(mousePressPosition) == statusBar && itemAt(event->pos()) == statusBar && menuWidget) {
// If the mouse was pressed AND released on top of the status bar, hide the status indicator menu
menuWidget->disappear();
}

// pass mouse release to status bar as well, else it will remain in pressed state if press happened on it
MWindow::mouseReleaseEvent(event);
}
50 changes: 32 additions & 18 deletions tests/ut_statusindicatormenuwindow/ut_statusindicatormenuwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,36 +235,50 @@ void Ut_StatusIndicatorMenuWindow::testStatusIndicatorMenuAppearsAfterEnteringDi
QCOMPARE(statusIndicatorMenuWindow->menuWidget->sceneWindowState(), MSceneWindow::Appeared);
}

void Ut_StatusIndicatorMenuWindow::testStatusIndicatorMenuIsClosedWhenStatusBarIsTapped_data()
{
QTest::addColumn<bool>("pressInside");
QTest::addColumn<bool>("releaseInside");
QTest::addColumn<MSceneWindow::SceneWindowState>("sceneWindowState");

QTest::newRow("Press outside, release outside") << false << false << MSceneWindow::Appeared;
QTest::newRow("Press outside, release inside") << false << true << MSceneWindow::Appeared;
QTest::newRow("Press inside, release outside") << true << false << MSceneWindow::Appeared;
QTest::newRow("Press inside, release inside") << true << true << MSceneWindow::Disappeared;
}

void Ut_StatusIndicatorMenuWindow::testStatusIndicatorMenuIsClosedWhenStatusBarIsTapped()
{
QFETCH(bool, pressInside);
QFETCH(bool, releaseInside);
QFETCH(MSceneWindow::SceneWindowState, sceneWindowState);

statusIndicatorMenuWindow->displayActive();

// Map the bounding rect to the scene
QRectF statusBarGeo(statusIndicatorMenuWindow->statusBar->sceneBoundingRect());
QRectF statusBarGeometry(statusIndicatorMenuWindow->statusBar->sceneBoundingRect());
QPoint pressPoint(statusBarGeometry.x(), statusBarGeometry.y());
QPoint releasePoint(statusBarGeometry.x(), statusBarGeometry.y());

QPoint inside(statusBarGeo.x()+statusBarGeo.width()/2,
statusBarGeo.y()+statusBarGeo.height()/2);
if (!pressInside) {
pressPoint += QPoint(-1, -1);
}

// Then map a point inside it to the viewport
inside = statusIndicatorMenuWindow->mapFromScene(inside);
if (!releaseInside) {
releasePoint += QPoint(-1, -1);
}

QMouseEvent pressInside(QEvent::MouseButtonPress,
inside,
Qt::LeftButton,
Qt::MouseButtons(Qt::LeftButton),
Qt::KeyboardModifiers(Qt::NoModifier));
// Then map the press point to the viewport
pressPoint = statusIndicatorMenuWindow->mapFromScene(pressPoint);
releasePoint = statusIndicatorMenuWindow->mapFromScene(releasePoint);

QMouseEvent releaseInside(QEvent::MouseButtonRelease,
inside,
Qt::LeftButton,
Qt::MouseButtons(Qt::LeftButton),
Qt::KeyboardModifiers(Qt::NoModifier));
QMouseEvent pressEvent(QEvent::MouseButtonPress, pressPoint, Qt::LeftButton, Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers(Qt::NoModifier));
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, releasePoint, Qt::LeftButton, Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers(Qt::NoModifier));

statusIndicatorMenuWindow->mousePressEvent(&pressInside);
statusIndicatorMenuWindow->mouseReleaseEvent(&releaseInside);
statusIndicatorMenuWindow->mousePressEvent(&pressEvent);
statusIndicatorMenuWindow->mouseReleaseEvent(&releaseEvent);

QCOMPARE(statusIndicatorMenuWindow->menuWidget->sceneWindowState(), MSceneWindow::Disappeared);
QCOMPARE(statusIndicatorMenuWindow->menuWidget->sceneWindowState(), sceneWindowState);
}

void Ut_StatusIndicatorMenuWindow::testWhenStatusIndicatorMenuIsDisappearedThenWindowIsHidden()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private slots:
void testWhenLanguageChangesThenMenuWidgetIsResetted();
void testWhenLanguageChangeEventWithoutLanguageChangingThenMenuWidgetIsNotResetted();
void testStatusIndicatorMenuAppearsAfterEnteringDisplay();
void testStatusIndicatorMenuIsClosedWhenStatusBarIsTapped_data();
void testStatusIndicatorMenuIsClosedWhenStatusBarIsTapped();
void testWhenWindowAlreadyOnDisplayThenMenuWidgetAppearsWithoutDisplayEnterSignal();
void testWhenStatusIndicatorMenuIsDisappearedThenWindowIsHidden();
Expand Down

0 comments on commit fd6f374

Please sign in to comment.