Windows11Style: allow overriding of palette for QPush/ToolButton
Honor the palette set by the stylesheet when drawing a QPush/ToolButton. Pick-to: 6.9 6.8 Fixes: QTBUG-134497 Change-Id: I33b9cdf8d4999e1fccdae250543db541b66b3b7d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
0de9b3f126
commit
b0dec15d2d
@ -906,6 +906,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
painter->drawRoundedRect(rect,
|
painter->drawRoundedRect(rect,
|
||||||
secondLevelRoundingRadius, secondLevelRoundingRadius);
|
secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
|
|
||||||
|
if (!option->palette.isBrushSet(QPalette::Current, QPalette::Button)) {
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
if (!isRaised)
|
if (!isRaised)
|
||||||
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
||||||
@ -913,7 +914,9 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillSecondary]);
|
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillSecondary]);
|
||||||
else
|
else
|
||||||
painter->setBrush(option->palette.button());
|
painter->setBrush(option->palette.button());
|
||||||
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(rect, secondLevelRoundingRadius,
|
||||||
|
secondLevelRoundingRadius);
|
||||||
|
}
|
||||||
if (isRaised) {
|
if (isRaised) {
|
||||||
const qreal sublineOffset = secondLevelRoundingRadius - 0.5;
|
const qreal sublineOffset = secondLevelRoundingRadius - 0.5;
|
||||||
painter->setPen(WINUI3Colors[colorSchemeIndex][controlStrokeSecondary]);
|
painter->setPen(WINUI3Colors[colorSchemeIndex][controlStrokeSecondary]);
|
||||||
@ -1465,7 +1468,9 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
}
|
}
|
||||||
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
} else {
|
} else {
|
||||||
if (flags & (State_Sunken))
|
if (option->palette.isBrushSet(QPalette::Current, QPalette::Button))
|
||||||
|
painter->setBrush(option->palette.button());
|
||||||
|
else if (flags & (State_Sunken))
|
||||||
painter->setBrush(flags & State_On ? option->palette.accent().color().lighter(120) : WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
painter->setBrush(flags & State_On ? option->palette.accent().color().lighter(120) : WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
||||||
else if (flags & State_MouseOver)
|
else if (flags & State_MouseOver)
|
||||||
painter->setBrush(flags & State_On ? option->palette.accent().color().lighter(110) : WINUI3Colors[colorSchemeIndex][controlFillSecondary]);
|
painter->setBrush(flags & State_On ? option->palette.accent().color().lighter(110) : WINUI3Colors[colorSchemeIndex][controlFillSecondary]);
|
||||||
@ -2354,6 +2359,9 @@ void QWindows11Style::polish(QPalette& result)
|
|||||||
|
|
||||||
QBrush QWindows11Style::buttonFillBrush(const QStyleOption *option)
|
QBrush QWindows11Style::buttonFillBrush(const QStyleOption *option)
|
||||||
{
|
{
|
||||||
|
if (option->palette.isBrushSet(QPalette::Current, QPalette::Button))
|
||||||
|
return option->palette.button();
|
||||||
|
|
||||||
const bool isOn = (option->state & QStyle::State_On || option->state & QStyle::State_NoChange);
|
const bool isOn = (option->state & QStyle::State_On || option->state & QStyle::State_NoChange);
|
||||||
QBrush brush = isOn ? option->palette.accent() : option->palette.window();
|
QBrush brush = isOn ? option->palette.accent() : option->palette.window();
|
||||||
if (!isOn && option->state & QStyle::State_AutoRaise)
|
if (!isOn && option->state & QStyle::State_AutoRaise)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user