summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmenu.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-21 09:11:27 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-04-08 18:44:59 +0000
commit3a34ef636af43e249fba417419db14c42b98094a (patch)
treee5165267a4b48b7f3abebe408ab5e9122f094ec0 /src/widgets/widgets/qmenu.cpp
parent8045ccc382ac91c14849e10f37d9a8d0605dc562 (diff)
QMenu/QComboBox: Extract helper for determining the pop up geometry
Move the code returning whether a popup should use the full screen to QStylePrivate and use for QMenu and QComboBox. Task-number: QTBUG-73231 Change-Id: I1901ecedfa90edf16329ce3b13ef4abea5ab44e8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r--src/widgets/widgets/qmenu.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 48253b52b0..a44f0fb8a7 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -78,6 +78,7 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
#include <private/qdesktopwidget_p.h>
+#include <private/qstyle_p.h>
QT_BEGIN_NAMESPACE
@@ -307,29 +308,26 @@ int QMenuPrivate::scrollerHeight() const
return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
}
-//Windows and KDE allow menus to cover the taskbar, while GNOME and Mac don't
+// Windows and KDE allow menus to cover the taskbar, while GNOME and macOS
+// don't. Torn-off menus are again different
+inline bool QMenuPrivate::useFullScreenForPopup() const
+{
+ return !tornoff && QStylePrivate::useFullScreenForPopup();
+}
+
QRect QMenuPrivate::popupGeometry() const
{
Q_Q(const QMenu);
- if (!tornoff && // Torn-off menus are different
- QGuiApplicationPrivate::platformTheme() &&
- QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
- return QDesktopWidgetPrivate::screenGeometry(q);
- } else {
- return QDesktopWidgetPrivate::availableGeometry(q);
- }
+ return useFullScreenForPopup()
+ ? QDesktopWidgetPrivate::screenGeometry(q)
+ : QDesktopWidgetPrivate::availableGeometry(q);
}
-//Windows and KDE allow menus to cover the taskbar, while GNOME and Mac don't
QRect QMenuPrivate::popupGeometry(int screen) const
{
- if (!tornoff && // Torn-off menus are different
- QGuiApplicationPrivate::platformTheme() &&
- QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
- return QDesktopWidgetPrivate::screenGeometry(screen);
- } else {
- return QDesktopWidgetPrivate::availableGeometry(screen);
- }
+ return useFullScreenForPopup()
+ ? QDesktopWidgetPrivate::screenGeometry(screen)
+ : QDesktopWidgetPrivate::availableGeometry(screen);
}
QVector<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const