Skip to content

Commit

Permalink
fix old qt version build error
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 7, 2015
1 parent f2b91a3 commit a0cefa6
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 21 deletions.
20 changes: 20 additions & 0 deletions examples/QMLPlayer/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
/******************************************************************************
Simple Player: this file is part of QtAV examples
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <cmath>
#include <QtCore/QtDebug>
#include <QtCore/QFile>
#include <QtGui/QGuiApplication>
#include <QQuickItem>
Expand Down
2 changes: 1 addition & 1 deletion examples/QMLPlayer/qml/QMLPlayer/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/

import QtQuick 2.1
import QtQuick 2.0
import QtQuick.Dialogs 1.0
//import QtMultimedia 5.0
import QtAV 1.5
Expand Down
5 changes: 3 additions & 2 deletions qml/MediaMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "QmlAV/MediaMetaData.h"
#include <QtCore/QFile>
#include <QtCore/QMetaEnum>
#include <QtCore/QStringList>
#include <QtAV/Statistics.h>

using namespace QtAV;
Expand Down Expand Up @@ -70,8 +71,8 @@ void MediaMetaData::setValuesFromStatistics(const QtAV::Statistics &st)
setValue(TrackNumber, it.value().toInt());
continue;
}
setValue(TrackNumber, it.value().leftRef(slash).toInt());
setValue(TrackCount, it.value().midRef(slash+1).toInt());
setValue(TrackNumber, it.value().leftRef(slash).string()->toInt()); //QStringRef.toInt(): Qt5.2
setValue(TrackCount, it.value().midRef(slash+1).string()->toInt());
continue;
}
if (keyName == QStringLiteral("date")
Expand Down
5 changes: 3 additions & 2 deletions qml/QmlAV/QmlAVPlayer.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) 2013 Wang Bin <[email protected]>
Copyright (C) 2013-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -23,7 +23,8 @@
#define QTAV_QML_AVPLAYER_H

#include <QtCore/QObject>
#include <QmlAV/QQuickItemRenderer.h>
#include <QtCore/QStringList> //5.0
#include <QtQml/QQmlParserStatus>
#include <QmlAV/MediaMetaData.h>
#include <QtAV/AVError.h>
#include <QtAV/CommonTypes.h>
Expand Down
3 changes: 1 addition & 2 deletions qml/QmlAVPlayer.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) 2013-2014 Wang Bin <[email protected]>
Copyright (C) 2013-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -137,7 +137,6 @@ void QmlAVPlayer::setSource(const QUrl &url)
if (mSource == url)
return;
mSource = url;
qDebug() << url;
mpPlayer->setFile(QUrl::fromPercentEncoding(mSource.toEncoded()));
emit sourceChanged(); //TODO: emit only when player loaded a new source

Expand Down
1 change: 1 addition & 0 deletions qml/QuickFBORenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "QtAV/private/VideoRenderer_p.h"
#include "QtAV/private/mkid.h"
#include "QtAV/private/prepost.h"
#include <QtCore/QCoreApplication>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtQuick/QQuickWindow>

Expand Down
1 change: 1 addition & 0 deletions qml/QuickSubtitle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "QmlAV/QuickSubtitle.h"
#include "QmlAV/QmlAVPlayer.h"
#include <QtAV/Filter.h>
#include <QtAV/VideoFrame.h>
#include <QtAV/private/PlayerSubtitle.h>

using namespace QtAV;
Expand Down
1 change: 0 additions & 1 deletion qml/QuickVideoPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void QuickVideoPreview::setFile(const QUrl &value)
{
if (m_file == value)
return;
qDebug() << value;
m_file = value;
emit fileChanged();
m_extractor.setSource(QUrl::fromPercentEncoding(m_file.toEncoded()));
Expand Down
9 changes: 8 additions & 1 deletion qml/libQmlAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ CONFIG *= qmlav-buildlib
#http://qt-project.org/forums/viewthread/38438
# mkspecs/features/qml_plugin.prf
URI = QtAV #uri used in QtAVQmlPlugin::registerTypes(uri)
greaterThan(QT_MAJOR_VERSION, 4) {
isEqual(QT_MAJOR_VERSION, 5) {
greaterThan(QT_MINOR_VERSION, 2) {
QMAKE_MOC_OPTIONS += -Muri=$$URI # not sure what moc does

}
} else {
QMAKE_MOC_OPTIONS += -Muri=$$URI # not sure what moc does
}
}
#var with '_' can not pass to pri?
STATICLINK = 0
PROJECTROOT = $$PWD/..
Expand Down
11 changes: 2 additions & 9 deletions src/QtAV/private/factory.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
Factory: factory template
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -34,8 +34,6 @@
#include <string>
#include <vector>
#include <algorithm> //std::remove
//#include <qglobal.h> //TODO: no qt

#include "singleton.h"
#if 0
#include <loki/Singleton.h>
Expand All @@ -56,12 +54,7 @@ class Factory : public Singleton<Class>
DISABLE_COPY(Factory)
typedef Id ID;
typedef T Type;
#if defined(Q_COMPILER_LAMBDA) && !defined(Q_CC_MSVC)
#include <functional>
typedef std::function<Type*()> Creator; //vc does not have std::function?
#else
typedef Type* (*Creator)();
#endif //defined(Q_COMPILER_LAMBDA)
typedef Type* (*Creator)();
public:
virtual void init() {}
Type* create(const ID& id);
Expand Down
4 changes: 1 addition & 3 deletions src/QtAV/private/singleton.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
singleton.h: singleton template
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -24,11 +24,9 @@
#include <cstdlib> //harmattan: atexit
#include <iostream>
#include <cassert>
//#include <qglobal.h> //TODO: no qt
#ifndef QT_NO_EXCEPTIONS
#include <stdexcept>
#endif

#define DEBUG 0
#if DEBUG
#define DBG(fmt, ...) \
Expand Down
8 changes: 8 additions & 0 deletions widgets/QOpenGLWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,12 @@ void QOpenGLWidget::initialize()
return;
}
m_paintDevice = new QOpenGLWidgetPaintDevice(this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
m_paintDevice->setSize(size() * devicePixelRatio());
m_paintDevice->setDevicePixelRatio(devicePixelRatio());
#else
m_paintDevice->setSize(size());
#endif
m_initialized = true;
initializeGL();
}
Expand All @@ -201,7 +205,11 @@ void QOpenGLWidget::render()

void QOpenGLWidget::invokeUserPaint()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 1 , 0)
DYGL(glViewport(0, 0, width()*devicePixelRatio(), height()*devicePixelRatio()));
#else
DYGL(glViewport(0, 0, width(), height()));
#endif
paintGL();
DYGL(glFlush());
}
Expand Down

0 comments on commit a0cefa6

Please sign in to comment.