summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-06-05 11:55:33 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-06-05 11:58:44 +0300
commitb07ed2701e69a2ddf6f4626e9213272af5d0f06c (patch)
tree08fad2fc5ab1edbb410ebab8eae0efc4ed602277
parent23f1596e25cbea26e5bd0e7ead32b79bd91083e6 (diff)
qt5: Initial port to Qt5
Based on patches by: Tiago Salem Herrmann <tiago.herrmann@canonical.com> Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> Andoni Morales Alastruey <ylatuya@gmail.com> Luciana Fujii Pontello <luciana@fujii.eti.br>
-rw-r--r--elements/gstqtvideosink/autotest.cpp28
-rw-r--r--elements/gstqtvideosink/qwidgetvideosinkdelegate.cpp4
-rw-r--r--elements/gstqtvideosink/qwidgetvideosinkdelegate.h13
-rw-r--r--examples/player/main.cpp8
-rw-r--r--examples/player/mediaapp.cpp21
-rw-r--r--examples/player/mediaapp.h10
-rw-r--r--examples/recorder/main.cpp13
-rw-r--r--examples/voip/main.cpp9
-rw-r--r--src/QGlib/connect.cpp2
-rw-r--r--src/QGst/Ui/graphicsvideosurface.h7
-rw-r--r--src/QGst/Ui/graphicsvideowidget.h12
-rw-r--r--src/QGst/Ui/videowidget.cpp12
-rw-r--r--src/QGst/Ui/videowidget.h7
-rw-r--r--src/QGst/objectstore.cpp4
-rw-r--r--src/qml/plugin.cpp7
-rw-r--r--tests/manual/qwidgetvideosinktest.cpp6
-rw-r--r--tests/manual/videoorientationtest.cpp13
-rw-r--r--tests/manual/videowidgetpipelinetest.cpp9
-rw-r--r--tests/manual/videowidgettest.cpp13
19 files changed, 162 insertions, 36 deletions
diff --git a/elements/gstqtvideosink/autotest.cpp b/elements/gstqtvideosink/autotest.cpp
index 704f2bc..c998ae4 100644
--- a/elements/gstqtvideosink/autotest.cpp
+++ b/elements/gstqtvideosink/autotest.cpp
@@ -21,12 +21,24 @@
#include <gst/video/video.h>
#include <gst/interfaces/colorbalance.h>
#include <QtTest/QTest>
-#include <QtGui/QWidget>
#include <QtGui/QPainter>
-#include <QtGui/QLabel>
-#include <QtGui/QGridLayout>
#include <QtCore/QDebug>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QWidget>
+# include <QtWidgets/QLabel>
+# include <QtWidgets/QGridLayout>
+# define SkipSingle 0
+# define SkipAll 0
+# define QSKIP_PORT(m, a) QSKIP(m)
+#else
+# include <QtGui/QWidget>
+# include <QtGui/QLabel>
+# include <QtGui/QGridLayout>
+# define QSKIP_PORT(m, a) QSKIP(m, a)
+#endif
+
+
#ifndef GST_QT_VIDEO_SINK_NO_OPENGL
# include "openglsurfacepainter.h"
# include <QtOpenGL/QGLWidget>
@@ -429,11 +441,11 @@ void QtVideoSinkTest::glSurfacePainterFormatsTest()
QVERIFY(format != GST_VIDEO_FORMAT_UNKNOWN);
if (glsl && !haveGlsl) {
- QSKIP("Skipping because the system does not support GLSL", SkipSingle);
+ QSKIP_PORT("Skipping because the system does not support GLSL", SkipSingle);
}
if (!glsl && !haveArbFp) {
- QSKIP("Skipping because the system does not support ARB Fragment Programs", SkipSingle);
+ QSKIP_PORT("Skipping because the system does not support ARB Fragment Programs", SkipSingle);
}
GstCaps *caps = BufferFormat::newCaps(format, QSize(100, 100), Fraction(1, 1), Fraction(1, 1));
@@ -613,7 +625,7 @@ void QtVideoSinkTest::qtVideoSinkTest()
QVERIFY(context != 0);
} else
#endif
- QSKIP("Skipping because we have no OpenGL support", SkipSingle);
+ QSKIP_PORT("Skipping because we have no OpenGL support", SkipSingle);
} else {
widget.reset(new VideoWidget);
}
@@ -754,7 +766,11 @@ void QtVideoSinkTest::qtVideoSinkTest()
widget->show();
widget->raise();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+ QTest::qWaitForWindowActive(widget.data()->windowHandle());
+#else
QTest::qWaitForWindowShown(widget.data());
+#endif
GstStateChangeReturn stateReturn = gst_element_set_state(
GST_ELEMENT(pipeline.data()), GST_STATE_PAUSED);
diff --git a/elements/gstqtvideosink/qwidgetvideosinkdelegate.cpp b/elements/gstqtvideosink/qwidgetvideosinkdelegate.cpp
index 6773277..76f3b45 100644
--- a/elements/gstqtvideosink/qwidgetvideosinkdelegate.cpp
+++ b/elements/gstqtvideosink/qwidgetvideosinkdelegate.cpp
@@ -43,7 +43,11 @@ void QWidgetVideoSinkDelegate::setWidget(QWidget *widget)
m_widget.data()->setAttribute(Qt::WA_OpaquePaintEvent, m_opaquePaintEventAttribute);
m_widget.data()->update();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+ m_widget = NULL;
+#else
m_widget = QWeakPointer<QWidget>();
+#endif
}
if (widget) {
diff --git a/elements/gstqtvideosink/qwidgetvideosinkdelegate.h b/elements/gstqtvideosink/qwidgetvideosinkdelegate.h
index f324903..8849287 100644
--- a/elements/gstqtvideosink/qwidgetvideosinkdelegate.h
+++ b/elements/gstqtvideosink/qwidgetvideosinkdelegate.h
@@ -19,9 +19,14 @@
#define QWIDGET_VIDEO_SINK_DELEGATE_H
#include "qtvideosinkdelegate.h"
-#include <QtCore/QWeakPointer>
#include <QtCore/QEvent>
-#include <QtGui/QWidget>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtCore/QPointer>
+# include <QtWidgets/QWidget>
+#else
+# include <QtGui/QWidget>
+#endif
class QWidgetVideoSinkDelegate : public QtVideoSinkDelegate
{
@@ -40,7 +45,11 @@ protected:
private:
// "widget" property
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+ QPointer<QWidget> m_widget;
+#else
QWeakPointer<QWidget> m_widget;
+#endif
// original value of the Qt::WA_OpaquePaintEvent attribute
bool m_opaquePaintEventAttribute;
diff --git a/examples/player/main.cpp b/examples/player/main.cpp
index 959df1e..b02b0ba 100644
--- a/examples/player/main.cpp
+++ b/examples/player/main.cpp
@@ -15,7 +15,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mediaapp.h"
-#include <QtGui/QApplication>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QApplication>
+#else
+# include <QtGui/QApplication>
+#endif
+
#include <QGst/Init>
int main(int argc, char *argv[])
diff --git a/examples/player/mediaapp.cpp b/examples/player/mediaapp.cpp
index 1d6da91..ab07fff 100644
--- a/examples/player/mediaapp.cpp
+++ b/examples/player/mediaapp.cpp
@@ -18,12 +18,21 @@
*/
#include "mediaapp.h"
#include "player.h"
-#include <QtGui/QBoxLayout>
-#include <QtGui/QFileDialog>
-#include <QtGui/QToolButton>
-#include <QtGui/QLabel>
-#include <QtGui/QSlider>
-#include <QtGui/QMouseEvent>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QBoxLayout>
+# include <QtWidgets/QFileDialog>
+# include <QtWidgets/QToolButton>
+# include <QtWidgets/QLabel>
+# include <QtWidgets/QSlider>
+#else
+# include <QtGui/QBoxLayout>
+# include <QtGui/QFileDialog>
+# include <QtGui/QToolButton>
+# include <QtGui/QLabel>
+# include <QtGui/QSlider>
+# include <QtGui/QMouseEvent>
+#endif
MediaApp::MediaApp(QWidget *parent)
: QWidget(parent)
diff --git a/examples/player/mediaapp.h b/examples/player/mediaapp.h
index e4516ef..ff25f8f 100644
--- a/examples/player/mediaapp.h
+++ b/examples/player/mediaapp.h
@@ -19,10 +19,16 @@
#ifndef MEDIAAPP_H
#define MEDIAAPP_H
-#include <QtGui/QWidget>
-#include <QtGui/QStyle>
#include <QtCore/QTimer>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QWidget>
+# include <QtWidgets/QStyle>
+#else
+# include <QtGui/QWidget>
+# include <QtGui/QStyle>
+#endif
+
class Player;
class QBoxLayout;
class QLabel;
diff --git a/examples/recorder/main.cpp b/examples/recorder/main.cpp
index e5d99e3..6f7859f 100644
--- a/examples/recorder/main.cpp
+++ b/examples/recorder/main.cpp
@@ -18,9 +18,16 @@
#include "ui_recorder.h"
#include <QtCore/QDir>
-#include <QtGui/QApplication>
-#include <QtGui/QDialog>
-#include <QtGui/QMessageBox>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QApplication>
+# include <QtWidgets/QDialog>
+# include <QtWidgets/QMessageBox>
+#else
+# include <QtGui/QApplication>
+# include <QtGui/QDialog>
+# include <QtGui/QMessageBox>
+#endif
#include <QGlib/Error>
#include <QGlib/Connect>
diff --git a/examples/voip/main.cpp b/examples/voip/main.cpp
index f646164..ee8d56b 100644
--- a/examples/voip/main.cpp
+++ b/examples/voip/main.cpp
@@ -49,8 +49,13 @@
#include "ui_voip.h"
-#include <QtGui/QApplication>
-#include <QtGui/QDialog>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QApplication>
+# include <QtWidgets/QDialog>
+#else
+# include <QtGui/QApplication>
+# include <QtGui/QDialog>
+#endif
#include <QGlib/Connect>
#include <QGlib/Error>
diff --git a/src/QGlib/connect.cpp b/src/QGlib/connect.cpp
index d55f02e..9ff6fde 100644
--- a/src/QGlib/connect.cpp
+++ b/src/QGlib/connect.cpp
@@ -91,7 +91,7 @@ static void c_marshaller(GClosure *closure, GValue *returnValue, uint paramValue
"This is most likely a bug in the code that invoked the signal.");
}
} catch (...) {
- msg = QString::fromAscii(e.what());
+ msg = QString::fromLatin1(e.what());
}
}
diff --git a/src/QGst/Ui/graphicsvideosurface.h b/src/QGst/Ui/graphicsvideosurface.h
index c22b110..12134c9 100644
--- a/src/QGst/Ui/graphicsvideosurface.h
+++ b/src/QGst/Ui/graphicsvideosurface.h
@@ -20,7 +20,12 @@
#include "global.h"
#include "../element.h"
-#include <QtGui/QGraphicsView>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QGraphicsView>
+#else
+# include <QtGui/QGraphicsView>
+#endif
namespace QGst {
namespace Ui {
diff --git a/src/QGst/Ui/graphicsvideowidget.h b/src/QGst/Ui/graphicsvideowidget.h
index 0e195c8..7d53c52 100644
--- a/src/QGst/Ui/graphicsvideowidget.h
+++ b/src/QGst/Ui/graphicsvideowidget.h
@@ -19,7 +19,13 @@
#define QGST_UI_GRAPHICSVIDEOWIDGET_H
#include "graphicsvideosurface.h"
-#include <QtGui/QGraphicsWidget>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QGraphicsWidget>
+# include <QtCore/QPointer>
+#else
+# include <QtGui/QGraphicsWidget>
+#endif
namespace QGst {
namespace Ui {
@@ -50,7 +56,11 @@ public:
void setSurface(GraphicsVideoSurface *surface);
private:
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+ QPointer<GraphicsVideoSurface> m_surface;
+#else
QWeakPointer<GraphicsVideoSurface> m_surface;
+#endif
};
} // namespace Ui
diff --git a/src/QGst/Ui/videowidget.cpp b/src/QGst/Ui/videowidget.cpp
index 249054d..73fd61b 100644
--- a/src/QGst/Ui/videowidget.cpp
+++ b/src/QGst/Ui/videowidget.cpp
@@ -29,8 +29,14 @@
#include <QtGui/QPainter>
#include <QtGui/QPaintEvent>
#include <QtGui/QResizeEvent>
-#include <QtGui/QApplication>
-#include <QtGui/QHBoxLayout>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QApplication>
+# include <QtWidgets/QHBoxLayout>
+#else
+# include <QtGui/QApplication>
+# include <QtGui/QHBoxLayout>
+#endif
#ifndef QTGSTREAMER_UI_NO_OPENGL
# include <QtOpenGL/QGLWidget>
@@ -56,7 +62,9 @@ public:
: QObject(parent)
{
m_windowId = widget()->winId(); //create a new X window (if we are on X11 with alien widgets)
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QApplication::syncX(); //inform other applications about the new window (on X11)
+#endif
widget()->installEventFilter(this);
widget()->setAttribute(Qt::WA_NoSystemBackground, true);
diff --git a/src/QGst/Ui/videowidget.h b/src/QGst/Ui/videowidget.h
index 19c148a..76b3c90 100644
--- a/src/QGst/Ui/videowidget.h
+++ b/src/QGst/Ui/videowidget.h
@@ -21,7 +21,12 @@
#include "global.h"
#include "../element.h"
-#include <QtGui/QWidget>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QWidget>
+#else
+# include <QtGui/QWidget>
+#endif
namespace QGst {
namespace Ui {
diff --git a/src/QGst/objectstore.cpp b/src/QGst/objectstore.cpp
index d2bf2d3..236a733 100644
--- a/src/QGst/objectstore.cpp
+++ b/src/QGst/objectstore.cpp
@@ -70,7 +70,11 @@ bool ObjectStore::take(const void * ptr)
//Decrease our bindings (weak) reference count
(gs->refCount[ptr]).deref();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+ if (!gs->refCount[ptr].deref()) {
+#else
if (!gs->refCount[ptr]) {
+#endif
//refCount is 0
gs->refCount.remove(ptr);
mustSubtractStrongRef = true;
diff --git a/src/qml/plugin.cpp b/src/qml/plugin.cpp
index 2713939..0192797 100644
--- a/src/qml/plugin.cpp
+++ b/src/qml/plugin.cpp
@@ -18,9 +18,14 @@
#include "videoitem.h"
#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
+# define Q_PLUGIN_METADATA(x)
+#endif
+
class QtGStreamerPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.freedesktop.gstreamer.Qt5GStreamerDeclarative-0.10")
public:
void registerTypes(const char *uri);
};
@@ -32,6 +37,8 @@ void QtGStreamerPlugin::registerTypes(const char *uri)
QLatin1String("Creating a QGst::Ui::GraphicsVideoSurface from QML is not supported"));
}
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
Q_EXPORT_PLUGIN2(qtgstPlugin, QtGStreamerPlugin)
+#endif
#include "plugin.moc"
diff --git a/tests/manual/qwidgetvideosinktest.cpp b/tests/manual/qwidgetvideosinktest.cpp
index 1ddbf9d..f541348 100644
--- a/tests/manual/qwidgetvideosinktest.cpp
+++ b/tests/manual/qwidgetvideosinktest.cpp
@@ -18,8 +18,14 @@
#include <QGst/Init>
#include <QGst/Pipeline>
#include <QGst/ElementFactory>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QWidget>
+#else
#include <QtGui/QApplication>
#include <QtGui/QWidget>
+#endif
+
class QWidgetVideoSinkTest : public QWidget
{
diff --git a/tests/manual/videoorientationtest.cpp b/tests/manual/videoorientationtest.cpp
index 82f00f3..5658171 100644
--- a/tests/manual/videoorientationtest.cpp
+++ b/tests/manual/videoorientationtest.cpp
@@ -20,9 +20,16 @@
#include <QGst/Pipeline>
#include <QGst/ElementFactory>
#include <QGst/VideoOrientation>
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
-#include <QtGui/QCheckBox>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QApplication>
+# include <QtWidgets/QMessageBox>
+# include <QtWidgets/QCheckBox>
+#else
+# include <QtGui/QApplication>
+# include <QtGui/QMessageBox>
+# include <QtGui/QCheckBox>
+#endif
class VideoOrientationTest : public QWidget
{
diff --git a/tests/manual/videowidgetpipelinetest.cpp b/tests/manual/videowidgetpipelinetest.cpp
index bdd0f80..b3a19b0 100644
--- a/tests/manual/videowidgetpipelinetest.cpp
+++ b/tests/manual/videowidgetpipelinetest.cpp
@@ -19,7 +19,12 @@
#include <QGst/Init>
#include <QGst/Pipeline>
#include <QGst/ElementFactory>
-#include <QtGui/QApplication>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QApplication>
+#else
+# include <QtGui/QApplication>
+#endif
class VideoWidgetPipelineTest : public QWidget
{
@@ -69,4 +74,4 @@ int main(int argc, char **argv)
return app.exec();
}
-#include "videowidgetpipelinetest.moc" \ No newline at end of file
+#include "videowidgetpipelinetest.moc"
diff --git a/tests/manual/videowidgettest.cpp b/tests/manual/videowidgettest.cpp
index 863bfdb..0865b19 100644
--- a/tests/manual/videowidgettest.cpp
+++ b/tests/manual/videowidgettest.cpp
@@ -18,9 +18,16 @@
#include <QGst/Init>
#include <QGst/Pipeline>
#include <QGst/ElementFactory>
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
-#include <QtGui/QButtonGroup>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+# include <QtWidgets/QApplication>
+# include <QtWidgets/QMessageBox>
+# include <QtWidgets/QButtonGroup>
+#else
+# include <QtGui/QApplication>
+# include <QtGui/QMessageBox>
+# include <QtGui/QButtonGroup>
+#endif
class VideoWidgetTest : public QWidget
{