00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "graphicsvideowidget.h"
00019 #include "graphicsvideosurface_p.h"
00020 #include "../../QGlib/signal.h"
00021
00022 namespace QGst {
00023 namespace Ui {
00024
00025 GraphicsVideoWidget::GraphicsVideoWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
00026 : QGraphicsWidget(parent, wFlags)
00027 {
00028 setFlag(QGraphicsItem::ItemHasNoContents, false);
00029 }
00030
00031 GraphicsVideoWidget::~GraphicsVideoWidget()
00032 {
00033 setSurface(0);
00034 }
00035
00036 GraphicsVideoSurface *GraphicsVideoWidget::surface() const
00037 {
00038 return m_surface.data();
00039 }
00040
00041 void GraphicsVideoWidget::setSurface(GraphicsVideoSurface *surface)
00042 {
00043 if (m_surface) {
00044 m_surface.data()->d->items.remove(this);
00045 }
00046
00047 m_surface = surface;
00048
00049 if (m_surface) {
00050 m_surface.data()->d->items.insert(this);
00051 }
00052 }
00053
00054 void GraphicsVideoWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
00055 {
00056 Q_UNUSED(option);
00057
00058 QRectF r = rect();
00059
00060 if (!m_surface || m_surface.data()->d->videoSink.isNull() ||
00061 widget != m_surface.data()->d->view->viewport()
00062 ) {
00063 painter->fillRect(r, Qt::black);
00064 } else {
00065 QGlib::emit<void>(m_surface.data()->d->videoSink, "paint",
00066 (void*)painter, r.x(), r.y(), r.width(), r.height());
00067 }
00068 }
00069
00070 }
00071 }