Windows11Style: adjust subline color in editable widgets in dark mode
The color of the subline in editable widgets was black in light and dark mode. Fix it to use white in dark mode to make it visible. Move it out into own helper function since it's used in at least three places. Pick-to: 6.8 Task-nubmer: QTBUG-131585 Fixes: QTBUG-131586 Change-Id: Icca2b142a1ce0c3d7f722baa6d3635bae5950e1c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 66d42b62b6f01205cf1db72e56ecb5166554e373) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
07ad8c8444
commit
eab71ff6b0
@ -254,11 +254,8 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
|
||||
if (cp.needsPainting()) {
|
||||
if (sb->frame && (sub & SC_SpinBoxFrame)) {
|
||||
cp->save();
|
||||
QRegion clipRegion = option->rect;
|
||||
clipRegion -= option->rect.adjusted(2, 2, -2, -2);
|
||||
cp->setClipRegion(clipRegion);
|
||||
QColor lineColor = state & State_HasFocus ? option->palette.accent().color() : QColor(0,0,0);
|
||||
cp->setPen(QPen(lineColor));
|
||||
cp->setClipRect(option->rect.adjusted(-2, -2, 2, 2));
|
||||
cp->setPen(editSublineColor(option, colorSchemeIndex));
|
||||
cp->drawLine(option->rect.bottomLeft() + QPointF(7, -0.5),
|
||||
option->rect.bottomRight() + QPointF(-7, -0.5));
|
||||
cp->restore();
|
||||
@ -470,8 +467,7 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
|
||||
painter->drawText(rect, QStringLiteral(u"\uE70D"), Qt::AlignVCenter | Qt::AlignHCenter);
|
||||
}
|
||||
if (combobox->editable) {
|
||||
QColor lineColor = state & State_HasFocus ? option->palette.accent().color() : QColor(0,0,0);
|
||||
painter->setPen(QPen(lineColor));
|
||||
painter->setPen(editSublineColor(option, colorSchemeIndex));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(2,1), rect.bottomRight() + QPoint(-2,1));
|
||||
if (state & State_HasFocus)
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(3,2), rect.bottomRight() + QPoint(-3,2));
|
||||
@ -969,11 +965,8 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->setPen(highContrastTheme == true ? option->palette.buttonText().color() : QPen(WINUI3Colors[colorSchemeIndex][frameColorLight]));
|
||||
painter->drawRoundedRect(option->rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||
QRegion clipRegion = option->rect;
|
||||
clipRegion -= option->rect.adjusted(2, 2, -2, -2);
|
||||
painter->setClipRegion(clipRegion);
|
||||
QColor lineColor = state & State_HasFocus ? option->palette.accent().color() : QColor(0,0,0);
|
||||
painter->setPen(QPen(lineColor));
|
||||
painter->setClipRect(option->rect.adjusted(-2, -2, 2, 2));
|
||||
painter->setPen(editSublineColor(option, colorSchemeIndex));
|
||||
painter->drawLine(option->rect.bottomLeft() + QPointF(1,0.5), option->rect.bottomRight() + QPointF(-1,0.5));
|
||||
}
|
||||
break;
|
||||
@ -2348,6 +2341,14 @@ QPen QWindows11Style::buttonLabelPen(const QStyleOption *option, int colorScheme
|
||||
: option->palette.buttonText().color());
|
||||
}
|
||||
|
||||
QColor QWindows11Style::editSublineColor(const QStyleOption *option, int colorSchemeIndex)
|
||||
{
|
||||
const State state = option->state;
|
||||
return state & State_HasFocus ? option->palette.accent().color()
|
||||
: (colorSchemeIndex == 0 ? QColor(0x80, 0x80, 0x80)
|
||||
: QColor(0xa0, 0xa0, 0xa0));
|
||||
}
|
||||
|
||||
#undef SET_IF_UNRESOLVED
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -55,6 +55,7 @@ protected:
|
||||
private:
|
||||
static inline QBrush buttonFillBrush(const QStyleOption *option);
|
||||
static inline QPen buttonLabelPen(const QStyleOption *option, int colorSchemeIndex);
|
||||
static inline QColor editSublineColor(const QStyleOption *option, int colorSchemeIndex);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(QWindows11Style)
|
||||
|
Loading…
x
Reference in New Issue
Block a user