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
wilder-5.24
David Edmundson 5 years ago committed by Nate Graham
parent ae65ce3004
commit 3be21543a7
  1. 14
      kstyle/breezestyle.cpp

@ -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());
}

Loading…
Cancel
Save