]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Check clips property before launching proxy creation so that we only proxy the HD...
[kdenlive] / src / projectlist.cpp
index 03b8cd2c49fe438e59bd1b256136386fed395edd..1c2834ec58a2477bb4f6a864b4a0d560d3b212f2 100644 (file)
@@ -585,7 +585,7 @@ void ProjectList::adjustProxyActions(ProjectItem *clip) const
         m_proxyAction->setEnabled(false);
         return;
     }
-    m_proxyAction->setEnabled(true);
+    m_proxyAction->setEnabled(useProxy());
     m_proxyAction->blockSignals(true);
     m_proxyAction->setChecked(clip->hasProxy());
     m_proxyAction->blockSignals(false);
@@ -827,7 +827,7 @@ void ProjectList::updateButtons() const
             m_openAction->setEnabled(true);
             m_reloadAction->setEnabled(true);
             m_transcodeAction->setEnabled(true);
-            m_proxyAction->setEnabled(true);
+            m_proxyAction->setEnabled(useProxy());
             return;
         }
         else if (item && item->type() == PROJECTFOLDERTYPE && item->childCount() > 0) {
@@ -960,19 +960,21 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
         if (parentitem)
             item = new ProjectItem(parentitem, clip);
     }
-    if (item == NULL)
+    if (item == NULL) {
         item = new ProjectItem(m_listView, clip);
+    }
     if (item->data(0, DurationRole).isNull()) item->setData(0, DurationRole, i18n("Loading"));
     if (getProperties) {
-        qApp->processEvents();
+        m_listView->processLayout();
         m_refreshed = false;
         // Proxy clips
         CLIPTYPE t = clip->clipType();
         if ((t == VIDEO || t == AV || t == UNKNOWN) && useProxy()) {
             if (clip->getProperty("proxy").isEmpty()) {
-                connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool)));
-                setProxyStatus(item, 1);
-                clip->generateProxy(m_doc->projectFolder(), proxyParams());
+                
+                //connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool)));
+                //setProxyStatus(item, 1);
+                //clip->generateProxy(m_doc->projectFolder(), proxyParams());
             }
             else {
                 // Proxy clip already created
@@ -982,13 +984,13 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
                 m_infoQueue.insert(clip->getId(), e);
             }
         }
-        else {
+        //else {
             // We don't use proxies
             // remove file_hash so that we load all properties for the clip
             QDomElement e = clip->toXML().cloneNode().toElement();
             e.removeAttribute("file_hash");
             m_infoQueue.insert(clip->getId(), e);
-        }
+        //}
         //m_render->getFileProperties(clip->toXML(), clip->getId(), true);
     }
     else if (!clip->getProperty("proxy").isEmpty()) {
@@ -1168,7 +1170,7 @@ QString ProjectList::getExtensions()
     // Build list of mime types
     QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain"
                             << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime" << "video/webm"
-                            << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg" << "application/mxf" << "application/x-shockwave-flash"
+                            << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "audio/x-aiff" << "audio/aiff" << "application/ogg" << "application/mxf" << "application/x-shockwave-flash"
                             << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
 
     QString allExtensions;
@@ -1561,9 +1563,20 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
             toReload = clipId;
         }
-        if (item->referencedClip()->getProperty("proxy").isEmpty()) setProxyStatus(item, 0);
-        item->referencedClip()->setProducer(producer, replace);
-        item->referencedClip()->askForAudioThumbs();
+        if (!useProxy() && item->referencedClip()->getProperty("proxy").isEmpty()) setProxyStatus(item, 0);
+        QString type = properties.value("type");
+        QString size = properties.value("frame_size");
+        DocClipBase *clip = item->referencedClip();
+        if (useProxy() && (type == "video" || type == "av") && generateProxy() && size.section('x', 0, 0).toInt() > proxyMinSize()) {
+            if (clip->getProperty("proxy").isEmpty()) {
+                connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool)));
+                setProxyStatus(item, 1);
+                clip->generateProxy(m_doc->projectFolder(), proxyParams());
+                
+            }
+        }
+        clip->setProducer(producer, replace);
+        clip->askForAudioThumbs();
         if (!replace && item->data(0, Qt::DecorationRole).isNull())
             requestClipThumbnail(clipId);
         if (!toReload.isEmpty())
@@ -1572,7 +1585,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
         if (m_listView->isEnabled() && replace) {
             // update clip in clip monitor
             emit clipSelected(NULL);
-            emit clipSelected(item->referencedClip());
+            emit clipSelected(clip);
             //TODO: Make sure the line below has no side effect
             toReload = clipId;
         }
@@ -1674,6 +1687,16 @@ bool ProjectList::useProxy() const
     return m_doc->getDocumentProperty("enableproxy").toInt();
 }
 
+bool ProjectList::generateProxy() const
+{
+    return m_doc->getDocumentProperty("generateproxy").toInt();
+}
+
+int ProjectList::proxyMinSize() const
+{
+    return m_doc->getDocumentProperty("proxyminsize").toInt();
+}
+
 QString ProjectList::proxyParams() const
 {
     return m_doc->getDocumentProperty("proxyparams").simplified();
@@ -1770,7 +1793,7 @@ void ProjectList::slotSelectClip(const QString &ix)
         m_deleteButton->defaultAction()->setEnabled(true);
         m_reloadAction->setEnabled(true);
         m_transcodeAction->setEnabled(true);
-        m_proxyAction->setEnabled(true);
+        m_proxyAction->setEnabled(useProxy());
         if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
             m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
             m_openAction->setEnabled(true);
@@ -2027,11 +2050,13 @@ void ProjectList::updateProxyConfig()
         }
         CLIPTYPE t = item->clipType();
         if ((t == VIDEO || t == AV || t == UNKNOWN) && item->referencedClip() != NULL) {
-            if  (useProxy()) {
+            if  (generateProxy() && useProxy()) {
                 DocClipBase *clip = item->referencedClip();
-                connect(clip, SIGNAL(proxyReady(const QString &, bool)), this, SLOT(slotGotProxy(const QString &, bool)));
-                setProxyStatus(item, 1);
-                clip->generateProxy(m_doc->projectFolder(), proxyParams());
+                if (clip->getProperty("frame_size").section('x', 0, 0).toInt() > proxyMinSize()) {
+                    connect(clip, SIGNAL(proxyReady(const QString &, bool)), this, SLOT(slotGotProxy(const QString &, bool)));
+                    setProxyStatus(item, 1);
+                    clip->generateProxy(m_doc->projectFolder(), proxyParams());
+                }
             }
             else if (!item->referencedClip()->getProperty("proxy").isEmpty()) {
                 // remove proxy