]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Fix crash on clip deletion, fix issues with placeholder clips
[kdenlive] / src / clipitem.cpp
index efb4c00c538cc4e28fb54dc04e028a5800376b0b..1aa2b203dcbd674b8ffb9a69edc65ad7d9c08e57 100644 (file)
@@ -68,52 +68,49 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
     m_videoPix = KIcon("kdenlive-show-video").pixmap(QSize(16, 16));
     m_audioPix = KIcon("kdenlive-show-audio").pixmap(QSize(16, 16));
 
-    if (m_speed == 1.0) m_clipName = clip->name();
+    if (m_speed == 1.0) m_clipName = m_clip->name();
     else {
-        m_clipName = clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
+        m_clipName = m_clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
     }
-    m_producer = clip->getId();
-    m_clipType = clip->clipType();
+    m_producer = m_clip->getId();
+    m_clipType = m_clip->clipType();
     //m_cropStart = info.cropStart;
-    m_maxDuration = clip->maxDuration();
+    m_maxDuration = m_clip->maxDuration();
     setAcceptDrops(true);
-    m_audioThumbReady = clip->audioThumbCreated();
+    m_audioThumbReady = m_clip->audioThumbCreated();
     //setAcceptsHoverEvents(true);
     connect(this , SIGNAL(prepareAudioThumb(double, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, int, int, int)));
 
     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
         m_baseColor = QColor(141, 166, 215);
-        m_hasThumbs = true;
-        m_startThumbTimer.setSingleShot(true);
-        connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
-        m_endThumbTimer.setSingleShot(true);
-        connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
-
-        connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
-        //connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(getVideoThumbs(int, int)));
-
-        connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
-        connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
-        if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
-
-        /*if (m_clip->producer()) {
-            videoThumbProducer.init(this, m_clip->producer(), KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio(), KdenliveSettings::trackheight());
-            slotFetchThumbs();
-        }*/
+        if (!m_clip->isPlaceHolder()) {
+            m_hasThumbs = true;
+            m_startThumbTimer.setSingleShot(true);
+            connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
+            m_endThumbTimer.setSingleShot(true);
+            connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
+
+            connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
+
+            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+            connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+            if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
+        }
+
     } else if (m_clipType == COLOR) {
-        QString colour = clip->getProperty("colour");
+        QString colour = m_clip->getProperty("colour");
         colour = colour.replace(0, 2, "#");
         m_baseColor = QColor(colour.left(7));
     } else if (m_clipType == IMAGE || m_clipType == TEXT) {
         m_baseColor = QColor(141, 166, 215);
         if (m_clipType == TEXT) {
-            connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
-            connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
+            connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
+            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
         }
         //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
     } else if (m_clipType == AUDIO) {
         m_baseColor = QColor(141, 215, 166);
-        connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+        connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
     }
 }
 
@@ -121,9 +118,10 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
 ClipItem::~ClipItem()
 {
     blockSignals(true);
+    if (scene()) scene()->removeItem(this);
     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
-        disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
-        disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+        //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+        //disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
     }
     delete m_timeLine;
 }
@@ -132,7 +130,7 @@ ClipItem *ClipItem::clone(ItemInfo info) const
 {
     ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed, m_strobe);
     if (m_clipType == IMAGE || m_clipType == TEXT) duplicate->slotSetStartThumb(m_startPix);
-    else {
+    else if (m_clipType != COLOR) {
         if (info.cropStart == m_info.cropStart) duplicate->slotSetStartThumb(m_startPix);
         if (info.cropStart + (info.endPos - info.startPos) == m_info.cropStart + (m_info.endPos - m_info.startPos)) duplicate->slotSetEndThumb(m_endPix);
     }
@@ -187,13 +185,13 @@ void ClipItem::initEffect(QDomElement effect, int diff)
             }
         }
 
-        if (!e.isNull() && e.attribute("type") == "keyframe") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             QString def = e.attribute("default");
             // Effect has a keyframe type parameter, we need to set the values
             if (e.attribute("keyframes").isEmpty()) {
                 e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + def + ';' + QString::number((cropStart() + cropDuration()).frames(m_fps) - 1) + ':' + def);
                 //kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
-                break;
+                //break;
             }
         }
     }
@@ -320,7 +318,7 @@ void ClipItem::setKeyframes(const int ix, const QString keyframes)
     QDomNodeList params = effect.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        if (!e.isNull() && e.attribute("type") == "keyframe") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             e.setAttribute("keyframes", keyframes);
             if (ix == m_selectedEffect) {
                 m_keyframes.clear();
@@ -328,6 +326,8 @@ void ClipItem::setKeyframes(const int ix, const QString keyframes)
                 double min = e.attribute("min").toDouble();
                 m_keyframeFactor = 100.0 / (max - min);
                 m_keyframeDefault = e.attribute("default").toDouble();
+                m_selectedKeyframe = 0;
+                m_editedKeyframe = -1;
                 // parse keyframes
                 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
                 foreach(const QString &str, keyframes) {
@@ -353,12 +353,14 @@ void ClipItem::setSelectedEffect(const int ix)
         if (effect.attribute("disabled") != "1")
             for (int i = 0; i < params.count(); i++) {
                 QDomElement e = params.item(i).toElement();
-                if (!e.isNull() && e.attribute("type") == "keyframe") {
+                if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
                     m_keyframes.clear();
                     double max = e.attribute("max").toDouble();
                     double min = e.attribute("min").toDouble();
                     m_keyframeFactor = 100.0 / (max - min);
                     m_keyframeDefault = e.attribute("default").toDouble();
+                    m_selectedKeyframe = 0;
+                    m_editedKeyframe = -1;
                     // parse keyframes
                     const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
                     foreach(const QString &str, keyframes) {
@@ -385,7 +387,7 @@ QString ClipItem::keyframes(const int index)
 
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        if (!e.isNull() && e.attribute("type") == "keyframe") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             result = e.attribute("keyframes");
             break;
         }
@@ -402,9 +404,9 @@ void ClipItem::updateKeyframeEffect()
 
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        if (!e.isNull() && e.attribute("type") == "keyframe") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             QString keyframes;
-            if (m_keyframes.count() > 1) {
+            if (m_keyframes.count() > 0) {
                 QMap<int, int>::const_iterator i = m_keyframes.constBegin();
                 while (i != m_keyframes.constEnd()) {
                     keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';');
@@ -463,6 +465,7 @@ void ClipItem::refreshClip(bool checkDuration)
 
 void ClipItem::slotFetchThumbs()
 {
+    if (scene() == NULL || m_clipType == AUDIO || m_clipType == COLOR) return;
     if (m_clipType == IMAGE) {
         if (m_startPix.isNull()) {
             m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
@@ -479,7 +482,7 @@ void ClipItem::slotFetchThumbs()
     if (m_endPix.isNull() && m_startPix.isNull()) {
         m_startThumbRequested = true;
         m_endThumbRequested = true;
-        emit getThumb((int)cropStart().frames(m_fps), (int)(cropStart() + cropDuration()).frames(m_fps) - 1);
+        emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
     } else {
         if (m_endPix.isNull()) {
             slotGetEndThumb();
@@ -488,35 +491,18 @@ void ClipItem::slotFetchThumbs()
             slotGetStartThumb();
         }
     }
-    /*
-        if (m_hasThumbs) {
-            if (m_endPix.isNull() && m_startPix.isNull()) {
-                int frame1 = (int)m_cropStart.frames(m_fps);
-                int frame2 = (int)(m_cropStart + m_cropDuration).frames(m_fps) - 1;
-                //videoThumbProducer.setThumbFrames(m_clip->producer(), frame1, frame2);
-                //videoThumbProducer.start(QThread::LowestPriority);
-            } else {
-                if (m_endPix.isNull()) slotGetEndThumb();
-                else slotGetStartThumb();
-            }
-
-        } else if (m_startPix.isNull()) slotGetStartThumb();*/
 }
 
 void ClipItem::slotGetStartThumb()
 {
     m_startThumbRequested = true;
-    emit getThumb((int)cropStart().frames(m_fps), -1);
-    //videoThumbProducer.setThumbFrames(m_clip->producer(), (int)m_cropStart.frames(m_fps),  - 1);
-    //videoThumbProducer.start(QThread::LowestPriority);
+    emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), -1);
 }
 
 void ClipItem::slotGetEndThumb()
 {
     m_endThumbRequested = true;
-    emit getThumb(-1, (int)(cropStart() + cropDuration()).frames(m_fps) - 1);
-    //videoThumbProducer.setThumbFrames(m_clip->producer(), -1, (int)(m_cropStart + m_cropDuration).frames(m_fps) - 1);
-    //videoThumbProducer.start(QThread::LowestPriority);
+    emit getThumb(-1, (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
 }
 
 
@@ -542,19 +528,20 @@ void ClipItem::slotSetEndThumb(QImage img)
     }
 }
 
-void ClipItem::slotThumbReady(int frame, QPixmap pix)
+void ClipItem::slotThumbReady(int frame, QImage img)
 {
     if (scene() == NULL) return;
     QRectF r = boundingRect();
+    QPixmap pix = QPixmap::fromImage(img);
     double width = pix.width() / projectScene()->scale().x();
-    if (m_startThumbRequested && frame == cropStart().frames(m_fps)) {
+    if (m_startThumbRequested && frame == m_speedIndependantInfo.cropStart.frames(m_fps)) {
         m_startPix = pix;
         m_startThumbRequested = false;
         update(r.left(), r.top(), width, pix.height());
         if (m_clipType == IMAGE || m_clipType == TEXT) {
             update(r.right() - width, r.top(), width, pix.height());
         }
-    } else if (m_endThumbRequested && frame == (cropStart() + cropDuration()).frames(m_fps) - 1) {
+    } else if (m_endThumbRequested && frame == (m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1) {
         m_endPix = pix;
         m_endThumbRequested = false;
         update(r.right() - width, r.top(), width, pix.height());
@@ -643,7 +630,7 @@ void ClipItem::flashClip()
     //m_timeLine->start();
 }
 
-void ClipItem::animate(qreal value)
+void ClipItem::animate(qreal /*value*/)
 {
     QRectF r = boundingRect();
     r.setHeight(20);
@@ -775,38 +762,38 @@ void ClipItem::paint(QPainter *painter,
 
 
     // draw markers
-    QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
-    QList < CommentedTime >::Iterator it = markers.begin();
-    GenTime pos;
-    double framepos;
-    QBrush markerBrush(QColor(120, 120, 0, 140));
-    QPen pen = painter->pen();
-    pen.setColor(QColor(255, 255, 255, 200));
-    pen.setStyle(Qt::DotLine);
-
-    for (; it != markers.end(); ++it) {
-        pos = GenTime((int)((*it).time().frames(m_fps) / m_speed + 0.5), m_fps) - cropStart();
-        if (pos > GenTime()) {
-            if (pos > cropDuration()) break;
-            QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
-            QLineF l2 = painter->matrix().map(l);
-            //framepos = scale * pos.frames(m_fps);
-            //QLineF l(framepos, 5, framepos, itemHeight - 5);
-            painter->setPen(pen);
-            painter->drawLine(l2);
-            if (KdenliveSettings::showmarkers()) {
-                framepos = rect().x() + pos.frames(m_fps);
-                const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
-                const QRectF r2 = painter->matrix().mapRect(r1);
-                const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
-                painter->setBrush(markerBrush);
-                painter->setPen(Qt::NoPen);
-                painter->drawRoundedRect(txtBounding3, 3, 3);
-                painter->setBrush(QBrush(Qt::NoBrush));
-                painter->setPen(Qt::white);
-                painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
+    if (isEnabled() && m_clip) {
+        QList < CommentedTime > markers = m_clip->commentedSnapMarkers();
+        QList < CommentedTime >::Iterator it = markers.begin();
+        GenTime pos;
+        double framepos;
+        QBrush markerBrush(QColor(120, 120, 0, 140));
+        QPen pen = painter->pen();
+        pen.setColor(QColor(255, 255, 255, 200));
+        pen.setStyle(Qt::DotLine);
+
+        for (; it != markers.end(); ++it) {
+            pos = GenTime((int)((*it).time().frames(m_fps) / m_speed + 0.5), m_fps) - cropStart();
+            if (pos > GenTime()) {
+                if (pos > cropDuration()) break;
+                QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
+                QLineF l2 = painter->matrix().map(l);
+                painter->setPen(pen);
+                painter->drawLine(l2);
+                if (KdenliveSettings::showmarkers()) {
+                    framepos = rect().x() + pos.frames(m_fps);
+                    const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
+                    const QRectF r2 = painter->matrix().mapRect(r1);
+                    const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
+                    painter->setBrush(markerBrush);
+                    painter->setPen(Qt::NoPen);
+                    painter->drawRoundedRect(txtBounding3, 3, 3);
+                    painter->setBrush(QBrush(Qt::NoBrush));
+                    painter->setPen(Qt::white);
+                    painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
+                }
+                //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
             }
-            //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
         }
     }
 
@@ -875,16 +862,20 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
 
     if (qAbs((int)(pos.x() - (rect.x() + m_startFade))) < maximumOffset  && qAbs((int)(pos.y() - rect.y())) < 6) {
         if (m_startFade == 0) setToolTip(i18n("Add audio fade"));
+        // xgettext:no-c-format
         else setToolTip(i18n("Audio fade duration: %1s", GenTime(m_startFade, m_fps).seconds()));
         return FADEIN;
     } else if (pos.x() - rect.x() < maximumOffset && (rect.bottom() - pos.y() > addtransitionOffset)) {
+        // xgettext:no-c-format
         setToolTip(i18n("Crop from start: %1s", cropStart().seconds()));
         return RESIZESTART;
     } else if (qAbs((int)(pos.x() - (rect.x() + rect.width() - m_endFade))) < maximumOffset && qAbs((int)(pos.y() - rect.y())) < 6) {
         if (m_endFade == 0) setToolTip(i18n("Add audio fade"));
+        // xgettext:no-c-format
         else setToolTip(i18n("Audio fade duration: %1s", GenTime(m_endFade, m_fps).seconds()));
         return FADEOUT;
     } else if ((rect.right() - pos.x() < maximumOffset) && (rect.bottom() - pos.y() > addtransitionOffset)) {
+        // xgettext:no-c-format
         setToolTip(i18n("Clip duration: %1s", cropDuration().seconds()));
         return RESIZEEND;
     } else if ((pos.x() - rect.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
@@ -1095,7 +1086,6 @@ void ClipItem::resizeStart(int posx)
 
     if ((int) cropStart().frames(m_fps) != previous) {
         if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
-            /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
             m_startThumbTimer.start(150);
         }
     }
@@ -1117,7 +1107,6 @@ void ClipItem::resizeEnd(int posx)
 
     if ((int) cropDuration().frames(m_fps) != previous) {
         if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
-            /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
             m_endThumbTimer.start(150);
         }
     }
@@ -1132,7 +1121,7 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
         QDomNodeList params = effect.elementsByTagName("parameter");
         for (int j = 0; j < params.count(); j++) {
             QDomElement e = params.item(i).toElement();
-            if (e.attribute("type") == "keyframe") {
+            if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
                 // parse keyframes and adjust values
                 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
                 QMap <int, double> kfr;
@@ -1171,6 +1160,10 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
 //virtual
 QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
 {
+    if (change == QGraphicsItem::ItemSelectedChange) {
+        if (value.toBool()) setZValue(10);
+        else setZValue(2);
+    }
     if (change == ItemPositionChange && scene()) {
         // calculate new position.
         //if (parentItem()) return pos();
@@ -1186,12 +1179,15 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
         // Only one clip is moving
         QRectF sceneShape = rect();
         sceneShape.translate(newPos);
-        QList<QGraphicsItem*> items = scene()->items(sceneShape, Qt::IntersectsItemShape);
+        QList<QGraphicsItem*> items;
+        if (projectScene()->editMode() == NORMALEDIT)
+            items = scene()->items(sceneShape, Qt::IntersectsItemShape);
         items.removeAll(this);
         bool forwardMove = newPos.x() > pos().x();
         int offset = 0;
         if (!items.isEmpty()) {
             for (int i = 0; i < items.count(); i++) {
+                if (!items.at(i)->isEnabled()) continue;
                 if (items.at(i)->type() == type()) {
                     // Collision!
                     QPointF otherPos = items.at(i)->pos();
@@ -1215,7 +1211,9 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
                         QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
                         subitems.removeAll(this);
                         for (int j = 0; j < subitems.count(); j++) {
+                            if (!subitems.at(j)->isEnabled()) continue;
                             if (subitems.at(j)->type() == type()) {
+                                // move was not successful, revert to previous pos
                                 m_info.startPos = GenTime((int) pos().x(), m_fps);
                                 return pos();
                             }
@@ -1224,6 +1222,7 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
 
                     m_info.track = newTrack;
                     m_info.startPos = GenTime((int) newPos.x(), m_fps);
+
                     return newPos;
                 }
             }
@@ -1274,7 +1273,7 @@ QDomElement ClipItem::getEffectAt(int ix) const
 
 void ClipItem::setEffectAt(int ix, QDomElement effect)
 {
-    if (ix < 0 || ix > (m_effectList.count() - 1)) {
+    if (ix < 0 || ix > (m_effectList.count() - 1) || effect.isNull()) {
         kDebug() << "Invalid effect index: " << ix;
         return;
     }
@@ -1292,7 +1291,7 @@ void ClipItem::setEffectAt(int ix, QDomElement effect)
     }
 }
 
-EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool animate)
+EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animate*/)
 {
     bool needRepaint = false;
     int ix;
@@ -1323,16 +1322,28 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool animate)
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull()) {
-            if (e.attribute("type") == "keyframe") {
+            if (e.attribute("type") == "simplekeyframe") {
+                QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+                double factor = e.attribute("factor", "1").toDouble();
+                if (factor != 1) {
+                    for (int j = 0; j < values.count(); j++) {
+                        QString pos = values.at(j).section(":", 0, 0);
+                        double val = values.at(j).section(":", 1, 1).toDouble() / factor;
+                        values[j] = pos + "=" + QString::number(val);
+                    }
+                }
+                parameters.addParam(e.attribute("name"), values.join(";"));
+                /*parameters.addParam("max", e.attribute("max"));
+                parameters.addParam("min", e.attribute("min"));
+                parameters.addParam("factor", );*/
+            } else if (e.attribute("type") == "keyframe") {
                 parameters.addParam("keyframes", e.attribute("keyframes"));
                 parameters.addParam("max", e.attribute("max"));
                 parameters.addParam("min", e.attribute("min"));
                 parameters.addParam("factor", e.attribute("factor", "1"));
                 parameters.addParam("starttag", e.attribute("starttag", "start"));
                 parameters.addParam("endtag", e.attribute("endtag", "end"));
-            }
-
-            if (e.attribute("factor", "1") == "1") {
+            } else if (e.attribute("factor", "1") == "1") {
                 parameters.addParam(e.attribute("name"), e.attribute("value"));
 
                 // check if it is a fade effect
@@ -1418,7 +1429,22 @@ EffectsParameterList ClipItem::getEffectArgs(const QDomElement effect)
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         //kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
-        if (e.attribute("type") == "keyframe") {
+        if (e.attribute("type") == "simplekeyframe") {
+
+            QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+            double factor = e.attribute("factor", "1").toDouble();
+            for (int j = 0; j < values.count(); j++) {
+                QString pos = values.at(j).section(":", 0, 0);
+                double val = values.at(j).section(":", 1, 1).toDouble() / factor;
+                values[j] = pos + "=" + QString::number(val);
+            }
+            // kDebug() << "/ / / /SENDING KEYFR:" << values;
+            parameters.addParam(e.attribute("name"), values.join(";"));
+            /*parameters.addParam(e.attribute("name"), e.attribute("keyframes").replace(":", "="));
+            parameters.addParam("max", e.attribute("max"));
+            parameters.addParam("min", e.attribute("min"));
+            parameters.addParam("factor", e.attribute("factor", "1"));*/
+        } else if (e.attribute("type") == "keyframe") {
             kDebug() << "/ / / /SENDING KEYFR EFFECT TYPE";
             parameters.addParam("keyframes", e.attribute("keyframes"));
             parameters.addParam("max", e.attribute("max"));
@@ -1581,7 +1607,14 @@ void ClipItem::setAudioOnly(bool force)
 {
     m_audioOnly = force;
     if (m_audioOnly) m_baseColor = QColor(141, 215, 166);
-    else m_baseColor = QColor(141, 166, 215);
+    else {
+        if (m_clipType == COLOR) {
+            QString colour = m_clip->getProperty("colour");
+            colour = colour.replace(0, 2, "#");
+            m_baseColor = QColor(colour.left(7));
+        } else if (m_clipType == AUDIO) m_baseColor = QColor(141, 215, 166);
+        else m_baseColor = QColor(141, 166, 215);
+    }
     m_audioThumbCachePic.clear();
 }