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:
parent
bea6b0e944
commit
9433e8b68d
@ -387,10 +387,11 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
|
|||||||
#if QT_CONFIG(shortcut)
|
#if QT_CONFIG(shortcut)
|
||||||
const bool contextMenu = isContextMenu();
|
const bool contextMenu = isContextMenu();
|
||||||
#endif
|
#endif
|
||||||
|
const bool menuSupportsSections = q->style()->styleHint(QStyle::SH_Menu_SupportsSections, nullptr, q);
|
||||||
for(int i = 0; i <= lastVisibleAction; i++) {
|
for(int i = 0; i <= lastVisibleAction; i++) {
|
||||||
QAction *action = actions.at(i);
|
QAction *action = actions.at(i);
|
||||||
const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull());
|
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);
|
|| (action->isSeparator() && !isSection);
|
||||||
|
|
||||||
if (!action->isVisible() ||
|
if (!action->isVisible() ||
|
||||||
@ -517,7 +518,7 @@ QRect QMenuPrivate::actionRect(QAction *act) const
|
|||||||
void QMenuPrivate::hideUpToMenuBar()
|
void QMenuPrivate::hideUpToMenuBar()
|
||||||
{
|
{
|
||||||
Q_Q(QMenu);
|
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) {
|
if (!tornoff) {
|
||||||
QWidget *caused = causedPopup.widget;
|
QWidget *caused = causedPopup.widget;
|
||||||
hideMenu(q); //hide after getting causedPopup
|
hideMenu(q); //hide after getting causedPopup
|
||||||
@ -585,7 +586,7 @@ void QMenuPrivate::hideMenu(QMenu *menu)
|
|||||||
|
|
||||||
aboutToHide = true;
|
aboutToHide = true;
|
||||||
// Flash item which is about to trigger (if any).
|
// 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
|
&& currentAction && currentAction == actionAboutToTrigger
|
||||||
&& menu->actions().contains(currentAction)) {
|
&& menu->actions().contains(currentAction)) {
|
||||||
QEventLoop eventLoop;
|
QEventLoop eventLoop;
|
||||||
|
@ -103,13 +103,14 @@ public:
|
|||||||
|
|
||||||
void initialize(QMenu *menu)
|
void initialize(QMenu *menu)
|
||||||
{
|
{
|
||||||
|
const auto style = menu->style();
|
||||||
m_menu = menu;
|
m_menu = menu;
|
||||||
m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, nullptr, menu);
|
m_uni_directional = 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_uni_dir_fail_at_count = short(style->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, nullptr, menu));
|
||||||
m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, nullptr , menu);
|
m_select_other_actions = style->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, nullptr, menu);
|
||||||
m_timeout = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout));
|
m_timeout = short(style->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout, nullptr, menu));
|
||||||
m_discard_state_when_entering_parent = menu->style()->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent);
|
m_discard_state_when_entering_parent = style->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent, nullptr, menu);
|
||||||
m_dont_start_time_on_leave = menu->style()->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave);
|
m_dont_start_time_on_leave = style->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave, nullptr, menu);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user