]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Add checkbox to "Add clip" dialog to automatically add transparency to images: http...
[kdenlive] / src / projectlist.cpp
index af471ae8daaf903f507278123eefecc9d5a666df..94286501a2b344fe40f9df0ed62957f95902ad38 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) {
@@ -971,9 +971,10 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
         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
@@ -983,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()) {
@@ -1153,8 +1154,7 @@ void ProjectList::updateAllClips()
         //qApp->processEvents();
         ++it;
     }
-    /*if (!m_queueTimer.isActive())
-        m_queueTimer.start();*/
+
     if (!m_queueRunner.isRunning() && m_processingClips.isEmpty()) m_queueRunner = QtConcurrent::run(this, &ProjectList::slotProcessNextClipInQueue);
     if (m_listView->isEnabled())
         monitorItemEditing(true);
@@ -1194,10 +1194,21 @@ void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &group
         const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
         QCheckBox *b = new QCheckBox(i18n("Import image sequence"));
         b->setChecked(KdenliveSettings::autoimagesequence());
-        KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), b);
+        QCheckBox *c = new QCheckBox(i18n("Transparent background for images"));
+        c->setChecked(KdenliveSettings::autoimagetransparency());
+        QFrame *f = new QFrame;
+        f->setFrameShape(QFrame::NoFrame);
+        QHBoxLayout *l = new QHBoxLayout;
+        l->addWidget(b);
+        l->addWidget(c);
+        l->addStretch(5);
+        f->setLayout(l);
+        KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), f);
         d->setOperationMode(KFileDialog::Opening);
         d->setMode(KFile::Files);
-        d->exec();
+        if (d->exec() == QDialog::Accepted) {
+            KdenliveSettings::setAutoimagetransparency(c->isChecked());
+        }
         list = d->selectedUrls();
         if (b->isChecked() && list.count() == 1) {
             // Check for image sequence
@@ -1562,9 +1573,18 @@ 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 size = properties.value("frame_size");
+        DocClipBase *clip = item->referencedClip();
+        if (useProxy() && (item->clipType() == AV || item->clipType() == VIDEO) && 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())
@@ -1573,7 +1593,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;
         }
@@ -1675,6 +1695,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();
@@ -1771,7 +1801,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);
@@ -2028,11 +2058,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