Style: pass widget to styleHint() where appropriate

QStyle::styleHint() take the QWidget as optional third parameter. Add
this to calls to styleHint() where appropriate.

Task-number: QTBUG-2501
Pick-to: 6.8
Change-Id: I95b85d51ce98540920243b37473b97426eb40ab4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6f813bcb441ee195d88cc9fd39921bc4b5fa0192)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2024-11-21 19:04:33 +01:00 committed by Qt Cherry-pick Bot
parent bea6b0e944
commit 9433e8b68d
2 changed files with 11 additions and 9 deletions

View File

@ -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;

View File

@ -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();
}