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>
This commit is contained in:
parent
8045ccc382
commit
3a34ef636a
@ -46,6 +46,7 @@
|
|||||||
#include "qstyleoption.h"
|
#include "qstyleoption.h"
|
||||||
#include "private/qstyle_p.h"
|
#include "private/qstyle_p.h"
|
||||||
#include "private/qguiapplication_p.h"
|
#include "private/qguiapplication_p.h"
|
||||||
|
#include <qpa/qplatformtheme.h>
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
#include "qdebug.h"
|
#include "qdebug.h"
|
||||||
#endif
|
#endif
|
||||||
@ -2447,6 +2448,13 @@ void QStyle::setProxy(QStyle *style)
|
|||||||
d->proxyStyle = style;
|
d->proxyStyle = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Windows and KDE allow menus to cover the taskbar, while GNOME and macOS don't
|
||||||
|
bool QStylePrivate::useFullScreenForPopup()
|
||||||
|
{
|
||||||
|
auto theme = QGuiApplicationPrivate::platformTheme();
|
||||||
|
return theme && theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#include "moc_qstyle.cpp"
|
#include "moc_qstyle.cpp"
|
||||||
|
@ -67,6 +67,9 @@ class QStylePrivate: public QObjectPrivate
|
|||||||
public:
|
public:
|
||||||
inline QStylePrivate()
|
inline QStylePrivate()
|
||||||
: layoutSpacingIndex(-1), proxyStyle(0) {}
|
: layoutSpacingIndex(-1), proxyStyle(0) {}
|
||||||
|
|
||||||
|
static bool useFullScreenForPopup();
|
||||||
|
|
||||||
mutable int layoutSpacingIndex;
|
mutable int layoutSpacingIndex;
|
||||||
QStyle *proxyStyle;
|
QStyle *proxyStyle;
|
||||||
};
|
};
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
#if QT_CONFIG(effects)
|
#if QT_CONFIG(effects)
|
||||||
# include <private/qeffects_p.h>
|
# include <private/qeffects_p.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <private/qstyle_p.h>
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
#include "qaccessible.h"
|
#include "qaccessible.h"
|
||||||
#endif
|
#endif
|
||||||
@ -261,16 +262,11 @@ void QComboBoxPrivate::_q_modelDestroyed()
|
|||||||
model = QAbstractItemModelPrivate::staticEmptyModel();
|
model = QAbstractItemModelPrivate::staticEmptyModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
|
|
||||||
QRect QComboBoxPrivate::popupGeometry(int screen) const
|
QRect QComboBoxPrivate::popupGeometry(int screen) const
|
||||||
{
|
{
|
||||||
bool useFullScreenForPopupMenu = false;
|
return QStylePrivate::useFullScreenForPopup()
|
||||||
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
|
? QDesktopWidgetPrivate::screenGeometry(screen)
|
||||||
useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
|
: QDesktopWidgetPrivate::availableGeometry(screen);
|
||||||
return useFullScreenForPopupMenu ?
|
|
||||||
QDesktopWidgetPrivate::screenGeometry(screen) :
|
|
||||||
QDesktopWidgetPrivate::availableGeometry(screen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QComboBoxPrivate::updateHoverControl(const QPoint &pos)
|
bool QComboBoxPrivate::updateHoverControl(const QPoint &pos)
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
#include <private/qguiapplication_p.h>
|
#include <private/qguiapplication_p.h>
|
||||||
#include <qpa/qplatformtheme.h>
|
#include <qpa/qplatformtheme.h>
|
||||||
#include <private/qdesktopwidget_p.h>
|
#include <private/qdesktopwidget_p.h>
|
||||||
|
#include <private/qstyle_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -307,29 +308,26 @@ int QMenuPrivate::scrollerHeight() const
|
|||||||
return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
|
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
|
QRect QMenuPrivate::popupGeometry() const
|
||||||
{
|
{
|
||||||
Q_Q(const QMenu);
|
Q_Q(const QMenu);
|
||||||
if (!tornoff && // Torn-off menus are different
|
return useFullScreenForPopup()
|
||||||
QGuiApplicationPrivate::platformTheme() &&
|
? QDesktopWidgetPrivate::screenGeometry(q)
|
||||||
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
|
: QDesktopWidgetPrivate::availableGeometry(q);
|
||||||
return QDesktopWidgetPrivate::screenGeometry(q);
|
|
||||||
} else {
|
|
||||||
return QDesktopWidgetPrivate::availableGeometry(q);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Windows and KDE allow menus to cover the taskbar, while GNOME and Mac don't
|
|
||||||
QRect QMenuPrivate::popupGeometry(int screen) const
|
QRect QMenuPrivate::popupGeometry(int screen) const
|
||||||
{
|
{
|
||||||
if (!tornoff && // Torn-off menus are different
|
return useFullScreenForPopup()
|
||||||
QGuiApplicationPrivate::platformTheme() &&
|
? QDesktopWidgetPrivate::screenGeometry(screen)
|
||||||
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
|
: QDesktopWidgetPrivate::availableGeometry(screen);
|
||||||
return QDesktopWidgetPrivate::screenGeometry(screen);
|
|
||||||
} else {
|
|
||||||
return QDesktopWidgetPrivate::availableGeometry(screen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const
|
QVector<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const
|
||||||
|
@ -343,6 +343,7 @@ public:
|
|||||||
void updateActionRects(const QRect &screen) const;
|
void updateActionRects(const QRect &screen) const;
|
||||||
QRect popupGeometry() const;
|
QRect popupGeometry() const;
|
||||||
QRect popupGeometry(int screen) const;
|
QRect popupGeometry(int screen) const;
|
||||||
|
bool useFullScreenForPopup() const;
|
||||||
int getLastVisibleAction() const;
|
int getLastVisibleAction() const;
|
||||||
|
|
||||||
//selection
|
//selection
|
||||||
|
Loading…
Reference in New Issue
Block a user