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.9 6.8
Change-Id: I62aa251f7dd9d78178ea8aefc1e2882d3ac040be
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2024-11-21 19:05:45 +01:00
parent df97b6b2de
commit 5b320c146b
4 changed files with 4 additions and 4 deletions

View File

@ -259,7 +259,7 @@ QAccessible::State QAccessibleMenuItem::state() const
s.focused = true; s.focused = true;
#endif #endif
} }
if (own && own->style()->styleHint(QStyle::SH_Menu_MouseTracking)) if (own && own->style()->styleHint(QStyle::SH_Menu_MouseTracking, nullptr, own))
s.hotTracked = true; s.hotTracked = true;
if (m_action->isSeparator() || !m_action->isEnabled()) if (m_action->isSeparator() || !m_action->isEnabled())
s.disabled = true; s.disabled = true;

View File

@ -1793,7 +1793,7 @@ void QListViewPrivate::prepareItemsLayout()
layoutBounds = QRect(QPoint(), q->maximumViewportSize()); layoutBounds = QRect(QPoint(), q->maximumViewportSize());
int frameAroundContents = 0; int frameAroundContents = 0;
if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)) { if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q)) {
QStyleOption option; QStyleOption option;
option.initFrom(q); option.initFrom(q);
frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, q) * 2; frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, q) * 2;

View File

@ -565,7 +565,7 @@ public:
Q_Q(QWidget); Q_Q(QWidget);
if (qApp->autoSipEnabled()) { if (qApp->autoSipEnabled()) {
QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel, nullptr, q));
if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) { if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
QGuiApplication::inputMethod()->show(); QGuiApplication::inputMethod()->show();
} }

View File

@ -775,7 +775,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
case PE_FrameFocusRect: case PE_FrameFocusRect:
if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) { if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
//### check for d->alt_down //### check for d->alt_down
if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt)) if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt, w))
return; return;
QRect r = opt->rect; QRect r = opt->rect;
p->save(); p->save();