]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
Add proper support for 'float' parameter type in effect's drag widget (required for...
[kdenlive] / src / customtrackview.cpp
index 17ba812b6c54a64723cf835625cdc7f854071453..1ce7d165bb88db66b84e3e32ec821ff43c49ad68 100644 (file)
@@ -142,7 +142,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
 
     m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
 
-    pixmapCache = new KPixmapCache("kdenlive-thumbs");
+    m_pixmapCache = new KPixmapCache("kdenlive-thumbs");
 
     m_animationTimer = new QTimeLine(800);
     m_animationTimer->setFrameRange(0, 5);
@@ -188,6 +188,8 @@ CustomTrackView::~CustomTrackView()
     qDeleteAll(m_guides);
     m_guides.clear();
     m_waitingThumbs.clear();
+    delete m_pixmapCache;
+    delete m_animationTimer;
 }
 
 //virtual
@@ -334,7 +336,7 @@ void CustomTrackView::slotFetchNextThumbs()
 {
     if (!m_waitingThumbs.isEmpty()) {
         ClipItem *item = m_waitingThumbs.takeFirst();
-        while ((item == NULL) && !m_waitingThumbs.isEmpty()) {
+        while (item == NULL && !m_waitingThumbs.isEmpty()) {
             item = m_waitingThumbs.takeFirst();
         }
         if (item) item->slotFetchThumbs();
@@ -373,6 +375,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
 {
     int pos = event->x();
     int mappedXPos = qMax((int)(mapToScene(event->pos()).x() + 0.5), 0);
+   
     double snappedPos = getSnapPointForPos(mappedXPos);
     emit mousePosition(mappedXPos);
 
@@ -594,11 +597,14 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
         }
         m_moveOpMode = opMode;
         setTipAnimation(clip, opMode, size);
+        ClipItem *ci = NULL;
+        if (item->type() == AVWIDGET)
+            ci = static_cast <ClipItem *>(item);
+        QString message;
         if (opMode == MOVE) {
             setCursor(Qt::OpenHandCursor);
-            if (item->type() == AVWIDGET) {
-                ClipItem *ci = static_cast <ClipItem *>(item);
-                QString message = ci->clipName() + i18n(":");
+            if (ci) {
+                message = ci->clipName() + i18n(":");
                 message.append(i18n(" Position:") + m_document->timecode().getDisplayTimecode(ci->info().startPos, KdenliveSettings::frametimecode()));
                 message.append(i18n(" Duration:") + m_document->timecode().getDisplayTimecode(ci->cropDuration(),  KdenliveSettings::frametimecode()));
                 if (clip->parentItem() && clip->parentItem()->type() == GROUPWIDGET) {
@@ -613,26 +619,40 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                         message.append(i18n(" Selection duration:") + m_document->timecode().getDisplayTimecode(parent2->duration(), KdenliveSettings::frametimecode()));
                     }
                 }
-                emit displayMessage(message, InformationMessage);
             }
         } else if (opMode == RESIZESTART) {
             setCursor(KCursor("left_side", Qt::SizeHorCursor));
+            if (ci)
+                message = i18n("Crop from start: ") + m_document->timecode().getDisplayTimecode(ci->cropStart(), KdenliveSettings::frametimecode());
             if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
-                emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+                message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
         } else if (opMode == RESIZEEND) {
             setCursor(KCursor("right_side", Qt::SizeHorCursor));
+            if (ci)
+                message = i18n("Duration: ") + m_document->timecode().getDisplayTimecode(ci->cropDuration(), KdenliveSettings::frametimecode());
             if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
-                emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+                message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
         } else if (opMode == FADEIN || opMode == FADEOUT) {
             setCursor(Qt::PointingHandCursor);
-            emit displayMessage(i18n("Drag to add or resize a fade effect."), InformationMessage);
+            if (ci && opMode == FADEIN && ci->fadeIn()) {
+                message = i18n("Fade in duration: ");
+                message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeIn(), KdenliveSettings::frametimecode()));
+            } else if (ci && opMode == FADEOUT && ci->fadeOut()) {
+                message = i18n("Fade out duration: ");
+                message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeOut(), KdenliveSettings::frametimecode()));
+            } else {
+                message = i18n("Drag to add or resize a fade effect.");
+            }
         } else if (opMode == TRANSITIONSTART || opMode == TRANSITIONEND) {
             setCursor(Qt::PointingHandCursor);
-            emit displayMessage(i18n("Click to add a transition."), InformationMessage);
+            message = i18n("Click to add a transition.");
         } else if (opMode == KEYFRAME) {
             setCursor(Qt::PointingHandCursor);
             emit displayMessage(i18n("Move keyframe above or below clip to remove it, double click to add a new one."), InformationMessage);
         }
+
+        if (!message.isEmpty())
+            emit displayMessage(message, InformationMessage);
     } // no clip under mouse
     else if (m_tool == RAZORTOOL) {
         event->accept();
@@ -1117,6 +1137,7 @@ void CustomTrackView::resetSelectionGroup(bool selectItems)
                 children.at(i)->setSelected(selectItems);
             }
         }
+
         m_selectionGroup = NULL;
         KdenliveSettings::setSnaptopoints(snap);
     }
@@ -1302,26 +1323,37 @@ void CustomTrackView::editItemDuration()
                 m_commandStack->push(command);
             } else {
                 // move and resize clip
+                ClipItem *clip = static_cast<ClipItem *>(item);
                 QUndoCommand *moveCommand = new QUndoCommand();
                 moveCommand->setText(i18n("Edit clip"));
                 if (d.duration() < item->cropDuration() || d.cropStart() != clipInfo.cropStart) {
                     // duration was reduced, so process it first
                     clipInfo.endPos = clipInfo.startPos + d.duration();
                     clipInfo.cropStart = d.cropStart();
-                    new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
+
+                    resizeClip(startInfo, clipInfo);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
+                    adjustEffects(clip, startInfo, moveCommand);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
                 }
+
                 if (d.startPos() != clipInfo.startPos) {
                     startInfo = clipInfo;
                     clipInfo.startPos = d.startPos();
                     clipInfo.endPos = item->endPos() + (clipInfo.startPos - startInfo.startPos);
                     new MoveClipCommand(this, startInfo, clipInfo, true, moveCommand);
                 }
+
                 if (d.duration() > item->cropDuration()) {
                     // duration was increased, so process it after move
                     startInfo = clipInfo;
                     clipInfo.endPos = clipInfo.startPos + d.duration();
                     clipInfo.cropStart = d.cropStart();
-                    new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
+
+                    resizeClip(startInfo, clipInfo);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
+                    adjustEffects(clip, startInfo, moveCommand);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
                 }
                 updateTrackDuration(clipInfo.track, moveCommand);
                 m_commandStack->push(moveCommand);
@@ -1429,6 +1461,10 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0);
             return false;
         }
+        if (clip->producer() == NULL) {
+            emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+            return false;
+        }
         QPointF framePos = mapToScene(pos);
         ItemInfo info;
         info.startPos = GenTime();
@@ -1480,6 +1516,10 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
                 kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i);
                 return false;
             }
+            if (clip->producer() == NULL) {
+                emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+                return false;
+            }
             ItemInfo info;
             info.startPos = start;
             info.cropDuration = clip->duration();
@@ -1812,8 +1852,11 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef
                 }
             }
         }
-        if (delCommand->childCount() > 0) m_commandStack->push(delCommand);
-        else delete delCommand;
+        if (delCommand->childCount() > 0)
+            m_commandStack->push(delCommand);
+        else
+            delete delCommand;
+        setDocumentModified();
         return;
     }
     AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, false);
@@ -1837,10 +1880,10 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
             initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
         }
         // check if we are trying to reset a keyframe effect
-        if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
-            //clip->initEffect(effect);
+        /*if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
+            clip->initEffect(effect);
             effectParams = getEffectArgs(effect);
-        }
+        }*/
         if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - track, pos, effectParams))
             emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
         m_document->setTrackEffect(m_document->tracksCount() - track - 1, ix, effect);
@@ -1853,8 +1896,9 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
     if (clip) {
         // Special case: speed effect
         if (effect.attribute("id") == "speed") {
-            if (effect.attribute("disable") == "1") doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
-            else {
+            if (effect.attribute("disable") == "1") {
+                doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
+            } else {
                 double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
                 int strobe = EffectsList::parameter(effect, "strobe").toInt();
                 if (strobe == 0) strobe = 1;
@@ -1863,7 +1907,8 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
             clip->setEffectAt(ix, effect);
             if (ix == clip->selectedEffectIndex()) {
                 clip->setSelectedEffect(ix);
-                if (!triggeredByUser) emit clipItemSelected(clip, ix);
+                if (!triggeredByUser)
+                    emit clipItemSelected(clip, ix);
             }
             return;
         }
@@ -1878,14 +1923,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
             clip->initEffect(effect);
             effectParams = getEffectArgs(effect);
         }
-        if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
-            emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
 
-        clip->setEffectAt(ix, effect);
-        if (ix == clip->selectedEffectIndex()) {
-            clip->setSelectedEffect(ix);
-            if (!triggeredByUser) emit clipItemSelected(clip, ix);
-        }
         if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
             // A fade effect was modified, update the clip
             if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
@@ -1897,6 +1935,16 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
                 clip->setFadeOut(pos);
             }
         }
+
+        if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
+            emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+
+        clip->setEffectAt(ix, effect);
+        if (ix == clip->selectedEffectIndex()) {
+            clip->setSelectedEffect(ix);
+            if (!triggeredByUser)
+                emit clipItemSelected(clip, ix);
+        }
     }
     setDocumentModified();
 }
@@ -1996,8 +2044,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
             return NULL;
         }
 
-        kDebug() << "/////////  CUTTING CLIP : (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), INFO: (" << info.startPos.frames(25) << "-" << info.endPos.frames(25) << ")" << ", CUT: " << cutTime.frames(25);
-
         if (execute) m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime);
         int cutPos = (int) cutTime.frames(m_document->fps());
         ItemInfo newPos;
@@ -2010,17 +2056,32 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         bool snap = KdenliveSettings::snaptopoints();
         KdenliveSettings::setSnaptopoints(false);
         ClipItem *dup = item->clone(newPos);
-        // remove unwanted effects (fade in) from 2nd part of cutted clip
+
+        // remove unwanted effects
+        // fade in from 2nd part of the clip
         int ix = dup->hasEffect(QString(), "fadein");
         if (ix != -1) {
-            QDomElement oldeffect = item->effectAt(ix);
+            QDomElement oldeffect = dup->effectAt(ix);
             dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
         }
         ix = dup->hasEffect(QString(), "fade_from_black");
         if (ix != -1) {
-            QDomElement oldeffect = item->effectAt(ix);
+            QDomElement oldeffect = dup->effectAt(ix);
             dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
         }
+        // fade out from 1st part of the clip
+        ix = item->hasEffect(QString(), "fadeout");
+        if (ix != -1) {
+            QDomElement oldeffect = item->effectAt(ix);
+            item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+        }
+        ix = item->hasEffect(QString(), "fade_to_black");
+        if (ix != -1) {
+            QDomElement oldeffect = item->effectAt(ix);
+            item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+        }
+
+
         item->resizeEnd(cutPos);
         scene()->addItem(dup);
         if (item->checkKeyFrames())
@@ -2035,8 +2096,9 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         m_document->updateClip(item->baseClip()->getId());
         setDocumentModified();
         KdenliveSettings::setSnaptopoints(snap);
+        if (execute && item->isSelected())
+            emit clipItemSelected(item);
         return dup;
-        //kDebug() << "/////////  CUTTING CLIP RESULT: (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), DUP: (" << dup->startPos().frames(25) << "-" << dup->endPos().frames(25) << ")" << ", CUT: " << cutTime.frames(25);
     } else {
         // uncut clip
 
@@ -2053,19 +2115,33 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
             return NULL;
         }
 
-        /*kDebug() << "// UNCUTTING CLIPS: ITEM 1 (" << item->startPos().frames(25) << "x" << item->endPos().frames(25) << ")";
-        kDebug() << "// UNCUTTING CLIPS: ITEM 2 (" << dup->startPos().frames(25) << "x" << dup->endPos().frames(25) << ")";
-        kDebug() << "// UNCUTTING CLIPS, INFO (" << info.startPos.frames(25) << "x" << info.endPos.frames(25) << ") , CUT: " << cutTime.frames(25);;*/
-        //deleteClip(dup->info());
-
         bool snap = KdenliveSettings::snaptopoints();
         KdenliveSettings::setSnaptopoints(false);
 
-        if (dup->isSelected()) emit clipItemSelected(NULL);
+        // join fade effects again
+        int ix = dup->hasEffect(QString(), "fadeout");
+        if (ix != -1) {
+            QDomElement effect = dup->effectAt(ix);
+            item->addEffect(effect);
+        }
+        ix = dup->hasEffect(QString(), "fade_to_black");
+        if (ix != -1) {
+            QDomElement effect = dup->effectAt(ix);
+            item->addEffect(effect);
+        }
+
+        m_waitingThumbs.removeAll(dup);
+        bool selected = item->isSelected();
+        if (dup->isSelected()) {
+            selected = true;
+            item->setSelected(true);
+            emit clipItemSelected(NULL);
+        }
         dup->baseClip()->removeReference();
         m_document->updateClip(dup->baseClip()->getId());
         scene()->removeItem(dup);
         delete dup;
+        dup = NULL;
 
         ItemInfo clipinfo = item->info();
         clipinfo.track = m_document->tracksCount() - clipinfo.track;
@@ -2080,6 +2156,8 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
             emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
         }
         KdenliveSettings::setSnaptopoints(snap);
+        if (execute && selected)
+            emit clipItemSelected(item);
         return item;
     }
     //QTimer::singleShot(3000, this, SLOT(slotEnableRefresh()));
@@ -2244,6 +2322,7 @@ void CustomTrackView::updateTransition(int track, GenTime pos, QDomElement oldTr
         kWarning() << "Unable to find transition at pos :" << pos.frames(m_document->fps()) << ", ON track: " << track;
         return;
     }
+    
     bool force = false;
     if (oldTransition.attribute("transition_atrack") != transition.attribute("transition_atrack") || oldTransition.attribute("transition_btrack") != transition.attribute("transition_btrack"))
         force = true;
@@ -2379,7 +2458,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             groupSelectedItems(true);
         } else if (items.count() == 1) {
             m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
-            emit clipItemSelected((ClipItem*)m_dragItem);
+            emit clipItemSelected((ClipItem*)m_dragItem, -1, false);
         }
         event->setDropAction(Qt::MoveAction);
         event->accept();
@@ -2428,6 +2507,7 @@ void CustomTrackView::adjustTimelineClips(EDITMODE mode, ClipItem *item, ItemInf
                     }
                 } else if (clip->endPos() <= info.endPos) {
                     new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), clip->info(), clip->effectList(), false, false, false, true, command);
+                    m_waitingThumbs.removeAll(clip);
                     scene()->removeItem(clip);
                     delete clip;
                     clip = NULL;
@@ -3045,7 +3125,7 @@ void CustomTrackView::setCursorPos(int pos, bool seek)
     if (pos == m_cursorPos) return;
     emit cursorMoved((int)(m_cursorPos), (int)(pos));
     m_cursorPos = pos;
-    if (seek) m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    if (seek) m_document->renderer()->seek(m_cursorPos);
     else if (m_autoScroll) checkScrolling();
     m_cursorLine->setPos(m_cursorPos, 0);
 }
@@ -3066,7 +3146,7 @@ void CustomTrackView::moveCursorPos(int delta)
     emit cursorMoved((int)(m_cursorPos), (int)((m_cursorPos + delta)));
     m_cursorPos += delta;
     m_cursorLine->setPos(m_cursorPos, 0);
-    m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    m_document->renderer()->seek(m_cursorPos);
 }
 
 void CustomTrackView::initCursorPos(int pos)
@@ -3168,7 +3248,6 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
         resetSelectionGroup(false);
         m_operationMode = NONE;
     } else if (m_operationMode == RUBBERSELECTION) {
-        //kDebug() << "// END RUBBER SELECT";
         resetSelectionGroup();
         groupSelectedItems();
         m_operationMode = NONE;
@@ -3437,6 +3516,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                                 items.at(i)->parentItem()->setSelected(true);
                         }
                     }
+                    resetSelectionGroup();
                     groupSelectedItems();
                 } else {
                     rebuildGroup((AbstractGroupItem *)group);
@@ -3638,6 +3718,7 @@ void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
         emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
         return;
     }
+    m_waitingThumbs.removeAll(item);
     if (item->isSelected()) emit clipItemSelected(NULL);
     item->baseClip()->removeReference();
     m_document->updateClip(item->baseClip()->getId());
@@ -3651,8 +3732,9 @@ void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
             delete tr;
         }
     }*/
-    m_waitingThumbs.removeAll(item);
+
     if (m_dragItem == item) m_dragItem = NULL;
+
 #if QT_VERSION >= 0x040600
     // animate item deletion
     item->closeAnimation();
@@ -3775,7 +3857,7 @@ void CustomTrackView::changeClipSpeed()
 
 void CustomTrackView::doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id)
 {
-    Q_UNUSED(id);
+    Q_UNUSED(id)
     //DocClipBase *baseclip = m_document->clipManager()->getClipById(id);
 
     ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
@@ -3976,7 +4058,6 @@ void CustomTrackView::doGroupClips(QList <ItemInfo> clipInfos, QList <ItemInfo>
             clip->setSelected(true);
         }
     }
-
     groupSelectedItems(false, true);
     setDocumentModified();
 }
@@ -4047,8 +4128,7 @@ void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload)
                 if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer(info.track))) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
                 }
-                clip->refreshClip(true);
-                clip->update();
+                clip->refreshClip(true, true);
             }
         }
     }
@@ -4388,19 +4468,18 @@ void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool
         ItemInfo clipinfo = item->info();
         clipinfo.track = m_document->tracksCount() - clipinfo.track;
         bool success = m_document->renderer()->mltResizeClipStart(clipinfo, end.startPos - clipinfo.startPos);
-        if (success) {
-            kDebug() << "RESIZE CLP STRAT TO:" << end.startPos.frames(m_document->fps()) << ", OLD ST: " << start.startPos.frames(25);
+        if (success)
             item->resizeStart((int) end.startPos.frames(m_document->fps()));
-            updatePositionEffects(item, clipinfo);
-        } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+        else
+            emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
     } else {
         ItemInfo clipinfo = item->info();
         clipinfo.track = m_document->tracksCount() - clipinfo.track;
         bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, end.endPos - clipinfo.startPos);
-        if (success) {
+        if (success)
             item->resizeEnd((int) end.endPos.frames(m_document->fps()));
-            updatePositionEffects(item, clipinfo);
-        } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+        else
+            emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
     }
     if (!resizeClipStart && end.cropStart != start.cropStart) {
         kDebug() << "// RESIZE CROP, DIFF: " << (end.cropStart - start.cropStart).frames(25);
@@ -4472,44 +4551,16 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
                     new MoveTransitionCommand(this, trInfo, newTrInfo, true, command);
             }
 
-            /*
-             * TODO: cleanup the effect update process
-             */
             ClipItem *clip = static_cast < ClipItem * >(item);
 
-            updatePositionEffects(clip, oldInfo);
-
-            // check keyframes
-            QDomDocument doc;
-            QDomElement root = doc.createElement("list");
-            doc.appendChild(root);
-            QList <int> indexes;
-            for (int i = 0; i < clip->effectsCount(); i++) {
-                QDomElement effect = clip->effectAt(i);
-                if (EffectsList::hasKeyFrames(effect)) {
-                    doc.appendChild(doc.importNode(effect, true));
-                    indexes.append(i);
-                }
-            }
-
-            if (clip->checkEffectsKeyframesPos(oldInfo.cropStart.frames(m_document->fps()), clip->cropStart().frames(m_document->fps()), true)) {
-                // Keyframes were modified, updateClip
-                QDomNodeList effs = doc.elementsByTagName("effect");
-                // Hack:
-                // Since we must always resize clip before updating the keyframes, we
-                // put a resize command before & after checking keyframes so that
-                // we are sure the resize is performed before whenever we do or undo the action
-
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                for (int i = 0; i < indexes.count(); i++) {
-                    new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command);
-                    updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
-                }
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                emit clipItemSelected(clip);
-            } else {
-                new ResizeClipCommand(this, oldInfo, info, false, false, command);
-            }
+            // Hack:
+            // Since we must always resize clip before updating the keyframes, we
+            // put a resize command before & after checking keyframes so that
+            // we are sure the resize is performed before whenever we do or undo the action
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            adjustEffects(clip, oldInfo, command);
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            emit clipItemSelected(clip);
         } else {
             KdenliveSettings::setSnaptopoints(false);
             item->resizeStart((int) oldInfo.startPos.frames(m_document->fps()));
@@ -4560,7 +4611,6 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
         hasParentCommand = true;
     } else {
         command = new QUndoCommand();
-        command->setText(i18n("Resize clip end"));
     }
 
     // do this here, too, because otherwise undo won't update the group
@@ -4569,6 +4619,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
 
     ItemInfo info = item->info();
     if (item->type() == AVWIDGET) {
+        if (!hasParentCommand) command->setText(i18n("Resize clip end"));
         ItemInfo resizeinfo = info;
         resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
         bool success = m_document->renderer()->mltResizeClipEnd(resizeinfo, resizeinfo.cropDuration);
@@ -4597,39 +4648,14 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
 
             ClipItem *clip = static_cast < ClipItem * >(item);
 
-            updatePositionEffects(clip, oldInfo);
-
-            // check keyframes
-            QDomDocument doc;
-            QDomElement root = doc.createElement("list");
-            doc.appendChild(root);
-            QList <int> indexes;
-            for (int i = 0; i < clip->effectsCount(); i++) {
-                QDomElement effect = clip->effectAt(i);
-                if (EffectsList::hasKeyFrames(effect)) {
-                    doc.appendChild(doc.importNode(effect, true));
-                    indexes.append(i);
-                }
-            }
-
-            if (clip->checkEffectsKeyframesPos((oldInfo.cropStart + oldInfo.endPos - oldInfo.startPos).frames(m_document->fps()) - 1, (clip->cropStart() + clip->cropDuration()).frames(m_document->fps()) - 1, false)) {
-                // Keyframes were modified, updateClip
-                QDomNodeList effs = doc.elementsByTagName("effect");
-                // Hack:
-                // Since we must always resize clip before updating the keyframes, we
-                // put a resize command before & after checking keyframes so that
-                // we are sure the resize is performed before whenever we do or undo the action
-
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                for (int i = 0; i < indexes.count(); i++) {
-                    new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command);
-                    updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
-                }
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                emit clipItemSelected(clip);
-            } else {
-                new ResizeClipCommand(this, oldInfo, info, false, false, command);
-            }
+            // Hack:
+            // Since we must always resize clip before updating the keyframes, we
+            // put a resize command before & after checking keyframes so that
+            // we are sure the resize is performed before whenever we do or undo the action
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            adjustEffects(clip, oldInfo, command);
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            emit clipItemSelected(clip);
         } else {
             KdenliveSettings::setSnaptopoints(false);
             item->resizeEnd((int) oldInfo.endPos.frames(m_document->fps()));
@@ -4637,6 +4663,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
             emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
         }
     } else if (item->type() == TRANSITIONWIDGET) {
+        if (!hasParentCommand) command->setText(i18n("Resize transition end"));
         Transition *transition = static_cast <Transition *>(item);
         if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - oldInfo.track), (int)(m_document->tracksCount() - oldInfo.track), transition->transitionEndTrack(), oldInfo.startPos, oldInfo.endPos, info.startPos, info.endPos)) {
             // Cannot resize transition
@@ -4645,9 +4672,14 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
             KdenliveSettings::setSnaptopoints(true);
             emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
         } else {
-            MoveTransitionCommand *moveCommand = new MoveTransitionCommand(this, oldInfo, info, false, command);
-            if (command == NULL)
-                m_commandStack->push(moveCommand);
+            // Check transition keyframes
+            QDomElement old = transition->toXML();
+            if (transition->updateKeyframes()) {
+                QDomElement xml = transition->toXML();
+                m_document->renderer()->mltUpdateTransition(xml.attribute("tag"), xml.attribute("tag"), xml.attribute("transition_btrack").toInt(), m_document->tracksCount() - xml.attribute("transition_atrack").toInt(), transition->startPos(), transition->endPos(), xml);
+                new EditTransitionCommand(this, transition->track(), transition->startPos(), old, xml, false, command);
+            }
+            new MoveTransitionCommand(this, oldInfo, info, false, command);
         }
     }
     if (item->parentItem() && item->parentItem() != m_selectionGroup)
@@ -4659,14 +4691,14 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
     }
 }
 
-void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
+void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool standalone)
 {
     int end = item->fadeIn();
     if (end != 0) {
         // there is a fade in effect
         int effectPos = item->hasEffect("volume", "fadein");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int start = item->cropStart().frames(m_document->fps());
             int max = item->cropDuration().frames(m_document->fps());
             if (end > max) {
@@ -4675,16 +4707,19 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 end = item->fadeIn();
             }
             end += start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
         effectPos = item->hasEffect("brightness", "fade_from_black");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int start = item->cropStart().frames(m_document->fps());
             int max = item->cropDuration().frames(m_document->fps());
             if (end > max) {
@@ -4693,20 +4728,24 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 end = item->fadeIn();
             }
             end += start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
     }
+
     int start = item->fadeOut();
     if (start != 0) {
         // there is a fade out effect
         int effectPos = item->hasEffect("volume", "fadeout");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int max = item->cropDuration().frames(m_document->fps());
             int end = max + item->cropStart().frames(m_document->fps());
             if (start > max) {
@@ -4715,16 +4754,19 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 start = item->fadeOut();
             }
             start = end - start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
         effectPos = item->hasEffect("brightness", "fade_to_black");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int max = item->cropDuration().frames(m_document->fps());
             int end = max + item->cropStart().frames(m_document->fps());
             if (start > max) {
@@ -4733,12 +4775,15 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 start = item->fadeOut();
             }
             start = end - start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
     }
 
@@ -4750,13 +4795,13 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
         if (!eff.isNull() && diff != 0) {
             int freeze_pos = EffectsList::parameter(eff, "frame").toInt() + diff;
             EffectsList::setParameter(eff, "frame", QString::number(freeze_pos));
-            if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
-                emit clipItemSelected(item, item->selectedEffectIndex());
+            if (standalone) {
+                if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
+                    emit clipItemSelected(item, item->selectedEffectIndex());
+                }
             }
         }
     }
-
-    updatePanZoom(item);
 }
 
 double CustomTrackView::getSnapPointForPos(double pos)
@@ -4987,7 +5032,8 @@ void CustomTrackView::slotAddGuide(bool dialog)
     if (dialog) {
         MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
         if (d.exec() != QDialog::Accepted) return;
-        marker.setComment(d.newMarker().comment());
+        marker = d.newMarker();
+        
     } else {
         marker.setComment(m_document->timecode().getDisplayTimecodeFromFrames(m_cursorPos, false));
     }
@@ -5590,7 +5636,7 @@ void CustomTrackView::slotUpdateAllThumbs()
                         item->slotSetEndThumb(pix);
                     }
                 }
-                item->refreshClip(false);
+                item->refreshClip(false, false);
             }
         }
     }
@@ -5710,6 +5756,7 @@ void CustomTrackView::deleteTimelineTrack(int ix, TrackInfo trackinfo)
         if (selection.at(i)->type() == AVWIDGET) {
             ClipItem *item =  static_cast <ClipItem *>(selection.at(i));
             new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, false, true, deleteTrack);
+            m_waitingThumbs.removeAll(item);
             m_scene->removeItem(item);
             delete item;
             item = NULL;
@@ -5812,8 +5859,7 @@ void CustomTrackView::loadGroups(const QDomNodeList groups)
         QDomNodeList children = groups.at(i).childNodes();
         scene()->clearSelection();
         for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
-            QDomNode n = children.item(nodeindex);
-            QDomElement elem = n.toElement();
+            QDomElement elem = children.item(nodeindex).toElement();
             int pos = elem.attribute("position").toInt();
             int track = elem.attribute("track").toInt();
             if (elem.tagName() == "clipitem") {
@@ -6151,6 +6197,7 @@ void CustomTrackView::updateProjectFps()
             m_document->clipManager()->removeGroup(grp);
             m_scene->addItem(grp);
             scene()->destroyItemGroup(grp);
+            scene()->clearSelection();
             for (int j = 0; j < children.count(); j++) {
                 if (children.at(j)->type() == AVWIDGET || children.at(j)->type() == TRANSITIONWIDGET) {
                     //children.at(j)->setParentItem(0);
@@ -6271,10 +6318,15 @@ QStringList CustomTrackView::extractTransitionsLumas()
         if (itemList.at(i)->type() == TRANSITIONWIDGET) {
             transitionitem = static_cast <Transition*>(itemList.at(i));
             transitionXml = transitionitem->toXML();
+            // luma files in transitions can be in "resource" or "luma" property
             QString luma = EffectsList::parameter(transitionXml, "luma");
-            if (!luma.isEmpty()) urls << luma;
+            if (luma.isEmpty()) luma = EffectsList::parameter(transitionXml, "resource");
+            if (!luma.isEmpty()) urls << KUrl(luma).path();
         }
     }
+#if QT_VERSION >= 0x040500
+    urls.removeDuplicates();
+#endif
     return urls;
 }
 
@@ -6528,6 +6580,7 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
 void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos)
 {
     QList <int> effects = item->updatePanZoom(m_document->width(), m_document->height(), cutPos.frames(m_document->fps()));
+
     for (int i = 0; i < effects.count(); ++i) {
         if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(item->effectAt(effects.at(i)))))
             emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
@@ -6537,7 +6590,7 @@ void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos)
             emit clipItemSelected(item, effects.at(i));*/
     }
     // update always, otherwise there might problems when resizing groups
-    if (effects.count() > 0)
+    if (effects.count())
         emit clipItemSelected(item, item->selectedEffectIndex());
 }
 
@@ -6579,7 +6632,7 @@ void CustomTrackView::updateTrackNames(int track, bool added)
 
 void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
 {
-    Q_UNUSED(command);
+    Q_UNUSED(command)
 
     QList<int> tracks;
     if (track >= 0) {
@@ -6609,4 +6662,29 @@ void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
     }
 }
 
+void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
+{
+    QList<QGraphicsItem *> list = scene()->items();
+    ClipItem *clip = NULL;
+    for (int i = 0; i < list.size(); ++i) {
+        if (list.at(i)->type() == AVWIDGET) {
+            clip = static_cast <ClipItem *>(list.at(i));
+            if (clip->clipProducer() == id) {
+                clip->refreshClip(true, resetThumbs);
+            }
+        }
+    }
+}
+
+void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoCommand* command)
+{
+    QMap<int, QDomElement> effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo);
 
+    if (effects.count()) {
+        QMap<int, QDomElement>::const_iterator i = effects.constBegin();
+        while (i != effects.constEnd()) {
+            new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, command);
+            ++i;
+        }
+    }
+}