]> git.sesse.net Git - kdenlive/commitdiff
Fix transitions not appearing in timeline because QPropertyAnimation seems broken...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 13 Nov 2011 14:17:52 +0000 (15:17 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 13 Nov 2011 14:17:52 +0000 (15:17 +0100)
http://quickgit.kde.org/?p=kdenlive.git&a=commit&h=87914857d36c5b051b006f3f74d489af3801af4d

src/abstractclipitem.cpp
src/abstractclipitem.h
src/transition.cpp
src/transition.h

index 434f44a74b9478d0f4eabb6fa96beb1460437d91..50290cb154cf724a32d0a1d7d245cf562a70ea29 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <KDebug>
 #include <KLocale>
+#include <KGlobalSettings>
 
 #include <QPainter>
 #include <QToolTip>
@@ -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
 }
 
index c621c8cdcf1d361e4900979cb1a1e163d68ca64a..060d538e1b5aa6e28994bc4454988186bda4a1e9 100644 (file)
@@ -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
index fe3aa518e7c265bbb993e780ea97f5adebadcdb6..a43a8ce8c1beff1c1db562020c4bbc6cc07f61de 100644 (file)
@@ -29,6 +29,7 @@
 #include <QDomElement>
 #include <QPainter>
 #include <QStyleOptionGraphicsItem>
+#include <QPropertyAnimation>
 
 
 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);
 }
 
index 7ffdc6c98d72f6ebabc17d739d3fd6791a1d8d6d..49b90e0637dee857ee7dc70ac2f4aaf8a31fa5e5 100644 (file)
@@ -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