]> git.sesse.net Git - kdenlive/blobdiff - src/initeffects.cpp
Use const'ref
[kdenlive] / src / initeffects.cpp
index 692b3978f45e98e563b6f3564f9eb0284efeb4b0..e2f7734e6e4073ecbfe7f96b5d9766af4579d69d 100644 (file)
@@ -20,7 +20,6 @@
 #include "initeffects.h"
 #include "kdenlivesettings.h"
 #include "effectslist.h"
-#include "effectstackedit.h"
 #include "mainwindow.h"
 
 #include <KDebug>
@@ -32,6 +31,8 @@
 #include <QDir>
 #include <QIcon>
 
+#include "locale.h"
+
 initEffectsThumbnailer::initEffectsThumbnailer() :
     QThread()
 {
@@ -49,10 +50,10 @@ void initEffectsThumbnailer::run()
     foreach(const QString & entry, m_list) {
         kDebug() << entry;
         if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
-            if (!EffectStackEdit::iconCache.contains(entry)) {
+            if (!MainWindow::m_lumacache.contains(entry)) {
                 QImage pix(entry);
                 //if (!pix.isNull())
-                EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
+               MainWindow::m_lumacache.insert(entry, pix.scaled(30, 30, Qt::KeepAspectRatio, Qt::SmoothTransformation));
                 kDebug() << "stored";
             }
         }
@@ -134,7 +135,7 @@ QDomDocument initEffects::getUsedCustomEffects(QMap <QString, QString> effectids
 }
 
 //static
-void initEffects::parseEffectFiles()
+void initEffects::parseEffectFiles(const QString &locale)
 {
     QStringList::Iterator more;
     QStringList::Iterator it;
@@ -147,6 +148,9 @@ void initEffects::parseEffectFiles()
         return;
     }
 
+    // Warning: Mlt::Factory::init() resets the locale to the default system value, make sure we keep correct locale
+    if (!locale.isEmpty()) setlocale(LC_NUMERIC, locale.toUtf8().constData());
+    
     // Retrieve the list of MLT's available effects.
     Mlt::Properties *filters = repository->filters();
     QStringList filtersList;
@@ -196,8 +200,10 @@ void initEffects::parseEffectFiles()
         while (!in.atEnd()) {
             QString black = in.readLine().simplified();
             if (!black.isEmpty() && !black.startsWith('#') &&
-                    mltFiltersList.contains(black))
+                    mltFiltersList.contains(black)) {
                 mltFiltersList.removeAll(black);
+           }
+           
         }
         file2.close();
     }
@@ -225,8 +231,7 @@ void initEffects::parseEffectFiles()
     MainWindow::transitions.clearList();
     foreach(const QDomElement & effect, effectsMap)
         MainWindow::transitions.append(effect);
-    effectsMap.clear();
-
+    effectsMap.clear();    
     // Create effects from MLT
     foreach(const QString & filtername, mltFiltersList) {
         QDomDocument doc = createDescriptionFromMlt(repository, "filters", filtername);
@@ -239,7 +244,9 @@ void initEffects::parseEffectFiles()
                     if (desc.startsWith("Process audio using a SoX")) {
                         // Remove MLT's SOX generated effects since the parameters properties are unusable for us
                     }
-                    else audioEffectsMap.insert(doc.documentElement().firstChildElement("name").text().toLower().toUtf8().data(), doc.documentElement());
+                    else {
+                       audioEffectsMap.insert(doc.documentElement().firstChildElement("name").text().toLower().toUtf8().data(), doc.documentElement());
+                   }
                 }
             }
             else
@@ -337,7 +344,7 @@ void initEffects::parseCustomEffectsFile()
            }
            effectsMap.insert(groupName.toLower().toUtf8().data(), base);
         } else if (base.tagName() == "effect") {
-            effectsMap.insert(e.firstChildElement("name").text().toLower().toUtf8().data(), base);
+            effectsMap.insert(base.firstChildElement("name").text().toLower().toUtf8().data(), base);
         }
         else kDebug() << "Unsupported effect file: " << itemName;
     }
@@ -478,16 +485,23 @@ QDomDocument initEffects::createDescriptionFromMlt(Mlt::Repository* repository,
                 QDomElement params = ret.createElement("parameter");
 
                 Mlt::Properties paramdesc((mlt_properties) param_props.get_data(param_props.get_name(j)));
-
                 params.setAttribute("name", paramdesc.get("identifier"));
+               if (params.attribute("name") == "argument") {
+                   // This parameter has to be given as attribute when using command line, do not show it in Kdenlive
+                   continue;
+               }
 
                 if (paramdesc.get("maximum")) params.setAttribute("max", paramdesc.get("maximum"));
                 if (paramdesc.get("minimum")) params.setAttribute("min", paramdesc.get("minimum"));
 
                 QString paramType = paramdesc.get("type");
                 
-                if (paramType == "integer")
-                    params.setAttribute("type", "constant");
+                if (paramType == "integer") {
+                   if (params.attribute("min") == "0" && params.attribute("max") == "1")
+                       params.setAttribute("type", "bool");
+                    else params.setAttribute("type", "constant");
+                   
+               }
                 else if (paramType == "float") {
                     params.setAttribute("type", "constant");
                     // param type is float, set default decimals to 3
@@ -512,6 +526,12 @@ QDomDocument initEffects::createDescriptionFromMlt(Mlt::Repository* repository,
                 QDomElement pname = ret.createElement("name");
                 pname.appendChild(ret.createTextNode(paramdesc.get("title")));
                 params.appendChild(pname);
+               
+               if (paramdesc.get("description")) {
+                   QDomElement desc = ret.createElement("comment");
+                   desc.appendChild(ret.createTextNode(paramdesc.get("description")));
+                   params.appendChild(desc);
+               }
 
                 eff.appendChild(params);
             }