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.cpp71
1 files changed, 22 insertions, 49 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index e8415e3a9c..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();
}
}
}
@@ -2083,31 +2081,6 @@ QAction *QMenu::exec(QList<QAction*> actions, const QPoint &pos, QAction *at, QW
}
/*!
- \overload
-
- Executes a menu synchronously.
-
- The menu's actions are specified by the list of \a actions. The menu
- will pop up so that the specified action, \a at, appears at global
- position \a pos. If \a at is not specified then the menu appears
- at position \a pos.
-
- The function returns the triggered QAction in either the popup
- menu or one of its submenus, or 0 if no item was triggered
- (normally because the user pressed Esc).
-
- This is equivalent to:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 6
-
- \sa popup(), QWidget::mapToGlobal()
-*/
-QAction *QMenu::exec(QList<QAction*> actions, const QPoint &pos, QAction *at)
-{
- // ### Qt 5: merge
- return exec(actions, pos, at, 0);
-}
-
-/*!
\reimp
*/
void QMenu::hideEvent(QHideEvent *)
@@ -2286,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
@@ -3025,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);