Fix tst_qmenu.
authorDebao Zhang <dbzhang800@gmail.com>
Fri, 24 Feb 2012 21:46:33 +0000 (13:46 -0800)
committerQt by Nokia <qt-info@nokia.com>
Mon, 27 Feb 2012 19:52:45 +0000 (20:52 +0100)
Clear away Q_WS_WIN/Q_WS_X11 from QMenu. Using the hint returned by the
QPlatformTheme.

Task-number: QTBUG-24325
Change-Id: Iaa4da26c74273d7cfc1fbec6519c52d09e10f7bb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/widgets/widgets/qmenu.cpp
tests/auto/widgets/widgets/qmenu/qmenu.pro

index e619cdf..dad12fe 100644 (file)
 #include <private/qpushbutton_p.h>
 #include <private/qaction_p.h>
 #include <private/qsoftkeymanager_p.h>
-
-#ifdef Q_WS_X11
-#   include <private/qt_x11_p.h>
-#endif
+#include <private/qguiapplication_p.h>
+#include <qplatformtheme_qpa.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -177,31 +175,23 @@ int QMenuPrivate::scrollerHeight() const
 //Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
 QRect QMenuPrivate::popupGeometry(const QWidget *widget) const
 {
-#ifdef Q_WS_WIN
-    return QApplication::desktop()->screenGeometry(widget);
-#elif defined Q_WS_X11
-    if (X11->desktopEnvironment == DE_KDE)
+    if (QGuiApplicationPrivate::platformTheme() &&
+            QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
         return QApplication::desktop()->screenGeometry(widget);
-    else
-        return QApplication::desktop()->availableGeometry(widget);
-#else
+    } else {
         return QApplication::desktop()->availableGeometry(widget);
-#endif
+    }
 }
 
 //Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
 QRect QMenuPrivate::popupGeometry(int screen) const
 {
-#ifdef Q_WS_WIN
-    return QApplication::desktop()->screenGeometry(screen);
-#elif defined Q_WS_X11
-    if (X11->desktopEnvironment == DE_KDE)
+    if (QGuiApplicationPrivate::platformTheme() &&
+            QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
         return QApplication::desktop()->screenGeometry(screen);
-    else
-        return QApplication::desktop()->availableGeometry(screen);
-#else
+    } else {
         return QApplication::desktop()->availableGeometry(screen);
-#endif
+    }
 }
 
 QList<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const
@@ -2261,7 +2251,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e)
 
     if (action && action == d->currentAction) {
         if (!action->menu()){
-#if defined(Q_WS_WIN)
+#if defined(Q_OS_WIN)
             //On Windows only context menus can be activated with the right button
             if (e->button() == Qt::LeftButton || d->topCausedWidget() == 0)
 #endif
@@ -3000,7 +2990,7 @@ void QMenu::internalDelayedPopup()
 */
 void QMenu::setNoReplayFor(QWidget *noReplayFor)
 {
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
     d_func()->noReplayFor = noReplayFor;
 #else
     Q_UNUSED(noReplayFor);
index 55099f1..9efd030 100644 (file)
@@ -3,4 +3,3 @@ TARGET = tst_qmenu
 QT += widgets testlib
 SOURCES  += tst_qmenu.cpp
 
-win32:CONFIG += insignificant_test # QTBUG-24325