]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Fix white thumbnails in timeline when audio only copy of clip was in timeline
[kdenlive] / src / projectlist.cpp
index 49f4f10df125180b77549668ad7c91f674c2ce97..5d74c7bdd3e313daab2b8286983f89e6a05335af 100644 (file)
@@ -500,10 +500,31 @@ void ProjectList::slotMissingClip(const QString &id)
     ProjectItem *item = getItemById(id);
     if (item) {
         item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+        int height = m_listView->iconSize().height();
+        int width = (int)(height  * m_render->dar());
+        QPixmap pixmap = qVariantValue<QPixmap>(item->data(0, Qt::DecorationRole));
+        if (pixmap.isNull()) {
+            pixmap = QPixmap(width, height);
+            pixmap.fill(Qt::transparent);
+        }
+        KIcon icon("dialog-close");
+        QPainter p(&pixmap);
+        p.drawPixmap(3, 3, icon.pixmap(width - 6, height - 6));
+        p.end();
+        item->setData(0, Qt::DecorationRole, pixmap);
         if (item->referencedClip()) {
             item->referencedClip()->setPlaceHolder(true);
-            if (m_render == NULL) kDebug() << "*********  ERROR, NULL RENDR";
-            item->referencedClip()->setProducer(m_render->invalidProducer(id), true);
+            if (m_render == NULL) {
+                kDebug() << "*********  ERROR, NULL RENDR";
+                return;
+            }
+            Mlt::Producer *newProd = m_render->invalidProducer(id);
+            if (item->referencedClip()->producer()) {
+                Mlt::Properties props(newProd->get_properties());
+                Mlt::Properties src_props(item->referencedClip()->producer()->get_properties());
+                props.inherit(src_props);
+            }
+            item->referencedClip()->setProducer(newProd, true);
             item->slotSetToolTip();
             emit clipNeedsReload(id, true);
         }
@@ -608,7 +629,7 @@ void ProjectList::slotClipSelected()
 
 void ProjectList::adjustProxyActions(ProjectItem *clip) const
 {
-    if (clip == NULL || clip->type() != PROJECTCLIPTYPE || clip->clipType() == COLOR || clip->clipType() == TEXT || clip->clipType() == PLAYLIST || clip->clipType() == SLIDESHOW || clip->clipType() == AUDIO) {
+    if (clip == NULL || clip->type() != PROJECTCLIPTYPE || clip->clipType() == COLOR || clip->clipType() == TEXT || clip->clipType() == SLIDESHOW || clip->clipType() == AUDIO) {
         m_proxyAction->setEnabled(false);
         return;
     }
@@ -995,7 +1016,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     }
     if (item->data(0, DurationRole).isNull()) item->setData(0, DurationRole, i18n("Loading"));
     connect(clip, SIGNAL(createProxy(const QString)), this, SLOT(slotCreateProxy(const QString)));
-    connect(clip, SIGNAL(abortProxy(const QString)), this, SLOT(slotAbortProxy(const QString)));
+    connect(clip, SIGNAL(abortProxy(const QString, const QString)), this, SLOT(slotAbortProxy(const QString, const QString)));
     if (getProperties) {
         m_listView->processLayout();
         QDomElement e = clip->toXML().cloneNode().toElement();
@@ -1003,7 +1024,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
         m_infoQueue.insert(clip->getId(), e);
     }
     else if (item->hasProxy() && !item->isProxyRunning()) {
-        slotCreateProxy(clip->getId(), false);
+        slotCreateProxy(clip->getId());
     }
     clip->askForAudioThumbs();
     
@@ -1051,26 +1072,40 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
         m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
 }
 
-void ProjectList::slotGotProxy(const QString &id)
+void ProjectList::slotGotProxy(const QString &proxyPath)
 {
-    ProjectItem *item = getItemById(id);
-    if (item) {
-        // Proxy clip successfully created
-        QDomElement e = item->referencedClip()->toXML().cloneNode().toElement();  
-        //e.removeAttribute("file_hash");
+    if (proxyPath.isEmpty()) return;
+    QTreeWidgetItemIterator it(m_listView);
+    ProjectItem *item;
 
-        // Make sure we get the correct producer length if it was adjusted in timeline
-        CLIPTYPE t = item->clipType();
-        if (t == COLOR || t == IMAGE || t == SLIDESHOW || t == TEXT) {
-            int length = QString(item->referencedClip()->producerProperty("length")).toInt();
-            if (length > 0 && !e.hasAttribute("length")) {
-                e.setAttribute("length", length);
-            }
+    while (*it) {
+        if ((*it)->type() == PROJECTCLIPTYPE) {
+            item = static_cast <ProjectItem *>(*it);
+            if (item->referencedClip()->getProperty("proxy") == proxyPath)
+                slotGotProxy(item);
+        }
+        ++it;
+    }
+}
+
+void ProjectList::slotGotProxy(ProjectItem *item)
+{
+    if (item == NULL) return;
+    DocClipBase *clip = item->referencedClip();
+    // Proxy clip successfully created
+    QDomElement e = clip->toXML().cloneNode().toElement();
+
+    // Make sure we get the correct producer length if it was adjusted in timeline
+    CLIPTYPE t = item->clipType();
+    if (t == COLOR || t == IMAGE || t == SLIDESHOW || t == TEXT) {
+        int length = QString(clip->producerProperty("length")).toInt();
+        if (length > 0 && !e.hasAttribute("length")) {
+            e.setAttribute("length", length);
         }
-        e.setAttribute("replace", 1);
-        m_infoQueue.insert(id, e);
-        if (!m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
     }
+    e.setAttribute("replace", 1);
+    m_infoQueue.insert(clip->getId(), e);
+    if (!m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);   
 }
 
 void ProjectList::slotResetProjectList()
@@ -1122,7 +1157,7 @@ void ProjectList::slotUpdateClip(const QString &id)
     monitorItemEditing(true);
 }
 
-void ProjectList::updateAllClips(bool displayRatioChanged)
+void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged)
 {
     m_listView->setSortingEnabled(false);
 
@@ -1130,6 +1165,15 @@ void ProjectList::updateAllClips(bool displayRatioChanged)
     DocClipBase *clip;
     ProjectItem *item;
     monitorItemEditing(false);
+    int height = m_listView->iconSize().height();
+    int width = (int)(height  * m_render->dar());
+    QPixmap missingPixmap = QPixmap(width, height);
+    missingPixmap.fill(Qt::transparent);
+    KIcon icon("dialog-close");
+    QPainter p(&missingPixmap);
+    p.drawPixmap(3, 3, icon.pixmap(width - 6, height - 6));
+    p.end();
+                        
     while (*it) {
         if ((*it)->type() == PROJECTSUBCLIPTYPE) {
             // subitem
@@ -1148,20 +1192,48 @@ void ProjectList::updateAllClips(bool displayRatioChanged)
             item = static_cast <ProjectItem *>(*it);
             clip = item->referencedClip();
             if (item->referencedClip()->producer() == NULL) {
-                if (clip->isPlaceHolder() == false)
-                    requestClipInfo(clip->toXML(), clip->getId());
-                else if (!clip->isPlaceHolder())
+                if (clip->isPlaceHolder() == false) {
+                    QDomElement xml = clip->toXML();
+                    if (fpsChanged) {
+                        xml.removeAttribute("out");
+                        xml.removeAttribute("file_hash");
+                        xml.removeAttribute("proxy_out");
+                    }
+                    requestClipInfo(xml, clip->getId());
+                }
+                else {
                     item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+                    if (item->data(0, Qt::DecorationRole).isNull()) {
+                        item->setData(0, Qt::DecorationRole, missingPixmap);
+                    }
+                    else {
+                        QPixmap pixmap = qVariantValue<QPixmap>(item->data(0, Qt::DecorationRole));
+                        QPainter p(&pixmap);
+                        p.drawPixmap(3, 3, KIcon("dialog-close").pixmap(pixmap.width() - 6, pixmap.height() - 6));
+                        p.end();
+                        item->setData(0, Qt::DecorationRole, pixmap);
+                    }
+                }
             } else {
                 if (displayRatioChanged || item->data(0, Qt::DecorationRole).isNull())
                     requestClipThumbnail(clip->getId());
                 if (item->data(0, DurationRole).toString().isEmpty()) {
                     item->changeDuration(item->referencedClip()->producer()->get_playtime());
                 }
+                if (clip->isPlaceHolder()) {
+                    QPixmap pixmap = qVariantValue<QPixmap>(item->data(0, Qt::DecorationRole));
+                    if (pixmap.isNull()) {
+                        pixmap = QPixmap(width, height);
+                        pixmap.fill(Qt::transparent);
+                    }
+                    QPainter p(&pixmap);
+                    p.drawPixmap(3, 3, KIcon("dialog-close").pixmap(pixmap.width() - 6, pixmap.height() - 6));
+                    p.end();
+                    item->setData(0, Qt::DecorationRole, pixmap);
+                }
             }
             item->setData(0, UsageRole, QString::number(item->numReferences()));
         }
-        //qApp->processEvents();
         ++it;
     }
 
@@ -1280,6 +1352,7 @@ void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
 {
     ProjectItem *item = getItemById(id);
     m_processingClips.removeAll(id);
+    m_thumbnailQueue.removeAll(id);
     if (!m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
     if (item) {
         const QString path = item->referencedClip()->fileURL().path();
@@ -1313,6 +1386,7 @@ void ProjectList::slotRemoveInvalidProxy(const QString &id, bool durationError)
         }
     }
     m_processingClips.removeAll(id);
+    m_thumbnailQueue.removeAll(id);
     if (!m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
 }
 
@@ -1433,7 +1507,6 @@ void ProjectList::setDocument(KdenliveDoc *doc)
     m_timecode = doc->timecode();
     m_commandStack = doc->commandStack();
     m_doc = doc;
-    m_proxyList.clear();
 
     QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
     QStringList openedFolders = doc->getExpandedFolders();
@@ -1453,7 +1526,7 @@ void ProjectList::setDocument(KdenliveDoc *doc)
     connect(m_doc->clipManager(), SIGNAL(modifiedClip(const QString &)), this, SLOT(slotModifiedClip(const QString &)));
     connect(m_doc->clipManager(), SIGNAL(missingClip(const QString &)), this, SLOT(slotMissingClip(const QString &)));
     connect(m_doc->clipManager(), SIGNAL(availableClip(const QString &)), this, SLOT(slotAvailableClip(const QString &)));
-    connect(m_doc->clipManager(), SIGNAL(checkAllClips(bool)), this, SLOT(updateAllClips(bool)));
+    connect(m_doc->clipManager(), SIGNAL(checkAllClips(bool, bool)), this, SLOT(updateAllClips(bool, bool)));
 }
 
 QList <DocClipBase*> ProjectList::documentClipList() const
@@ -1560,7 +1633,7 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
         else if (clip->clipType() == IMAGE)
             pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, width, height));
         else
-            pix = item->referencedClip()->thumbProducer()->extractImage(frame, width, height);
+            pix = item->referencedClip()->extractImage(frame, width, height);
 
         if (!pix.isNull()) {
             monitorItemEditing(false);
@@ -1588,6 +1661,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     }
     m_processingClips.removeAll(clipId);
     if (m_infoQueue.isEmpty() && m_processingClips.isEmpty()) m_listView->setEnabled(true);
+
     if (item && producer) {
         //m_listView->blockSignals(true);
         monitorItemEditing(false);
@@ -1598,7 +1672,6 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
             toReload = clipId;
         }
-
         // Proxy stuff
         QString size = properties.value("frame_size");
         if (!useProxy() && clip->getProperty("proxy").isEmpty()) setProxyStatus(item, NOPROXY);
@@ -1609,15 +1682,15 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             CLIPTYPE t = item->clipType();
             if (t == IMAGE) maxSize = m_doc->getDocumentProperty("proxyimageminsize").toInt();
             else maxSize = m_doc->getDocumentProperty("proxyminsize").toInt();
-            if (((t == AV || t == VIDEO) && generateProxy() && size.section('x', 0, 0).toInt() > maxSize) || (t == IMAGE && generateImageProxy() && (size.section('x', 0, 0).toInt() > maxSize || size.section('x', 1, 1).toInt() > maxSize))) {
+            if ((((t == AV || t == VIDEO || t == PLAYLIST) && generateProxy()) || (t == IMAGE && generateImageProxy())) && (size.section('x', 0, 0).toInt() > maxSize || size.section('x', 1, 1).toInt() > maxSize)) {
                 if (clip->getProperty("proxy").isEmpty()) {
                     KUrl proxyPath = m_doc->projectFolder();
                     proxyPath.addPath("proxy/");
                     proxyPath.addPath(clip->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension")));
                     QMap <QString, QString> newProps;
-                    newProps.insert("proxy", proxyPath.path());
                     // insert required duration for proxy
                     if (t != IMAGE) newProps.insert("proxy_out", clip->producerProperty("out"));
+                    newProps.insert("proxy", proxyPath.path());
                     QMap <QString, QString> oldProps = clip->properties();
                     oldProps.insert("proxy", QString());
                     EditClipCommand *command = new EditClipCommand(this, clipId, oldProps, newProps, true);
@@ -1625,49 +1698,41 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
                 }
             }
         }
-        
         clip->setProducer(producer, replace);
         clip->askForAudioThumbs();
+
         if (!replace && item->data(0, Qt::DecorationRole).isNull())
             requestClipThumbnail(clipId);
         if (!toReload.isEmpty())
             item->slotSetToolTip();
 
-        if (m_listView->isEnabled() && replace) {
-            // update clip in clip monitor
-            emit clipSelected(NULL);
-            emit clipSelected(clip);
-            //TODO: Make sure the line below has no side effect
-            toReload = clipId;
-        }
-        /*else {
-            // Check if duration changed.
-            emit receivedClipDuration(clipId);
-            delete producer;
-        }*/
         if (m_listView->isEnabled())
             monitorItemEditing(true);
-        /*if (item->icon(0).isNull()) {
-            requestClipThumbnail(clipId);
-        }*/
     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
     if (selectClip && m_infoQueue.isEmpty()) {
-    if (item && m_infoQueue.isEmpty() && m_thumbnailQueue.isEmpty()) {
-        m_listView->setCurrentItem(item);
-        bool updatedProfile = false;
-        if (item->parent()) {
-            if (item->parent()->type() == PROJECTFOLDERTYPE)
-                static_cast <FolderProjectItem *>(item->parent())->switchIcon();
-        } else if (KdenliveSettings::checkfirstprojectclip() &&  m_listView->topLevelItemCount() == 1) {
-            // this is the first clip loaded in project, check if we want to adjust project settings to the clip
-            updatedProfile = adjustProjectProfileToItem(item);
-        }
-        if (updatedProfile == false) emit clipSelected(item->referencedClip());
-    } else {
-        int max = m_doc->clipManager()->clipsCount();
-        emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
-    }
+        if (item && m_infoQueue.isEmpty() && m_thumbnailQueue.isEmpty()) {
+            m_listView->setCurrentItem(item);
+            bool updatedProfile = false;
+            if (item->parent()) {
+                if (item->parent()->type() == PROJECTFOLDERTYPE)
+                    static_cast <FolderProjectItem *>(item->parent())->switchIcon();
+            } else if (KdenliveSettings::checkfirstprojectclip() &&  m_listView->topLevelItemCount() == 1) {
+                // this is the first clip loaded in project, check if we want to adjust project settings to the clip
+                updatedProfile = adjustProjectProfileToItem(item);
+            }
+            if (updatedProfile == false) emit clipSelected(item->referencedClip());
+        } else {
+            int max = m_doc->clipManager()->clipsCount();
+            emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
+        }
     }
+    if (item && m_listView->isEnabled() && replace) {
+            // update clip in clip monitor
+            if (item->isSelected() && m_listView->selectedItems().count() == 1)
+                emit clipSelected(item->referencedClip());
+            //TODO: Make sure the line below has no side effect
+            toReload = clipId;
+        }
     if (!toReload.isEmpty())
         emit clipNeedsReload(toReload, true);
 
@@ -1960,7 +2025,7 @@ void ProjectList::addClipCut(const QString &id, int in, int out, const QString d
             m_listView->scrollToItem(sub);
             m_listView->editItem(sub, 1);
         }
-        QPixmap p = clip->referencedClip()->thumbProducer()->extractImage(in, (int)(sub->sizeHint(0).height()  * m_render->dar()), sub->sizeHint(0).height() - 2);
+        QPixmap p = clip->referencedClip()->extractImage(in, (int)(sub->sizeHint(0).height()  * m_render->dar()), sub->sizeHint(0).height() - 2);
         sub->setData(0, Qt::DecorationRole, p);
         m_doc->cachePixmap(clip->getClipHash() + '#' + QString::number(in), p);
         monitorItemEditing(true);
@@ -2087,68 +2152,121 @@ QMap <QString, QString> ProjectList::getProxies()
     return list;
 }
 
-void ProjectList::slotCreateProxy(const QString id, bool createProducer)
+void ProjectList::slotCreateProxy(const QString id)
 {
     ProjectItem *item = getItemById(id);
-    if (!item || item->isProxyRunning()) return;
-    
-    // If proxy producer already exists, skip creation
-    if (!createProducer) {
-        setProxyStatus(id, PROXYDONE);
+    if (!item || item->isProxyRunning() || item->referencedClip()->isPlaceHolder()) return;
+    QString path = item->referencedClip()->getProperty("proxy");
+    if (path.isEmpty()) {
+        setProxyStatus(path, PROXYCRASHED);
         return;
     }
-    setProxyStatus(id, PROXYWAITING);
-    if (m_abortProxyId.contains(id)) m_abortProxyId.removeAll(id);
-    emit projectModified();
-    QtConcurrent::run(this, &ProjectList::slotGenerateProxy, id);
+    setProxyStatus(path, PROXYWAITING);
+    if (m_abortProxy.contains(path)) m_abortProxy.removeAll(path);
+    if (m_processingProxy.contains(path)) {
+        // Proxy is already being generated
+        return;
+    }
+    if (QFile::exists(path)) {
+        // Proxy already created
+        setProxyStatus(path, PROXYDONE);
+        slotGotProxy(path);
+        return;
+    }
+    m_processingProxy.append(path);
+    QtConcurrent::run(this, &ProjectList::slotGenerateProxy, path, item->clipUrl().path(), item->clipType(), QString(item->referencedClip()->producerProperty("_exif_orientation")).toInt());
 }
 
-void ProjectList::slotAbortProxy(const QString id)
+void ProjectList::slotAbortProxy(const QString id, const QString path)
 {
-    if (m_proxyList.contains(id)) m_proxyList.removeAll(id);
+    QTreeWidgetItemIterator it(m_listView);
     ProjectItem *item = getItemById(id);
-    if (item) {
-      emit projectModified();
-      if (item->isProxyReady()) slotGotProxy(id);
-      else if (item->isProxyRunning()) m_abortProxyId << id;
-      setProxyStatus(id, NOPROXY);
+    setProxyStatus(item, NOPROXY);
+    slotGotProxy(item);
+    if (!path.isEmpty() && m_processingProxy.contains(path)) {
+        m_abortProxy << path;
+        setProxyStatus(path, NOPROXY);
     }
 }
 
-void ProjectList::slotGenerateProxy(const QString id)
+void ProjectList::slotGenerateProxy(const QString destPath, const QString sourcePath, int clipType, int exif_orientation)
 {
-    setProxyStatus(id, CREATINGPROXY);
-    ProjectItem *item = getItemById(id);
-    if (item == NULL) return;
-    QString path = item->referencedClip()->getProperty("proxy");
-    if (path.isEmpty()) {
-        setProxyStatus(id, PROXYCRASHED);
+    emit projectModified();
+    // Make sure proxy path is writable
+    QFile file(destPath);
+    if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+        setProxyStatus(destPath, PROXYCRASHED);
         return;
     }
-
-    QString url = item->clipUrl().path();
+    file.close();
+    QFile::remove(destPath);
     
-    if (QFile::exists(path)) {
-        setProxyStatus(id, PROXYDONE);
-        slotGotProxy(id);
-        return;
-    }
-    else {
-        // Make sure proxy path is writable
-        QFile file(path);
-        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
-            setProxyStatus(id, PROXYCRASHED);
-            return;
+    setProxyStatus(destPath, CREATINGPROXY);
+
+    // Special case: playlist clips (.mlt or .kdenlive project files)
+    if (clipType == PLAYLIST) {
+        // change FFmpeg params to MLT format
+        QStringList parameters;
+        parameters << sourcePath;
+        parameters << "-consumer" << "avformat:" + destPath;
+        QStringList params = m_doc->getDocumentProperty("proxyparams").simplified().split('-', QString::SkipEmptyParts);
+        
+        foreach(QString s, params) {
+            s = s.simplified();
+            if (s.count(' ') == 0) {
+                s.append("=1");
+            }
+            else s.replace(' ', '=');
+            parameters << s;
         }
-        file.close();
-        QFile::remove(path);
+        
+        parameters.append(QString("real_time=-%1").arg(KdenliveSettings::mltthreads()));
+
+        //TODO: currently, when rendering an xml file through melt, the display ration is lost, so we enforce it manualy
+        double display_ratio = KdenliveDoc::getDisplayRatio(sourcePath);
+        parameters << "aspect=" + QString::number(display_ratio);
+
+        //kDebug()<<"TRANSCOD: "<<parameters;
+        QProcess myProcess;
+        myProcess.start(KdenliveSettings::rendererpath(), parameters);
+        myProcess.waitForStarted();
+        int result = -1;
+        while (myProcess.state() != QProcess::NotRunning) {
+            // building proxy file
+            if (m_abortProxy.contains(destPath)) {
+                myProcess.close();
+                myProcess.waitForFinished();
+                m_abortProxy.removeAll(destPath);
+                m_processingProxy.removeAll(destPath);
+                QFile::remove(destPath);
+                setProxyStatus(destPath, NOPROXY);
+                result = -2;
+
+            }
+            myProcess.waitForFinished(500);
+        }
+        myProcess.waitForFinished();
+        m_processingProxy.removeAll(destPath);
+        if (result == -1) result = myProcess.exitStatus();
+        if (result == 0) {
+            // proxy successfully created
+            setProxyStatus(destPath, PROXYDONE);
+            slotGotProxy(destPath);
+        }
+        else if (result == 1) {
+            // Proxy process crashed
+            QFile::remove(destPath);
+            setProxyStatus(destPath, PROXYCRASHED);
+        }   
+
     }
-    if (item->clipType() == IMAGE) {
+    
+    if (clipType == IMAGE) {
         // Image proxy
-        QImage i(url);
+        QImage i(sourcePath);
         if (i.isNull()) {
             // Cannot load image
-            setProxyStatus(id, PROXYCRASHED);
+            setProxyStatus(destPath, PROXYCRASHED);
             return;
         }
         QImage proxy;
@@ -2156,7 +2274,6 @@ void ProjectList::slotGenerateProxy(const QString id)
         //TODO: Make it be configurable?
         if (i.width() > i.height()) proxy = i.scaledToWidth(m_render->frameRenderWidth());
         else proxy = i.scaledToHeight(m_render->renderHeight());
-        int exif_orientation = QString(item->referencedClip()->producerProperty("_exif_orientation")).toInt();
         if (exif_orientation > 1) {
             // Rotate image according to exif data
             QImage processed;
@@ -2188,35 +2305,39 @@ void ProjectList::slotGenerateProxy(const QString id)
                   break;
               }
               processed = proxy.transformed( matrix );
-              processed.save(path);
+              processed.save(destPath);
         }
-        else proxy.save(path);
-        setProxyStatus(id, PROXYDONE);
-        slotGotProxy(id);
+        else proxy.save(destPath);
+        setProxyStatus(destPath, PROXYDONE);
+        slotGotProxy(destPath);
+        m_abortProxy.removeAll(destPath);
+        m_processingProxy.removeAll(destPath);
         return;
     }
 
     QStringList parameters;
-    parameters << "-i" << url;
+    parameters << "-i" << sourcePath;
     QString params = m_doc->getDocumentProperty("proxyparams").simplified();
     foreach(QString s, params.split(' '))
     parameters << s;
 
     // Make sure we don't block when proxy file already exists
     parameters << "-y";
-    parameters << path;
+    parameters << destPath;
+    kDebug()<<"// STARTING PROXY GEN: "<<parameters;
     QProcess myProcess;
     myProcess.start("ffmpeg", parameters);
     myProcess.waitForStarted();
     int result = -1;
     while (myProcess.state() != QProcess::NotRunning) {
         // building proxy file
-        if (m_abortProxyId.contains(id)) {
+        if (m_abortProxy.contains(destPath)) {
             myProcess.close();
             myProcess.waitForFinished();
-            m_abortProxyId.removeAll(id);
-            QFile::remove(path);
-            setProxyStatus(id, NOPROXY);
+            m_abortProxy.removeAll(destPath);
+            m_processingProxy.removeAll(destPath);
+            QFile::remove(destPath);
+            setProxyStatus(destPath, NOPROXY);
             result = -2;
             
         }
@@ -2226,14 +2347,16 @@ void ProjectList::slotGenerateProxy(const QString id)
     if (result == -1) result = myProcess.exitStatus();
     if (result == 0) {
         // proxy successfully created
-        setProxyStatus(id, PROXYDONE);
-        slotGotProxy(id);
+        setProxyStatus(destPath, PROXYDONE);
+        slotGotProxy(destPath);
     }
     else if (result == 1) {
         // Proxy process crashed
-        QFile::remove(path);
-        setProxyStatus(id, PROXYCRASHED);
+        QFile::remove(destPath);
+        setProxyStatus(destPath, PROXYCRASHED);
     }
+    m_abortProxy.removeAll(destPath);
+    m_processingProxy.removeAll(destPath);
 }
 
 void ProjectList::updateProxyConfig()
@@ -2334,14 +2457,14 @@ void ProjectList::slotProxyCurrentItem(bool doProxy)
         if (listItem->type() == PROJECTCLIPTYPE) {
             ProjectItem *item = static_cast <ProjectItem*>(listItem);
             CLIPTYPE t = item->clipType();
-            if ((t == VIDEO || t == AV || t == UNKNOWN || t == IMAGE) && item->referencedClip()) {
+            if ((t == VIDEO || t == AV || t == UNKNOWN || t == IMAGE || t == PLAYLIST) && item->referencedClip()) {
                 oldProps = item->referencedClip()->properties();
                 if (doProxy) {
                     newProps.clear();
                     QString path = proxydir + item->referencedClip()->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension"));
-                    newProps.insert("proxy", path);
                     // insert required duration for proxy
                     newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
+                    newProps.insert("proxy", path);
                     // We need to insert empty proxy so that undo will work
                     oldProps.insert("proxy", QString());
                 }
@@ -2356,10 +2479,47 @@ void ProjectList::slotProxyCurrentItem(bool doProxy)
     //if (!m_infoQueue.isEmpty() && !m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
 }
 
-void ProjectList::setProxyStatus(const QString id, PROXYSTATUS status)
+
+void ProjectList::slotDeleteProxy(const QString proxyPath)
 {
-    ProjectItem *item = getItemById(id);
-    setProxyStatus(item, status);
+    if (proxyPath.isEmpty()) return;
+    QUndoCommand *proxyCommand = new QUndoCommand();
+    proxyCommand->setText(i18n("Remove Proxy"));
+    QTreeWidgetItemIterator it(m_listView);
+    ProjectItem *item;
+    while (*it) {
+        if ((*it)->type() == PROJECTCLIPTYPE) {
+            item = static_cast <ProjectItem *>(*it);
+            if (item->referencedClip()->getProperty("proxy") == proxyPath) {
+                QMap <QString, QString> props;
+                props.insert("proxy", QString());
+                new EditClipCommand(this, item->clipId(), item->referencedClip()->properties(), props, true, proxyCommand);
+            
+            }
+        }
+        ++it;
+    }
+    if (proxyCommand->childCount() == 0)
+        delete proxyCommand;
+    else
+        m_commandStack->push(proxyCommand);
+    QFile::remove(proxyPath);
+}
+
+void ProjectList::setProxyStatus(const QString proxyPath, PROXYSTATUS status)
+{
+    if (proxyPath.isEmpty()) return;
+    QTreeWidgetItemIterator it(m_listView);
+    ProjectItem *item;
+    while (*it) {
+        if ((*it)->type() == PROJECTCLIPTYPE) {
+            item = static_cast <ProjectItem *>(*it);
+            if (item->referencedClip()->getProperty("proxy") == proxyPath) {
+                setProxyStatus(item, status);
+            }
+        }
+        ++it;
+    }
 }
 
 void ProjectList::setProxyStatus(ProjectItem *item, PROXYSTATUS status)