diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-03-30 00:42:43 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-03-30 00:45:28 (GMT) |
commit | 3546fcbd83b2a255894e6ad9aa673f6feaba6fe7 (patch) | |
tree | 90b5799bf329f3c608d909f11168e9ddedccf025 /src/multimedia | |
parent | e19d9a53afa0a50d0ca85a144add9d546aac5b39 (diff) | |
download | Qt-3546fcbd83b2a255894e6ad9aa673f6feaba6fe7.zip Qt-3546fcbd83b2a255894e6ad9aa673f6feaba6fe7.tar.gz Qt-3546fcbd83b2a255894e6ad9aa673f6feaba6fe7.tar.bz2 |
Don't fill the video widget borders or background by default.
Can be enabled by settings setAutoFillBackground or the
Qt::WA_OpaquePaintEvent to true.
Reviewed-by: Dmytro Poplavskiy
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/base/qvideowidget.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/multimedia/base/qvideowidget.cpp b/src/multimedia/base/qvideowidget.cpp index 3820af9..467d7c6 100644 --- a/src/multimedia/base/qvideowidget.cpp +++ b/src/multimedia/base/qvideowidget.cpp @@ -218,13 +218,23 @@ void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) { QPainter painter(m_widget); + if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { + QRegion borderRegion = event->region(); + borderRegion = borderRegion.subtracted(m_boundingRect); + + QBrush brush = m_widget->palette().window(); + + QVector<QRect> rects = borderRegion.rects(); + for (QVector<QRect>::iterator it = rects.begin(), end = rects.end(); it != end; ++it) { + painter.fillRect(*it, brush); + } + } + if (m_surface->isActive() && m_boundingRect.intersects(event->rect())) { m_surface->paint(&painter, m_boundingRect, m_sourceRect); m_surface->setReady(true); } else { - painter.fillRect(event->rect(), m_widget->palette().background()); - #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) if (m_updatePaintDevice && (painter.paintEngine()->type() == QPaintEngine::OpenGL || painter.paintEngine()->type() == QPaintEngine::OpenGL2)) { @@ -239,6 +249,7 @@ void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) } #endif } + } void QRendererVideoWidgetBackend::formatChanged(const QVideoSurfaceFormat &format) @@ -364,6 +375,12 @@ void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *) void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event) { + if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { + QPainter painter(m_widget); + + painter.fillRect(event->rect(), m_widget->palette().window()); + } + m_windowControl->repaint(); event->accept(); @@ -545,10 +562,6 @@ QVideoWidget::QVideoWidget(QWidget *parent) , d_ptr(new QVideoWidgetPrivate) { d_ptr->q_ptr = this; - - QPalette palette = QWidget::palette(); - palette.setColor(QPalette::Background, Qt::black); - setPalette(palette); } /*! @@ -602,6 +615,7 @@ void QVideoWidget::setMediaObject(QMediaObject *object) QVideoWidgetControl *widgetControl = qobject_cast<QVideoWidgetControl *>( d->service->control(QVideoWidgetControl_iid)); + widgetControl = 0; if (widgetControl != 0) { d->widgetBackend = new QVideoWidgetControlBackend(widgetControl, this); } else { @@ -913,8 +927,13 @@ void QVideoWidget::paintEvent(QPaintEvent *event) { Q_D(QVideoWidget); - if (d->currentBackend) + if (d->currentBackend) { d->currentBackend->paintEvent(event); + } else if (testAttribute(Qt::WA_OpaquePaintEvent)) { + QPainter painter(this); + + painter.fillRect(event->rect(), palette().window()); + } } #include "moc_qvideowidget.cpp" |