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.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index d62c010c60..2cafe462b1 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -130,7 +130,7 @@ public:
setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true);
updateWindowTitle();
setEnabled(p->isEnabled());
-#if QT_CONFIG(cssparser)
+#if QT_CONFIG(style_stylesheet)
setStyleSheet(p->styleSheet());
#endif
if (style() != p->style())
@@ -327,8 +327,8 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + tearoffHeight;
+ const int column_max_y = screen.height() - 2 * deskFw - (vmargin + bottommargin + fw);
int max_column_width = 0;
- int dh = screen.height();
int y = base_y;
//for compatibility now - will have to refactor this away
@@ -406,8 +406,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
if (!sz.isEmpty()) {
max_column_width = qMax(max_column_width, sz.width());
//wrapping
- if (!scroll &&
- y + sz.height() + vmargin + bottommargin + fw > dh - (deskFw * 2)) {
+ if (!scroll && y + sz.height() > column_max_y) {
ncols++;
y = base_y;
} else {
@@ -433,8 +432,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
QRect &rect = actionRects[i];
if (rect.isNull())
continue;
- if (!scroll &&
- y + rect.height() + vmargin + bottommargin + fw > dh - deskFw * 2) {
+ if (!scroll && y + rect.height() > column_max_y) {
x += max_column_width + hmargin;
y = base_y;
}
@@ -2325,16 +2323,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
ensurePolished(); // Get the right font
emit aboutToShow();
const bool actionListChanged = d->itemsDirty;
- d->updateActionRects();
- QPoint pos;
- QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);
- if (actionListChanged && causedButton)
- pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
- else
- pos = p;
- const QSize menuSizeHint(sizeHint());
- QSize size = menuSizeHint;
QRect screen;
#ifndef QT_NO_GRAPHICSVIEW
bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
@@ -2343,6 +2332,17 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
else
#endif
screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
+ d->updateActionRects(screen);
+
+ QPoint pos;
+ QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);
+ if (actionListChanged && causedButton)
+ pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
+ else
+ pos = p;
+
+ const QSize menuSizeHint(sizeHint());
+ QSize size = menuSizeHint;
const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this);
bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen);