Always fill the background of a tabbed QMdiSubWindow

QMacStyle polishes QMdiSubWindows to have autoFillBackground set to
false. If the QMdiSubWindow's widget also doesn't fill the background
(like QLabel), then nobody fills the window in a tabbed QMdiArea, and
the other subwindows show through.

This change makes sure that all pixels are painted in that situations,
using the styled frame.

Fixes: QTBUG-76214
Change-Id: Iae025d15d36a8bc0d0c5838ac43c9d54944bcc83
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Volker Hilsheimer 2019-06-20 16:53:24 +02:00
parent a22a6c01f8
commit cfd2cc91fd
1 changed files with 11 additions and 5 deletions

View File

@ -3140,8 +3140,6 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent)
}
Q_D(QMdiSubWindow);
if (isMaximized() && !d->drawTitleBarWhenMaximized())
return;
if (d->resizeTimerId != -1) {
// Only update the style option rect and the window title.
@ -3161,6 +3159,17 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent)
}
QStylePainter painter(this);
QStyleOptionFrame frameOptions;
frameOptions.initFrom(this);
frameOptions.state.setFlag(QStyle::State_Active, d->isActive);
if (isMaximized() && !d->drawTitleBarWhenMaximized()) {
if (!autoFillBackground() && (!widget() || !qt_widget_private(widget())->isOpaque)) {
// make sure we paint all pixels of a maximized QMdiSubWindow if no-one else does
painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions);
}
return;
}
if (!d->windowTitle.isEmpty())
painter.setFont(d->font);
painter.drawComplexControl(QStyle::CC_TitleBar, d->cachedStyleOptions);
@ -3168,10 +3177,7 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent)
if (isMinimized() && !d->hasBorder(d->cachedStyleOptions))
return;
QStyleOptionFrame frameOptions;
frameOptions.initFrom(this);
frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this);
frameOptions.state.setFlag(QStyle::State_Active, d->isActive);
// ### Ensure that we do not require setting the cliprect for 4.4
if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions))