From: Jean-Baptiste Mardelle Date: Sun, 13 Nov 2011 14:17:52 +0000 (+0100) Subject: Fix transitions not appearing in timeline because QPropertyAnimation seems broken... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b284a0f9772513aa917c6b1bb15216e9b0ebf49a;p=kdenlive Fix transitions not appearing in timeline because QPropertyAnimation seems broken (disabled) since this commit: http://quickgit.kde.org/?p=kdenlive.git&a=commit&h=87914857d36c5b051b006f3f74d489af3801af4d --- diff --git a/src/abstractclipitem.cpp b/src/abstractclipitem.cpp index 434f44a7..50290cb1 100644 --- a/src/abstractclipitem.cpp +++ b/src/abstractclipitem.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -38,9 +39,6 @@ AbstractClipItem::AbstractClipItem(const ItemInfo &info, const QRectF& rect, dou m_keyframeFactor(1), m_keyframeOffset(0), m_fps(fps) -#if QT_VERSION >= 0x040600 - , m_closeAnimation(NULL) -#endif { setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); #if QT_VERSION >= 0x040600 @@ -51,29 +49,31 @@ AbstractClipItem::AbstractClipItem(const ItemInfo &info, const QRectF& rect, dou AbstractClipItem::~AbstractClipItem() { -#if QT_VERSION >= 0x040600 - if (m_closeAnimation) delete m_closeAnimation; -#endif } void AbstractClipItem::closeAnimation() { #if QT_VERSION >= 0x040600 - if (m_closeAnimation) return; + if (!isEnabled()) return; setEnabled(false); - m_closeAnimation = new QPropertyAnimation(this, "rect"); - connect(m_closeAnimation, SIGNAL(finished()), this, SLOT(deleteLater())); - m_closeAnimation->setDuration(200); + if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) { + // animation disabled + deleteLater(); + return; + } + QPropertyAnimation *closeAnimation = new QPropertyAnimation(this, "rect"); + connect(closeAnimation, SIGNAL(finished()), this, SLOT(deleteLater())); + closeAnimation->setDuration(200); QRectF r = rect(); QRectF r2 = r; r2.setLeft(r.left() + r.width() / 2); r2.setTop(r.top() + r.height() / 2); r2.setWidth(1); r2.setHeight(1); - m_closeAnimation->setStartValue(r); - m_closeAnimation->setEndValue(r2); - m_closeAnimation->setEasingCurve(QEasingCurve::InQuad); - m_closeAnimation->start(); + closeAnimation->setStartValue(r); + closeAnimation->setEndValue(r2); + closeAnimation->setEasingCurve(QEasingCurve::InQuad); + closeAnimation->start(QAbstractAnimation::DeleteWhenStopped); #endif } diff --git a/src/abstractclipitem.h b/src/abstractclipitem.h index c621c8cd..060d538e 100644 --- a/src/abstractclipitem.h +++ b/src/abstractclipitem.h @@ -125,10 +125,6 @@ protected: int mouseOverKeyFrames(QPointF pos, double maxOffset); virtual void mousePressEvent(QGraphicsSceneMouseEvent * event); -private: -#if QT_VERSION >= 0x040600 - QPropertyAnimation *m_closeAnimation; -#endif }; #endif diff --git a/src/transition.cpp b/src/transition.cpp index fe3aa518..a43a8ce8 100644 --- a/src/transition.cpp +++ b/src/transition.cpp @@ -29,6 +29,7 @@ #include #include #include +#include Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, QDomElement params, bool automaticTransition) : @@ -43,14 +44,20 @@ Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, QD setPos(info.startPos.frames(fps), (int)(info.track * KdenliveSettings::trackheight() + itemOffset() + 1)); #if QT_VERSION >= 0x040600 - m_startAnimation = new QPropertyAnimation(this, "rect"); - m_startAnimation->setDuration(200); - QRectF r(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal) itemHeight() / 2); - QRectF r2(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal)itemHeight()); - m_startAnimation->setStartValue(r); - m_startAnimation->setEndValue(r2); - m_startAnimation->setEasingCurve(QEasingCurve::OutQuad); - m_startAnimation->start(); + if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) { + // animation disabled + setRect(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal) itemHeight()); + } + else { + QPropertyAnimation *startAnimation = new QPropertyAnimation(this, "rect"); + startAnimation->setDuration(200); + QRectF r(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal) itemHeight() / 2); + QRectF r2(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal)itemHeight()); + startAnimation->setStartValue(r); + startAnimation->setEndValue(r2); + startAnimation->setEasingCurve(QEasingCurve::OutQuad); + startAnimation->start(QAbstractAnimation::DeleteWhenStopped); + } #else setRect(0, 0, m_info.cropDuration.frames(fps) - 0.02, (qreal) itemHeight()); #endif @@ -79,9 +86,6 @@ Transition::Transition(const ItemInfo &info, int transitiontrack, double fps, QD Transition::~Transition() { blockSignals(true); -#if QT_VERSION >= 0x040600 - delete m_startAnimation; -#endif if (scene()) scene()->removeItem(this); } diff --git a/src/transition.h b/src/transition.h index 7ffdc6c9..49b90e06 100644 --- a/src/transition.h +++ b/src/transition.h @@ -82,7 +82,7 @@ public: int defaultZValue() const; /** @brief When a transition is resized, check if keyframes are out of the transition and fix if necessary. */ bool updateKeyframes(); - + void animate(); protected: virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); @@ -108,10 +108,6 @@ private: /** @brief Returns the transition type for a given name. */ TRANSITIONTYPE getTransitionForName(const QString & type); - -#if QT_VERSION >= 0x040600 - QPropertyAnimation *m_startAnimation; -#endif }; #endif