summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r--src/widgets/widgets/qmenu.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index e619cdf4fc..7ebfdbecae 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -70,10 +70,8 @@
#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
@@ -305,7 +295,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
} else {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
- tabWidth = qMax(int(tabWidth), qfm.width(seq));
+ tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText)));
#endif
}
sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width());
@@ -1197,7 +1187,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
if (textAndAccel.indexOf(QLatin1Char('\t')) == -1) {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
- textAndAccel += QLatin1Char('\t') + QString(seq);
+ textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
}
#endif
option->text = textAndAccel;
@@ -1908,13 +1898,21 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset)
&& (pos.x() < parentActionRect.right()))
{
+ pos.rx() = parentActionRect.left() - menuSize.width();
+ if (pos.x() < screen.x())
pos.rx() = parentActionRect.right();
+ if (pos.x() + menuSize.width() > screen.x() + screen.width())
+ pos.rx() = screen.x();
}
} else {
if ((pos.x() < parentActionRect.right() + subMenuOffset)
&& (pos.x() + menuSize.width() > parentActionRect.left()))
{
+ pos.rx() = parentActionRect.right();
+ if (pos.x() + menuSize.width() > screen.x() + screen.width())
pos.rx() = parentActionRect.left() - menuSize.width();
+ if (pos.x() < screen.x())
+ pos.rx() = screen.x() + screen.width() - menuSize.width();
}
}
}
@@ -2261,7 +2259,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 +2998,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);