diff options
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 22 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu_p.h | 16 |
2 files changed, 20 insertions, 18 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index ab89b8a415..0355bb44f7 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -264,20 +264,23 @@ int QMenuPrivate::scrollerHeight() const } //Windows and KDE allow menus to cover the taskbar, while GNOME and Mac don't -QRect QMenuPrivate::popupGeometry(const QWidget *widget) const +QRect QMenuPrivate::popupGeometry() const { - if (QGuiApplicationPrivate::platformTheme() && + Q_Q(const QMenu); + if (!tornoff && // Torn-off menus are different + QGuiApplicationPrivate::platformTheme() && QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) { - return QDesktopWidgetPrivate::screenGeometry(widget); + return QDesktopWidgetPrivate::screenGeometry(q); } else { - return QDesktopWidgetPrivate::availableGeometry(widget); + 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 { - if (QGuiApplicationPrivate::platformTheme() && + if (!tornoff && // Torn-off menus are different + QGuiApplicationPrivate::platformTheme() && QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) { return QDesktopWidgetPrivate::screenGeometry(screen); } else { @@ -307,8 +310,7 @@ bool QMenuPrivate::isContextMenu() const void QMenuPrivate::updateActionRects() const { - Q_Q(const QMenu); - updateActionRects(popupGeometry(q)); + updateActionRects(popupGeometry()); } void QMenuPrivate::updateActionRects(const QRect &screen) const @@ -1076,7 +1078,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc if (newScrollFlags & QMenuScroller::ScrollUp) newOffset -= vmargin; - QRect screen = popupGeometry(q); + QRect screen = popupGeometry(); const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); if (q->height() < screen.height()-(desktopFrame*2)-1) { QRect geom = q->geometry(); @@ -2330,7 +2332,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) #if QT_CONFIG(graphicsview) bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); if (isEmbedded) - screen = d->popupGeometry(this); + screen = d->popupGeometry(); else #endif screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(p)); @@ -3599,7 +3601,7 @@ void QMenu::internalDelayedPopup() #if QT_CONFIG(graphicsview) bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); if (isEmbedded) - screen = d->popupGeometry(this); + screen = d->popupGeometry(); else #endif screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(pos())); diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index a48d41c140..574c71c31e 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -110,9 +110,9 @@ public: { m_menu = menu; m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, 0, menu); - m_uni_dir_fail_at_count = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, 0, menu); + m_uni_dir_fail_at_count = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, 0, menu)); m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, 0 , menu); - m_timeout = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout); + m_timeout = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout)); m_discard_state_when_entering_parent = menu->style()->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent); m_dont_start_time_on_leave = menu->style()->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave); reset(); @@ -150,12 +150,12 @@ public: void leave(); void childLeave(); - static float slope(const QPointF &p1, const QPointF &p2) + static qreal slope(const QPointF &p1, const QPointF &p2) { const QPointF slope = p2 - p1; - if (slope.x()== 0) + if (qFuzzyIsNull(slope.x())) return 9999; - return slope.y()/slope.x(); + return slope.y() / slope.x(); } bool checkSlope(qreal oldS, qreal newS, bool wantSteeper) @@ -218,7 +218,7 @@ public: bool slopeTop = checkSlope(prev_slope_top, current_slope_top, sub_menu_top.y() < mousePos.y()); bool slopeBottom = checkSlope(prev_slope_bottom, current_slope_bottom, sub_menu_bottom.y() > mousePos.y()); bool rightDirection = false; - int mouseDir = m_previous_point.y() - mousePos.y(); + int mouseDir = int(m_previous_point.y() - mousePos.y()); if (mouseDir >= 0) { rightDirection = rightDirection || slopeTop; } @@ -318,8 +318,8 @@ public: mutable QHash<QAction *, QWidget *> widgetItems; void updateActionRects() const; void updateActionRects(const QRect &screen) const; - QRect popupGeometry(const QWidget *widget) const; - QRect popupGeometry(int screen = -1) const; + QRect popupGeometry() const; + QRect popupGeometry(int screen) const; mutable uint ncols : 4; //4 bits is probably plenty uint collapsibleSeparators : 1; uint toolTipsVisible : 1; |