Windows11Style:Save unpolished palette for QAbstractScrollArea::viewport
When using QWindows11Style, the viewports background has to be set to Qt::transparent to have the effect of rounded corners in ItemViews and Combobox flyouts. Other Windows styles do not make use of transparent windows, so this polishment needs to be reverted in case the style changes. Other styles also do not manipulate the QAbstractScrollArea::viewport palette and thus changing color schemes results in not applying the new color scheme. Fixes: QTBUG-123928 Change-Id: Icb529124f63587e75bb56e40e8b1fcfe3c61c55d Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 7d7d843a3eacf11d2e9e5c2dd596f6daa3ab46f7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 2141c7998ace98dbc4f2da283c6611055cdbc162)
This commit is contained in:
parent
b0a7ace47d
commit
a59d60d4ff
@ -2020,11 +2020,11 @@ void QWindows11Style::polish(QWidget* widget)
|
||||
widget->setPalette(pal);
|
||||
} else if (const auto *scrollarea = qobject_cast<QAbstractScrollArea *>(widget);
|
||||
scrollarea && !qobject_cast<QMdiArea *>(widget)) {
|
||||
QPalette pal = widget->palette();
|
||||
QColor backgroundColor = widget->palette().base().color();
|
||||
backgroundColor.setAlpha(255);
|
||||
pal.setColor(scrollarea->viewport()->backgroundRole(), backgroundColor);
|
||||
QPalette pal = scrollarea->viewport()->palette();
|
||||
const QPalette originalPalette = pal;
|
||||
pal.setColor(scrollarea->viewport()->backgroundRole(), Qt::transparent);
|
||||
scrollarea->viewport()->setPalette(pal);
|
||||
scrollarea->viewport()->setProperty("_q_original_background_palette", originalPalette);
|
||||
} else if (qobject_cast<QCommandLinkButton *>(widget)) {
|
||||
widget->setProperty("_qt_usingVistaStyle",false);
|
||||
QPalette pal = widget->palette();
|
||||
@ -2034,6 +2034,16 @@ void QWindows11Style::polish(QWidget* widget)
|
||||
}
|
||||
}
|
||||
|
||||
void QWindows11Style::unpolish(QWidget *widget)
|
||||
{
|
||||
QWindowsVistaStyle::unpolish(widget);
|
||||
if (const auto *scrollarea = qobject_cast<QAbstractScrollArea *>(widget);
|
||||
scrollarea && !qobject_cast<QMdiArea *>(widget)) {
|
||||
const QPalette pal = scrollarea->viewport()->property("_q_original_background_palette").value<QPalette>();
|
||||
scrollarea->viewport()->setPalette(pal);
|
||||
scrollarea->viewport()->setProperty("_q_original_background_palette", QVariant());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
The colors for Windows 11 are taken from the official WinUI3 Figma style at
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
|
||||
const QWidget *widget = nullptr) const override;
|
||||
void polish(QPalette &pal) override;
|
||||
void unpolish(QWidget *widget) override;
|
||||
protected:
|
||||
QWindows11Style(QWindows11StylePrivate &dd);
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user