]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
Fix "delete" key not working in project tree, allow deletion of several clips at...
[kdenlive] / src / docclipbase.cpp
index 4abf90fb613b2b98acc6e0bf5f6ab478949038c9..e57bca60a67757f03a2eb72b7923b1cd3fc75c4e 100644 (file)
 #include "kthumb.h"
 #include "clipmanager.h"
 
-DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
+DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id):
         m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL), m_clipProducer(NULL) {
     int type = xml.attribute("type").toInt();
     m_clipType = (CLIPTYPE) type;
     m_name = xml.attribute("name");
-    m_id = id;
 
     QDomNamedNodeMap attributes = xml.attributes();
     for (unsigned int i = 0; i < attributes.count(); i++) {
@@ -44,7 +43,8 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
     }
     if (m_name.isEmpty()) m_name = url.fileName();
 
-    if (!url.isEmpty() && QFile::exists(url.path())) {
+    //if (!url.isEmpty() && QFile::exists(url.path()))
+    {
         m_thumbProd = new KThumb(clipManager, url);
         if (m_clipType == AV || m_clipType == AUDIO) slotCreateAudioTimer();
     }
@@ -102,11 +102,11 @@ const QString & DocClipBase::name() const {
     return m_name;
 }
 
-uint DocClipBase::getId() const {
+const QString &DocClipBase::getId() const {
     return m_id;
 }
 
-void DocClipBase::setId(const uint &newId) {
+void DocClipBase::setId(const QString &newId) {
     m_id = newId;
 }
 
@@ -139,6 +139,10 @@ const QString DocClipBase::description() const {
     return m_properties.value("description");
 }
 
+bool DocClipBase::isTransparent() const {
+    return (m_properties.value("transparency") == "1");
+}
+
 const QString DocClipBase::getProperty(const QString prop) const {
     return m_properties.value(prop);
 }
@@ -357,7 +361,9 @@ QString DocClipBase::markerComment(GenTime t) {
 }
 
 void DocClipBase::setProducer(Mlt::Producer *producer) {
+    if (producer == NULL) return;
     m_clipProducer = producer;
+    m_clipProducer->set("transparency", m_properties.value("transparency").toInt());
     if (m_thumbProd) m_thumbProd->setProducer(producer);
 }
 
@@ -398,6 +404,10 @@ void DocClipBase::slotRefreshProducer() {
                 char *tmp = (char *) qstrdup(resource.toUtf8().data());
                 filter->set("luma.resource", tmp);
                 delete[] tmp;
+                if (getProperty("softness") != QString()) {
+                    int soft = getProperty("softness").toInt();
+                    filter->set("luma.softness", (double) soft / 100.0);
+                }
             } else {
                 // filter does not exist, create it...
                 Mlt::Filter *filter = new Mlt::Filter(*(m_clipProducer->profile()), "luma");
@@ -407,6 +417,10 @@ void DocClipBase::slotRefreshProducer() {
                 char *tmp = (char *) qstrdup(resource.toUtf8().data());
                 filter->set("luma.resource", tmp);
                 delete[] tmp;
+                if (getProperty("softness") != QString()) {
+                    int soft = getProperty("softness").toInt();
+                    filter->set("luma.softness", (double) soft / 100.0);
+                }
                 clipService.attach(*filter);
             }
         } else {
@@ -430,13 +444,21 @@ void DocClipBase::setProperties(QMap <QString, QString> properties) {
     QMapIterator<QString, QString> i(properties);
     bool refreshProducer = false;
     QStringList keys;
-    keys << "luma_duration" << "luma_file" << "fade" << "ttl";
+    keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
     while (i.hasNext()) {
         i.next();
         m_properties.insert(i.key(), i.value());
         if (i.key() == "resource") m_thumbProd->updateClipUrl(KUrl(i.value()));
         else if (i.key() == "out") setDuration(GenTime(i.value().toInt(), KdenliveSettings::project_fps()));
         else if (m_clipType == SLIDESHOW && keys.contains(i.key())) refreshProducer = true;
+        else if (i.key() == "transparency") m_clipProducer->set("transparency", i.value().toInt());
+        else if (i.key() == "colour") {
+            char *tmp = (char *) qstrdup(i.value().toUtf8().data());
+            m_clipProducer->set("colour", tmp);
+            delete[] tmp;
+        } else if (i.key() == "xmldata") {
+            m_clipProducer->set("force_reload", 1);
+        }
     }
     if (refreshProducer) slotRefreshProducer();
 }
@@ -445,6 +467,14 @@ void DocClipBase::setProperty(QString key, QString value) {
     m_properties.insert(key, value);
     if (key == "resource") m_thumbProd->updateClipUrl(KUrl(value));
     else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
+    else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
+    else if (key == "colour") {
+        char *tmp = (char *) qstrdup(value.toUtf8().data());
+        m_clipProducer->set("colour", tmp);
+        delete[] tmp;
+    } else if (key == "xmldata") {
+        m_clipProducer->set("force_reload", 1);
+    }
 }
 
 QMap <QString, QString> DocClipBase::properties() const {