Skip to content

Commit

Permalink
widgets: add QtAVWidgets module
Browse files Browse the repository at this point in the history
changes:
You have to include <QtAVWidgets/QtAVWidgets.h> to use built-in widget
renderers
Link against QtAVWidgets
TODO:
QT  = avwidgets not available
move ids to widgets module?
  • Loading branch information
wang-bin committed Jan 9, 2015
1 parent bcb449e commit 192f22c
Show file tree
Hide file tree
Showing 33 changed files with 280 additions and 293 deletions.
2 changes: 1 addition & 1 deletion QtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 25,7 @@ greaterThan(QT_MAJOR_VERSION, 4) {
}
!android:!no-tests {
SUBDIRS = tests
tests.depends = libqtav
tests.depends = libqtav libqtavwidgets
}
OTHER_FILES = README.md TODO.txt Changelog
OTHER_FILES = templates/vo.h templates/vo.cpp templates/COPYRIGHT.h templates/mkclass.sh
Expand Down
1 change: 1 addition & 0 deletions examples/filters/filters.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@ TARGET = filters
STATICLINK = 0
PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES = \
Expand Down
1 change: 1 addition & 0 deletions examples/player/EventFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,7 @@
******************************************************************************/

#include "EventFilter.h"
#include <QtAVWidgets/QtAVWidgets.h>
#include <QApplication>
#include <QtCore/QUrl>
#include <QEvent>
Expand Down
1 change: 1 addition & 0 deletions examples/player/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,7 @@
******************************************************************************/
#include "MainWindow.h"
#include "EventFilter.h"
#include <QtAVWidgets/QtAVWidgets.h>
#include <QtCore/QtDebug>
#include <QtCore/QLocale>
#include <QtCore/QTimer>
Expand Down
1 change: 1 addition & 0 deletions examples/player/player.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@ VERSION = $$QTAV_VERSION
STATICLINK = 0
PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
include($$PWD/../common/libcommon.pri)
preparePaths($$OUT_PWD/../../out)
INCLUDEPATH = $$PWD
Expand Down
1 change: 1 addition & 0 deletions examples/sharedoutput/sharedoutput.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 13,7 @@ CONFIG -= app_bundle

PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES = main.cpp \
Expand Down
1 change: 1 addition & 0 deletions examples/simpleplayer/simpleplayer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT = widgets
STATICLINK = 0
PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES = main.cpp \
Expand Down
1 change: 1 addition & 0 deletions examples/videocapture/videocapture.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT = widgets
STATICLINK = 0
PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES = main.cpp \
Expand Down
1 change: 1 addition & 0 deletions examples/videographicsitem/videographicsitem.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@ TEMPLATE = app
STATICLINK = 0
PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)


Expand Down
1 change: 1 addition & 0 deletions examples/videogroup/videogroup.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@ TARGET = videogroup
STATICLINK = 0
PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES = main.cpp videogroup.cpp
Expand Down
1 change: 1 addition & 0 deletions examples/videowall/videowall.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@ TARGET = videowall
STATICLINK = 0
PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES = main.cpp VideoWall.cpp
Expand Down
15 changes: 1 addition & 14 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -29,9 29,6 @@
#include <QtCore/QIODevice>
#include <QtCore/QThreadPool>
#include <QtCore/QTimer>
#if QTAV_HAVE(WIDGETS)
#include <QWidget>
#endif //QTAV_HAVE(WIDGETS)
#include "QtAV/AVDemuxer.h"
#include "QtAV/Packet.h"
#include "QtAV/AudioDecoder.h"
Expand All @@ -44,7 41,6 @@
#include "QtAV/AudioOutputTypes.h"
#include "filter/FilterManager.h"
#include "output/OutputSet.h"
#include "output/video/VideoOutputEventFilter.h"
#include "AudioThread.h"
#include "VideoThread.h"
#include "AVDemuxThread.h"
Expand Down Expand Up @@ -114,15 110,6 @@ void AVPlayer::addVideoRenderer(VideoRenderer *renderer)
return;
}
renderer->setStatistics(&d->statistics);
#if QTAV_HAVE(WIDGETS)
QObject *voo = renderer->widget();
if (voo) {
//TODO: how to delete filter if no parent?
//the filtering object must be in the same thread as this object.
if (renderer->widget())
voo->installEventFilter(new VideoOutputEventFilter(renderer));
}
#endif //QTAV_HAVE(WIDGETS)
d->vos->addOutput(renderer);
}

Expand Down
5 changes: 3 additions & 2 deletions src/QtAV/GLWidgetRenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -22,6 22,7 @@
#ifndef QTAV_GLWIDGETRENDERER_H
#define QTAV_GLWIDGETRENDERER_H

#include <QtAVWidgets/global.h>
#include <QtAV/VideoRenderer.h>
#include <QtOpenGL/QGLWidget>
// TODO: QGLFunctions is in Qt4.8 . meego is 4.7
Expand All @@ -32,7 33,7 @@
namespace QtAV {

class GLWidgetRendererPrivate;
class Q_AV_EXPORT GLWidgetRenderer : public QGLWidget, public VideoRenderer
class Q_AVWIDGETS_EXPORT GLWidgetRenderer : public QGLWidget, public VideoRenderer
#if QTAV_HAVE(QGLFUNCTIONS) //TODO: why use QT_VERSION will result in moc error?
, public QGLFunctions
#endif //QTAV_HAVE(QGLFUNCTIONS)
Expand Down
5 changes: 3 additions & 2 deletions src/QtAV/GLWidgetRenderer2.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014 Wang Bin <[email protected]>
Copyright (C) 2014-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -22,6 22,7 @@
#ifndef QTAV_GLWIDGETRENDERER2_H
#define QTAV_GLWIDGETRENDERER2_H

#include <QtAVWidgets/global.h>
#include <QtOpenGL/QGLWidget>
#include <QtAV/OpenGLRendererBase.h>

Expand All @@ -33,7 34,7 @@ class GLWidgetRenderer2Private;
* Renderering video frames using GLSL. A more generic high level class OpenGLVideo is used internally.
* TODO: for Qt5, no QtOpenGL, use QWindow instead.
*/
class Q_AV_EXPORT GLWidgetRenderer2 : public QGLWidget, public OpenGLRendererBase
class Q_AVWIDGETS_EXPORT GLWidgetRenderer2 : public QGLWidget, public OpenGLRendererBase
{
Q_OBJECT
DPTR_DECLARE_PRIVATE(GLWidgetRenderer2)
Expand Down
5 changes: 3 additions & 2 deletions src/QtAV/GraphicsItemRenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -22,6 22,7 @@
#ifndef QAV_GRAPHICSITEMRENDERER_H
#define QAV_GRAPHICSITEMRENDERER_H

#include <QtAVWidgets/global.h>
#include <QtAV/QPainterRenderer.h>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtWidgets/QGraphicsWidget>
Expand All @@ -40,7 41,7 @@
namespace QtAV {

class GraphicsItemRendererPrivate;
class Q_AV_EXPORT GraphicsItemRenderer : public GraphicsWidget, public QPainterRenderer
class Q_AVWIDGETS_EXPORT GraphicsItemRenderer : public GraphicsWidget, public QPainterRenderer
{
Q_OBJECT
DPTR_DECLARE_PRIVATE(GraphicsItemRenderer)
Expand Down
5 changes: 3 additions & 2 deletions src/QtAV/OpenGLWidgetRenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014 Wang Bin <[email protected]>
Copyright (C) 2014-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -22,13 22,14 @@
#ifndef QTAV_OPENGLWIDGETRENDERER_H
#define QTAV_OPENGLWIDGETRENDERER_H

#include <QtAVWidgets/global.h>
#include <QtWidgets/QOpenGLWidget>
#include <QtAV/OpenGLRendererBase.h>

namespace QtAV {

class OpenGLWidgetRendererPrivate;
class Q_AV_EXPORT OpenGLWidgetRenderer : public QOpenGLWidget, public OpenGLRendererBase
class Q_AVWIDGETS_EXPORT OpenGLWidgetRenderer : public QOpenGLWidget, public OpenGLRendererBase
{
DPTR_DECLARE_PRIVATE(OpenGLWidgetRenderer)
public:
Expand Down
6 changes: 1 addition & 5 deletions src/QtAV/QtAV.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -61,10 61,6 @@
#include <QtAV/VideoOutput.h>
//The following renderer headers can be removed
#include <QtAV/QPainterRenderer.h>
#include <QtAV/GraphicsItemRenderer.h>
#include <QtAV/WidgetRenderer.h>
#include <QtAV/GLWidgetRenderer.h>
#include <QtAV/GLWidgetRenderer2.h>

#include <QtAV/Subtitle.h>
#include <QtAV/SubtitleFilter.h>
Expand Down
5 changes: 1 addition & 4 deletions src/QtAV/QtAV_Global.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -49,11 49,8 @@ enum LogLevel {
LogFatal, // log fatal
LogAll
};
Q_AV_EXPORT void about(); //popup a dialog
Q_AV_EXPORT void aboutFFmpeg();
Q_AV_EXPORT QString aboutFFmpeg_PlainText();
Q_AV_EXPORT QString aboutFFmpeg_HTML();
Q_AV_EXPORT void aboutQtAV();
Q_AV_EXPORT QString aboutQtAV_PlainText();
Q_AV_EXPORT QString aboutQtAV_HTML();
/*!
Expand Down
5 changes: 3 additions & 2 deletions src/QtAV/WidgetRenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -22,6 22,7 @@
#ifndef QTAV_WIDGETRENDERER_H
#define QTAV_WIDGETRENDERER_H

#include <QtAVWidgets/global.h>
#include <QtAV/QPainterRenderer.h>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtWidgets/QWidget>
Expand All @@ -32,7 33,7 @@
namespace QtAV {

class WidgetRendererPrivate;
class Q_AV_EXPORT WidgetRenderer : public QWidget, public QPainterRenderer
class Q_AVWIDGETS_EXPORT WidgetRenderer : public QWidget, public QPainterRenderer
{
Q_OBJECT
DPTR_DECLARE_PRIVATE(WidgetRenderer)
Expand Down
65 changes: 1 addition & 64 deletions src/QtAV_Global.cpp
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -20,22 20,8 @@
******************************************************************************/

#include "QtAV/QtAV_Global.h"
// TODO: move to an internal header
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) || defined(QT_WIDGETS_LIB)
#ifndef QTAV_HAVE_WIDGETS
#define QTAV_HAVE_WIDGETS 1
#endif //QTAV_HAVE_WIDGETS
#endif

#include <QtCore/QObject>
#include <QtCore/QRegExp>
#if QTAV_HAVE(WIDGETS)
#include <QBoxLayout>
#include <QMessageBox>
#include <QPushButton>
#include <QTableWidget>
#include <QTextBrowser>
#endif //QTAV_HAVE(WIDGETS)
#include "QtAV/version.h"
#include "QtAV/private/AVCompat.h"
#include "utils/Logger.h"
Expand Down Expand Up @@ -71,46 57,6 @@ bool isLogLevelSet() { return gLogLevelSet;}
} //namespace Internal

//TODO: auto add new depend libraries information
void about()
{
#if QTAV_HAVE(WIDGETS)
//we should use new because a qobject will delete it's children
QTextBrowser *viewQtAV = new QTextBrowser;
QTextBrowser *viewFFmpeg = new QTextBrowser;
viewQtAV->setOpenExternalLinks(true);
viewFFmpeg->setOpenExternalLinks(true);
viewQtAV->setHtml(aboutQtAV_HTML());
viewFFmpeg->setHtml(aboutFFmpeg_HTML());
QTabWidget *tab = new QTabWidget;
tab->addTab(viewQtAV, "QtAV");
tab->addTab(viewFFmpeg, "FFmpeg");
QPushButton *btn = new QPushButton(QObject::tr("Ok"));
QHBoxLayout *btnLayout = new QHBoxLayout;
btnLayout->addStretch();
btnLayout->addWidget(btn);
QDialog dialog;
dialog.setWindowTitle(QObject::tr("About") " QtAV");
QVBoxLayout *layout = new QVBoxLayout;
dialog.setLayout(layout);
layout->addWidget(tab);
layout->addLayout(btnLayout);
QObject::connect(btn, SIGNAL(clicked()), &dialog, SLOT(accept()));
dialog.exec();
#else
aboutQtAV();
aboutFFmpeg();
#endif //QTAV_HAVE(WIDGETS)
}

void aboutFFmpeg()
{
#if QTAV_HAVE(WIDGETS)
QMessageBox::about(0, QObject::tr("About FFmpeg"), aboutFFmpeg_HTML());
#else
qDebug() << aboutFFmpeg_PlainText();
#endif
}

QString aboutFFmpeg_PlainText()
{
return aboutFFmpeg_HTML().remove(QRegExp("<[^>]*>"));
Expand Down Expand Up @@ -214,15 160,6 @@ QString aboutFFmpeg_HTML()
return text;
}

void aboutQtAV()
{
#if QTAV_HAVE(WIDGETS)
QMessageBox::about(0, QObject::tr("About QtAV"), aboutQtAV_HTML());
#else
qDebug() << aboutQtAV_PlainText();
#endif //QTAV_HAVE(WIDGETS)
}

QString aboutQtAV_PlainText()
{
return aboutQtAV_HTML().remove(QRegExp("<[^>]*>"));
Expand Down
Loading

0 comments on commit 192f22c

Please sign in to comment.