diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index d21bf6f7507..8969e4e1837 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -387,10 +387,11 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const #if QT_CONFIG(shortcut) const bool contextMenu = isContextMenu(); #endif + const bool menuSupportsSections = q->style()->styleHint(QStyle::SH_Menu_SupportsSections, nullptr, q); for(int i = 0; i <= lastVisibleAction; i++) { QAction *action = actions.at(i); const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull()); - const bool isPlainSeparator = (isSection && !q->style()->styleHint(QStyle::SH_Menu_SupportsSections)) + const bool isPlainSeparator = (isSection && !menuSupportsSections) || (action->isSeparator() && !isSection); if (!action->isVisible() || @@ -517,7 +518,7 @@ QRect QMenuPrivate::actionRect(QAction *act) const void QMenuPrivate::hideUpToMenuBar() { Q_Q(QMenu); - bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide); + bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide, nullptr, q); if (!tornoff) { QWidget *caused = causedPopup.widget; hideMenu(q); //hide after getting causedPopup @@ -585,7 +586,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) aboutToHide = true; // Flash item which is about to trigger (if any). - if (menu && menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem) + if (menu && menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem, nullptr, stillAlive) && currentAction && currentAction == actionAboutToTrigger && menu->actions().contains(currentAction)) { QEventLoop eventLoop; diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index d8c741ae7c6..c434a6d47a1 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -103,13 +103,14 @@ public: void initialize(QMenu *menu) { + const auto style = menu->style(); m_menu = menu; - m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, nullptr, menu); - m_uni_dir_fail_at_count = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, nullptr, menu)); - m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, nullptr , menu); - 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); + m_uni_directional = style->styleHint(QStyle::SH_Menu_SubMenuUniDirection, nullptr, menu); + m_uni_dir_fail_at_count = short(style->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, nullptr, menu)); + m_select_other_actions = style->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, nullptr, menu); + m_timeout = short(style->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout, nullptr, menu)); + m_discard_state_when_entering_parent = style->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent, nullptr, menu); + m_dont_start_time_on_leave = style->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave, nullptr, menu); reset(); }