Remove old Qt checks, fix Rotoscoping (QGraphicsItem need to be added to...

Remove old Qt checks, fix Rotoscoping (QGraphicsItem need to be added to scene, cannot be passed in constructor anymore)
parent e9e43004
......@@ -71,15 +71,9 @@ QUrl SamplePlugin::generatedClip(const QString &renderer, const QString &generat
QProcess generatorProcess;
// Disable VDPAU so that rendering will work even if there is a Kdenlive instance using VDPAU
#if QT_VERSION >= 0x040600
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("MLT_NO_VDPAU"), QLatin1String("1"));
generatorProcess.setProcessEnvironment(env);
#else
QStringList env = QProcess::systemEnvironment();
env << QLatin1String("MLT_NO_VDPAU=1");
generatorProcess.setEnvironment(env);
#endif
QStringList args;
if (generator == i18n("Noise")) {
args << QLatin1String("noise:") << QLatin1String("in=0") << QLatin1String("out=") + QString::number((int) fps * view.duration->value());
......
......@@ -53,15 +53,9 @@ RenderJob::RenderJob(bool erase, bool usekuiserver, int pid, const QString& rend
m_renderProcess = new QProcess;
// Disable VDPAU so that rendering will work even if there is a Kdenlive instance using VDPAU
#if QT_VERSION >= 0x040600
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("MLT_NO_VDPAU"), QLatin1String("1"));
m_renderProcess->setProcessEnvironment(env);
#else
QStringList env = QProcess::systemEnvironment();
env << QLatin1String("MLT_NO_VDPAU=1");
m_renderProcess->setEnvironment(env);
#endif
m_prog = renderer;
m_args << scenelist;
......@@ -124,15 +118,9 @@ RenderJob::~RenderJob()
void RenderJob::setLocale(const QString &locale)
{
#if QT_VERSION >= 0x040600
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("LC_NUMERIC"), locale);
m_renderProcess->setProcessEnvironment(env);
#else
QStringList env = QProcess::systemEnvironment();
env << QString::fromLatin1("LC_NUMERIC=%1").arg(locale);
m_renderProcess->setEnvironment(env);
#endif
}
void RenderJob::slotAbort(const QString& url)
......
......@@ -1074,11 +1074,7 @@ void DocumentValidator::updateEffects()
{
// WARNING: order by findDirs will determine which js file to use (in case multiple scripts for the same filter exist)
QMap <QString, QUrl> paths;
#if QT_VERSION >= 0x040700
QMap <QString, QScriptProgram> scripts;
#else
QMap <QString, QString> scripts;
#endif
QStringList directories = QStandardPaths::locateAll(QStandardPaths::DataLocation, "effects/update");
foreach (const QString &directoryName, directories) {
QDir directory(directoryName);
......@@ -1125,11 +1121,7 @@ void DocumentValidator::updateEffects()
if (!scriptFile.open(QIODevice::ReadOnly)) {
continue;
}
#if QT_VERSION >= 0x040700
QScriptProgram scriptProgram(scriptFile.readAll());
#else
QString scriptProgram = scriptFile.readAll();
#endif
scriptFile.close();
scripts.insert(effectId, scriptProgram);
}
......
......@@ -103,12 +103,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
m_documentProperties["proxyminsize"] = QString::number(KdenliveSettings::proxyminsize());
m_documentProperties["generateimageproxy"] = QString::number((int) KdenliveSettings::generateimageproxy());
m_documentProperties["proxyimageminsize"] = QString::number(KdenliveSettings::proxyimageminsize());
#if QT_VERSION >= 0x040700
m_documentProperties["documentid"] = QString::number(QDateTime::currentMSecsSinceEpoch());
#else
QDateTime date = QDateTime::currentDateTime();
m_documentProperties["documentid"] = QString::number(date.toTime_t());
#endif
// Load properties
QMapIterator<QString, QString> i(properties);
......
......@@ -234,14 +234,8 @@ QImage KThumb::getFrame(Mlt::Frame *frame, int frameWidth, int displayWidth, int
} else {
image = image.scaled(displayWidth, height, Qt::IgnoreAspectRatio).rgbSwapped();
}
#if QT_VERSION >= 0x040800
p.fill(QColor(100, 100, 100, 70));
QPainter painter(&p);
#else
p.fill(Qt::transparent);
QPainter painter(&p);
painter.fillRect(p.rect(), QColor(100, 100, 100, 70));
#endif
painter.drawImage(p.rect(), image);
painter.end();
} else
......@@ -261,22 +255,14 @@ uint KThumb::imageVariance(const QImage &image )
// First pass: get pivots and taking average
for( uint i=0; i<STEPS ; ++i ){
pivot[i] = bits[2 * i];
#if QT_VERSION >= 0x040700
avg+=pivot.at(i);
#else
avg+=pivot[i];
#endif
}
if (STEPS)
avg=avg/STEPS;
// Second Step: calculate delta (average?)
for (uint i=0; i<STEPS; ++i)
{
#if QT_VERSION >= 0x040700
int curdelta=abs(int(avg - pivot.at(i)));
#else
int curdelta=abs(int(avg - pivot[i]));
#endif
delta+=curdelta;
}
if (STEPS)
......
......@@ -220,9 +220,6 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
p.setPen(QPen(Qt::red, 1, Qt::SolidLine));
QPolygonF handle = QPolygonF() << QPointF(0, -3) << QPointF(3, 0) << QPointF(0, 3) << QPointF(-3, 0);
#if QT_VERSION < 0x040600
QPolygonF tmp;
#endif
for (int i = 0; i <= max; ++i) {
point = m_spline.getPoint(i, wWidth, wHeight, true);
......@@ -240,22 +237,10 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
p.drawEllipse(QRectF(point.p.x() - 3,
point.p.y() - 3, 6, 6));
if (i != 0 && (i == m_currentPointIndex || m_showAllHandles)) {
#if QT_VERSION >= 0x040600
p.drawConvexPolygon(handle.translated(point.h1.x(), point.h1.y()));
#else
tmp = handle;
tmp.translate(point.h1.x(), point.h1.y());
p.drawConvexPolygon(tmp);
#endif
}
if (i != max && (i == m_currentPointIndex || m_showAllHandles)) {
#if QT_VERSION >= 0x040600
p.drawConvexPolygon(handle.translated(point.h2.x(), point.h2.y()));
#else
tmp = handle;
tmp.translate(point.h2.x(), point.h2.y());
p.drawConvexPolygon(tmp);
#endif
}
if ( i == m_currentPointIndex)
......
......@@ -2444,15 +2444,9 @@ void MainWindow::slotSaveZone(Render *render, const QPoint &zone, DocClipBase *b
if (baseClip && !baseClip->fileURL().isEmpty()) {
// create zone from clip url, so that we don't have problems with proxy clips
QProcess p;
#if QT_VERSION >= 0x040600
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("MLT_PROFILE");
p.setProcessEnvironment(env);
#else
QStringList env = QProcess::systemEnvironment();
env << "MLT_PROFILE='\0'";
p.setEnvironment(env);
#endif
p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
if (!p.waitForStarted(3000)) {
KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
......
......@@ -115,11 +115,7 @@ void VideoContainer::switchFullScreen()
if (!isFullScreen()) {
// Check if we ahave a multiple monitor setup
setUpdatesEnabled(false);
#if QT_VERSION >= 0x040600
int monitors = QApplication::desktop()->screenCount();
#else
int monitors = QApplication::desktop()->numScreens();
#endif
if (monitors > 1) {
QRect screenres;
// Move monitor widget to the second screen (one screen for Kdenlive, the other one for the Monitor widget
......
......@@ -140,7 +140,6 @@ RecMonitor::RecMonitor(Kdenlive::MonitorId name, MonitorManager *manager, QWidge
connect(m_captureProcess, SIGNAL(readyReadStandardError()), this, SLOT(slotReadProcessInfo()));
QString videoDriver = KdenliveSettings::videodrivername();
#if QT_VERSION >= 0x040600
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("SDL_WINDOWID", QString::number(videoSurface->winId()));
if (!videoDriver.isEmpty()) {
......@@ -150,18 +149,6 @@ RecMonitor::RecMonitor(Kdenlive::MonitorId name, MonitorManager *manager, QWidge
} else env.insert("SDL_VIDEODRIVER", videoDriver);
}
m_displayProcess->setProcessEnvironment(env);
#else
QStringList env = QProcess::systemEnvironment();
env << "SDL_WINDOWID=" + QString::number(videoSurface->winId());
if (!videoDriver.isEmpty()) {
if (videoDriver == "x11_noaccel") {
env << "SDL_VIDEO_YUV_HWACCEL=0";
env << "SDL_VIDEODRIVER=x11";
} else env << "SDL_VIDEODRIVER=" + videoDriver;
}
m_displayProcess->setEnvironment(env);
#endif
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1);
//qDebug() << "/////// BUILDING MONITOR, ID: " << videoSurface->winId();
......
......@@ -175,11 +175,7 @@ void VideoGLWidget::mouseDoubleClickEvent(QMouseEvent * event)
Qt::WindowFlags flags = windowFlags();
if (!isFullScreen()) {
// Check if we ahave a multiple monitor setup
#if QT_VERSION >= 0x040600
int monitors = QApplication::desktop()->screenCount();
#else
int monitors = QApplication::desktop()->numScreens();
#endif
if (monitors > 1) {
QRect screenres;
// Move monitor widget to the second screen (one screen for Kdenlive, the other one for the Monitor widget
......
......@@ -192,18 +192,10 @@ void OnMonitorRectItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
if (p - pos() != QPointF()) {
if (diffWidth > diffHeight) {
if (m_mode != ResizeBottomLeft)
#if QT_VERSION >= 0x040600
setY(p.y() - r.height() + rect().normalized().height());
#else
setPos(x(), p.y() - r.height() + rect().normalized().height());
#endif
} else {
if (m_mode != ResizeTopRight)
#if QT_VERSION >= 0x040600
setX(p.x() - r.width() + rect().normalized().width());
#else
setPos(p.x() - r.width() + rect().normalized().width(), y());
#endif
}
}
}
......
......@@ -90,19 +90,8 @@ void BPointItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option
painter->drawLine(m_point.h1, m_point.p);
painter->drawLine(m_point.p, m_point.h2);
#if QT_VERSION >= 0x040600
painter->drawConvexPolygon(handle.translated(m_point.h1.x(), m_point.h1.y()));
painter->drawConvexPolygon(handle.translated(m_point.h2.x(), m_point.h2.y()));
#else
QPolygonF tmp;
tmp = handle;
tmp.translate(m_point.h1.x(), m_point.h1.y());
painter->drawConvexPolygon(tmp);
tmp = handle;
tmp.translate(m_point.h2.x(), m_point.h2.y());
painter->drawConvexPolygon(tmp);
#endif
painter->drawEllipse(QRectF(m_point.p.x() - handleSizeHalf,
m_point.p.y() - handleSizeHalf, handleSize, handleSize));
}
......
......@@ -63,12 +63,17 @@ SplineItem::SplineItem(const QList< BPoint >& points, QGraphicsItem* parent, QGr
setPen(framepen);
setBrush(Qt::NoBrush);
setAcceptHoverEvents(true);
m_view = scene->views().first();
initSpline(scene, points);
}
void SplineItem::initSpline(QGraphicsScene *scene, const QList< BPoint >& points)
{
scene->addItem(this);
setPoints(points);
}
int SplineItem::type() const
{
return Type;
......@@ -163,26 +168,8 @@ void SplineItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
i1->setPoint(p1);
i2->setPoint(p2);
#if QT_VERSION >= 0x040600
BPointItem *i = new BPointItem(p, this);
i->stackBefore(i2);
#else
QList <BPoint> points;
while (childItems().count()) {
BPointItem *item = qgraphicsitem_cast<BPointItem *>(childItems().takeFirst());
points.append(item->getPoint());
delete item;
}
int j = 0;
for ( ; j < points.count(); ++j) {
if (j == ix + 1)
new BPointItem(p, this);
new BPointItem(points.at(j), this);
}
if (j == ix + 1)
new BPointItem(p, this);
#endif
updateSpline();
}
} else {
......@@ -262,12 +249,7 @@ int SplineItem::getClosestPointOnCurve(const QPointF &point, double *tFinal)
p2 = qgraphicsitem_cast<BPointItem *>(items.at(j))->getPoint();
QPolygonF bounding = QPolygonF() << p1.p << p1.h2 << p2.h1 << p2.p;
QPointF cl = closestPointInRect(point, bounding.boundingRect());
#if QT_VERSION >= 0x040600
qreal d = (point - cl).manhattanLength();
#else
qreal d = qAbs((point - cl).x()) + qAbs((point - cl).y());
#endif
if (d > diff)
continue;
......@@ -289,12 +271,7 @@ int SplineItem::getClosestPointOnCurve(const QPointF &point, double *tFinal)
Point2 n = NearestPointOnCurve(p, b, &t);
cl.setX(n.x);
cl.setY(n.y);
#if QT_VERSION >= 0x040600
d = (point - cl).manhattanLength();
#else
d = qAbs((point - cl).x()) + qAbs((point - cl).y());
#endif
if (d < diff) {
diff = d;
param = t;
......
......@@ -36,7 +36,7 @@ public:
virtual int type() const;
bool editing() const;
void initSpline(QGraphicsScene *scene, const QList< BPoint >& points);
void updateSpline(bool editing = false);
QList <BPoint> getPoints() const;
void setPoints(const QList <BPoint> &points);
......
......@@ -45,10 +45,8 @@ AbstractClipItem::AbstractClipItem(const ItemInfo &info, const QRectF& rect, dou
, m_isMainSelectedClip(false)
{
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
#endif
}
AbstractClipItem::~AbstractClipItem()
......@@ -57,7 +55,6 @@ AbstractClipItem::~AbstractClipItem()
void AbstractClipItem::closeAnimation()
{
#if QT_VERSION >= 0x040600
if (!isEnabled()) return;
setEnabled(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
......@@ -86,7 +83,6 @@ void AbstractClipItem::closeAnimation()
group->addAnimation(closeAnimation);
group->addAnimation(closeAnimation2);
group->start(QAbstractAnimation::DeleteWhenStopped);
#endif
}
ItemInfo AbstractClipItem::info() const
......
......@@ -40,9 +40,7 @@ AbstractGroupItem::AbstractGroupItem(double /* fps */) :
{
setZValue(1);
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
#endif
setAcceptDrops(true);
m_resizeInfos = QList <ItemInfo>();
}
......
......@@ -57,9 +57,7 @@
#include <QApplication>
#include <QMimeData>
#if QT_VERSION >= 0x040600
#include <QGraphicsDropShadowEffect>
#endif
#define SEEK_INACTIVE (-1)
......@@ -836,7 +834,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
m_dragItem = NULL;
}
#if QT_VERSION >= 0x040800
// Add shadow to dragged item, currently disabled because of painting artifacts
/*if (m_dragItem) {
QGraphicsDropShadowEffect *eff = new QGraphicsDropShadowEffect();
......@@ -844,7 +841,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
eff->setOffset(3, 3);
m_dragItem->setGraphicsEffect(eff);
}*/
#endif
if (m_dragItem && m_dragItem->type() == TransitionWidget && m_dragItem->isEnabled()) {
// update transition menu action
m_autoTransition->setChecked(static_cast<Transition *>(m_dragItem)->isAutomatic());
......@@ -2590,12 +2586,8 @@ void CustomTrackView::deleteTransition(const ItemInfo &transitionInfo, int endTr
m_document->renderer()->mltDeleteTransition(item->transitionTag(), endTrack, m_document->tracksCount() - transitionInfo.track, transitionInfo.startPos, transitionInfo.endPos, item->toXML(), refresh);
if (m_dragItem == item) m_dragItem = NULL;
#if QT_VERSION >= 0x040600
// animate item deletion
item->closeAnimation();
#else
delete item;
#endif
emit transitionItemSelected(NULL);
setDocumentModified();
}
......@@ -3574,11 +3566,9 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
}
m_clipDrag = false;
//setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
#if QT_VERSION >= 0x040800
if (m_dragItem) {
m_dragItem->setGraphicsEffect(NULL);
}
#endif
if (m_scrollTimer.isActive()) m_scrollTimer.stop();
if (event->button() == Qt::MidButton) {
return;
......@@ -4159,7 +4149,6 @@ void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
if (m_dragItem == item) m_dragItem = NULL;
#if QT_VERSION >= 0x040600
// animate item deletion
item->closeAnimation();
/*if (refresh) item->closeAnimation();
......@@ -4169,10 +4158,6 @@ void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
delete item;
item = NULL;
}*/
#else
delete item;
item = NULL;
#endif
setDocumentModified();
if (refresh) m_document->renderer()->doRefresh();
......
......@@ -28,9 +28,7 @@
#include <QDomElement>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#if QT_VERSION >= 0x040600
#include <QPropertyAnimation>
#endif
#include <klocalizedstring.h>
Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, const QDomElement &params, bool automaticTransition) :
......@@ -43,7 +41,6 @@ Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, co
m_info.cropDuration = info.endPos - info.startPos;
setPos(info.startPos.frames(fps), (int)(info.track * KdenliveSettings::trackheight() + itemOffset() + 1));
#if QT_VERSION >= 0x040600
if (QApplication::activeWindow()->style()->styleHint(QStyle::SH_Widget_Animate, 0, QApplication::activeWindow())) {
// animation disabled
setRect(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal) itemHeight());
......@@ -58,9 +55,6 @@ Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, co
startAnimation->setEasingCurve(QEasingCurve::OutQuad);
startAnimation->start(QAbstractAnimation::DeleteWhenStopped);
}
#else
setRect(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal) itemHeight());
#endif
m_info.cropStart = GenTime();
m_maxDuration = GenTime(600);
......
......@@ -41,11 +41,9 @@
#include <QTextCursor>
#include <locale.h>
#if QT_VERSION >= 0x040600
#include <QGraphicsEffect>
#include <QGraphicsBlurEffect>
#include <QGraphicsDropShadowEffect>
#endif
QByteArray fileToByteArray(const QString& filename)
{
......@@ -225,7 +223,6 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en
e.setAttribute("z-index", item->zValue());
pos.appendChild(tr);
#if QT_VERSION >= 0x040600
// effects
QGraphicsEffect *eff = item->graphicsEffect();
if (eff) {
......@@ -246,7 +243,6 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en
}*/
e.appendChild(effect);
}
#endif
e.appendChild(pos);
e.appendChild(content);
......@@ -486,7 +482,6 @@ int TitleDocument::loadFromXml(const QDomDocument& doc, QGraphicsRectItem* start
gitem->setZValue(zValue);
gitem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
// effects
QDomNode eff = items.item(i).namedItem("effect");
if (!eff.isNull()) {
......@@ -502,7 +497,6 @@ int TitleDocument::loadFromXml(const QDomDocument& doc, QGraphicsRectItem* start
gitem->setGraphicsEffect(shadow);
}
}
#endif
}
if (items.item(i).nodeName() == "background") {
......
......@@ -39,11 +39,9 @@
#include <QCryptographicHash>
#include <QKeyEvent>
#if QT_VERSION >= 0x040600
#include <QGraphicsEffect>
#include <QGraphicsBlurEffect>
#include <QGraphicsDropShadowEffect>
#endif
#include <iostream>
#include <QStandardPaths>
......
......@@ -130,21 +130,13 @@ uint MltPreview::imageVariance(const QImage &image)
// First pass: get pivots and taking average
for( uint i=0; i<STEPS ; i++ ){
pivot[i] = bits[2 * i];
#if QT_VERSION >= 0x040700
avg+=pivot.at(i);
#else
avg+=pivot[i];
#endif
}
avg=avg/STEPS;
// Second Step: calculate delta (average?)
for (uint i=0; i<STEPS; ++i)
{
#if QT_VERSION >= 0x040700
int curdelta=abs(int(avg - pivot.at(i)));
#else
int curdelta=abs(int(avg - pivot[i]));
#endif
delta+=curdelta;
}
return delta / STEPS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment