Commit 3be21543 authored by David Edmundson's avatar David Edmundson Committed by Nate Graham

Move dialog margin settings to polish event

Paint events MUST not change the state of things. This is especially
important within style code that is used in many apps that we do not
control.

Doing it in polish is better. It's still not ideal to adjust geometry in
the style, but at least this is where we have a similar hook for
QDockWidget so hopefully we know this pattern is acceptable.

BUG: 427311
parent ae65ce30
......@@ -388,9 +388,19 @@ namespace Breeze
setTranslucentBackground( widget );
} else if ( qobject_cast<QMainWindow*> (widget) || qobject_cast<QDialog*> (widget) ) {
} else if ( qobject_cast<QMainWindow*> (widget) ) {
widget->setAttribute(Qt::WA_StyledBackground);
}
else if ( qobject_cast<QDialog*> (widget) ) {
widget->setAttribute(Qt::WA_StyledBackground);
if (_toolsAreaManager->hasHeaderColors() && _helper->shouldDrawToolsArea(widget)) {
const QMargins margins = widget->contentsMargins();
widget->setContentsMargins(margins.left(), qMax(margins.top(), 1), margins.right(), margins.bottom());
}
}
// base class polishing
ParentStyleClass::polish( widget );
......@@ -941,8 +951,6 @@ namespace Breeze
painter->restore();
} else if (auto dialog = qobject_cast<const QDialog*>(widget)) {
auto margins = dialog->contentsMargins();
const_cast<QDialog*>(dialog)->setContentsMargins(margins.left(), qMax(margins.top(), 1), margins.right(), margins.bottom());
painter->setPen(QPen(_helper->separatorColor(_toolsAreaManager->palette()), PenWidth::Frame * widget->devicePixelRatio()));
painter->drawLine(widget->rect().topLeft(), widget->rect().topRight());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment