|
27 | 27 | #include <QApplication> |
28 | 28 | #include <QBrush> |
29 | 29 | #include <QByteArray> |
30 | | -#include <QChildEvent> |
31 | 30 | #include <QColor> |
32 | 31 | #include <QCommonStyle> // IWYU pragma: keep |
33 | 32 | #include <QCoreApplication> |
@@ -134,11 +133,26 @@ void MapperProxyStyle::onSettingsChanged() |
134 | 133 | } |
135 | 134 | } |
136 | 135 |
|
| 136 | +void MapperProxyStyle::fixupProxyChain(QStyle* base_style) |
| 137 | +{ |
| 138 | + // QTBUG-24279 QProxyStyle doesn't support proxies |
| 139 | + // This function makes this proxy style the direct proxy of all underlying |
| 140 | + // styles, while keeping the top-down base style chain. |
| 141 | + if (auto* base_proxy_style = qobject_cast<QProxyStyle*>(base_style)) |
| 142 | + { |
| 143 | + fixupProxyChain(base_proxy_style->baseStyle()); |
| 144 | + } |
| 145 | + auto* const old_base = baseStyle(); |
| 146 | + old_base->setParent(nullptr); // Prevent deletion on setBaseStyle(). |
| 147 | + setBaseStyle(base_style); // Set base_style's proxy and parent to this. |
| 148 | + old_base->setParent(this); // Restore healthy ownership. |
| 149 | +} |
137 | 150 |
|
138 | 151 | void MapperProxyStyle::polish(QApplication* application) |
139 | 152 | { |
140 | 153 | common_style = qobject_cast<QCommonStyle*>(baseStyle()); |
141 | 154 |
|
| 155 | + fixupProxyChain(baseStyle()); |
142 | 156 | QProxyStyle::polish(application); |
143 | 157 | QApplication::setPalette(default_palette); |
144 | 158 |
|
@@ -207,13 +221,6 @@ void MapperProxyStyle::unpolish(QApplication* application) |
207 | 221 | } |
208 | 222 |
|
209 | 223 |
|
210 | | -void MapperProxyStyle::childEvent(QChildEvent* event) |
211 | | -{ |
212 | | - if (event->added() || event->removed()) |
213 | | - common_style = qobject_cast<QCommonStyle*>(baseStyle()); |
214 | | -} |
215 | | - |
216 | | - |
217 | 224 | void MapperProxyStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const |
218 | 225 | { |
219 | 226 | auto overridden_element = element; |
|
0 commit comments