From 9f0884773a451a4feef80812e015266bd487dcdc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 12 Apr 2010 20:55:03 +0200 Subject: Revert Merge Request 551. This introduces regressions to Qt. The regressions noticed were: Mac OS X: qmenu::menuGeometry line 1024 (new test) QWS and Win32: qmenubar::check_menuPosition line 1508 This reverts commits 6947390 and c1ce854. --- src/gui/widgets/qmenu.cpp | 7 +++--- tests/auto/qmenu/tst_qmenu.cpp | 56 ------------------------------------------ 2 files changed, 4 insertions(+), 59 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index b752ae2..3ea783f 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1913,9 +1913,10 @@ void QMenu::popup(const QPoint &p, QAction *atAction) pos.setX(screen.left() + desktopFrame); } if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) { - const int bestPos = (snapToMouse ? mouse.y() : p.y()) - desktopFrame - size.height() + 1; - const int fallbackPos = screen.bottom() - desktopFrame - size.height() + 1; - pos.setY(qMin(bestPos, fallbackPos)); + if(snapToMouse) + pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1)); + else + pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1)); } else if (pos.y() < screen.top() + desktopFrame) { pos.setY(screen.top() + desktopFrame); } diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 4be6fdd..e10d7ee 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -106,8 +106,6 @@ private slots: void pushButtonPopulateOnAboutToShow(); void QTBUG7907_submenus_autoselect(); void QTBUG7411_submenus_activate(); - void menuGeometry_data(); - void menuGeometry(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -969,60 +967,6 @@ void tst_QMenu::QTBUG7411_submenus_activate() QTRY_VERIFY(sub1.isVisible()); } -void tst_QMenu::menuGeometry_data() -{ - QTest::addColumn("screen"); - QTest::addColumn("pos"); - QTest::addColumn("expectedPos"); - - QMenu menu("Test Menu"); - for (int i = 0; i < 3; ++i) - menu.addAction("Hello World!"); - - menu.adjustSize(); - - const int screenCount = QApplication::desktop()->screenCount(); - const int desktopFrame = menu.style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, &menu); - - for (int i = 0; i < screenCount; ++i) { - const QRect screen = QApplication::desktop()->screenGeometry(i); - - if (screen.width() < menu.width() || screen.height() < menu.height()) - continue; - - QTest::newRow("topLeft") << screen << screen.topLeft() - << QPoint(screen.left() + desktopFrame, screen.top() + desktopFrame); - - QTest::newRow("topRight") << screen << screen.topRight() - << QPoint(screen.right() - desktopFrame - menu.width() + 1, screen.top() + desktopFrame); - - QTest::newRow("bottomLeft") << screen << screen.bottomLeft() - << QPoint(screen.left() + desktopFrame, screen.bottom() - desktopFrame - menu.height() + 1); - - QTest::newRow("bottomRight") << screen << screen.bottomRight() - << QPoint(screen.right() - desktopFrame - menu.width() + 1, screen.bottom() - desktopFrame - menu.height() + 1); - - const QPoint pos = QPoint(screen.right() - qMax(desktopFrame, 20), screen.bottom() - qMax(desktopFrame, 20)); - QTest::newRow("position") << screen << pos - << QPoint(screen.right() - menu.width() + 1, pos.y() - menu.height() + 1); - } -} - -void tst_QMenu::menuGeometry() -{ - QFETCH(QRect, screen); - QFETCH(QPoint, pos); - QFETCH(QPoint, expectedPos); - - QMenu menu("Test Menu"); - for (int i = 0; i < 3; ++i) - menu.addAction("Hello World!"); - - menu.popup(pos); - QTest::qWaitForWindowShown(&menu); - QVERIFY(screen.contains(menu.geometry())); - QCOMPARE(menu.pos(), expectedPos); -} QTEST_MAIN(tst_QMenu) -- cgit v0.12