]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Fix missing icon for placeholder clips
[kdenlive] / src / projectlist.cpp
index 1678b3150cf6c2c9a9fca5f5588ae353dea167cd..cddce5e83c53e59a01b21625e5ddf0e241e0bce5 100644 (file)
@@ -500,6 +500,15 @@ 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 = 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";
@@ -608,7 +617,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;
     }
@@ -1130,6 +1139,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
@@ -1150,8 +1168,12 @@ void ProjectList::updateAllClips(bool displayRatioChanged)
             if (item->referencedClip()->producer() == NULL) {
                 if (clip->isPlaceHolder() == false)
                     requestClipInfo(clip->toXML(), clip->getId());
-                else if (!clip->isPlaceHolder())
+                else {
                     item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+                    if (item->data(0, Qt::DecorationRole).isNull()) {
+                        item->setData(0, Qt::DecorationRole, missingPixmap);
+                    }
+                }
             } else {
                 if (displayRatioChanged || item->data(0, Qt::DecorationRole).isNull())
                     requestClipThumbnail(clip->getId());
@@ -1609,12 +1631,13 @@ 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 ((size.section('x', 0, 0).toInt() > maxSize || size.section('x', 1, 1).toInt() > maxSize) && (((t == AV || t == VIDEO || t == PLAYLIST) && generateProxy()) || (t == IMAGE && generateImageProxy()))) {
                 if (clip->getProperty("proxy").isEmpty()) {
-                    QString proxydir = m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/";
+                    KUrl proxyPath = m_doc->projectFolder();
+                    proxyPath.addPath("proxy/");
+                    proxyPath.addPath(clip->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension")));
                     QMap <QString, QString> newProps;
-                    QString path = proxydir + clip->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension"));
-                    newProps.insert("proxy", path);
+                    newProps.insert("proxy", proxyPath.path());
                     // insert required duration for proxy
                     if (t != IMAGE) newProps.insert("proxy_out", clip->producerProperty("out"));
                     QMap <QString, QString> oldProps = clip->properties();
@@ -2125,8 +2148,6 @@ void ProjectList::slotGenerateProxy(const QString id)
         return;
     }
 
-    QString url = item->clipUrl().path();
-    
     if (QFile::exists(path)) {
         setProxyStatus(id, PROXYDONE);
         slotGotProxy(id);
@@ -2142,6 +2163,63 @@ void ProjectList::slotGenerateProxy(const QString id)
         file.close();
         QFile::remove(path);
     }
+
+    QString url = item->clipUrl().path();
+
+    // Special case: playlist clips (.mlt or .kdenlive project files)
+    if (item->clipType() == PLAYLIST) {
+        // change FFmpeg params to MLT format
+        QStringList parameters;
+        parameters << url;
+        parameters << "-consumer" << "avformat:" + path;
+        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;
+        }
+
+        // currently, when rendering an xml file through melt, the display ration is lost, so we enforce it manualy
+        double display_ratio = KdenliveDoc::getDisplayRatio(url);
+        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_abortProxyId.contains(id)) {
+                myProcess.close();
+                myProcess.waitForFinished();
+                m_abortProxyId.removeAll(id);
+                QFile::remove(path);
+                setProxyStatus(id, NOPROXY);
+                result = -2;
+
+            }
+            myProcess.waitForFinished(500);
+        }
+        myProcess.waitForFinished();
+        if (result == -1) result = myProcess.exitStatus();
+        if (result == 0) {
+            // proxy successfully created
+            setProxyStatus(id, PROXYDONE);
+            slotGotProxy(id);
+        }
+        else if (result == 1) {
+            // Proxy process crashed
+            QFile::remove(path);
+            setProxyStatus(id, PROXYCRASHED);
+        }   
+
+    }
+    
     if (item->clipType() == IMAGE) {
         // Image proxy
         QImage i(url);
@@ -2333,7 +2411,7 @@ 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();