]> git.sesse.net Git - kdenlive/blobdiff - src/trackview.cpp
Disable threads option for rendering Flash.
[kdenlive] / src / trackview.cpp
index 4dbd355d928a481e14b81776d27a6bc11d8114ca..01a9a4a671aee8793b37cd9060038109c5c95955 100644 (file)
@@ -118,7 +118,6 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
 
     slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
     slotSetZone(m_doc->zone(), false);
-    setEnabled(!doc->isReadOnly());
 }
 
 TrackView::~TrackView()
@@ -192,15 +191,8 @@ void TrackView::parseDocument(QDomDocument doc)
     m_documentErrors.clear();
     m_replacementProducerIds.clear();
 
-    //kDebug() << "//// DOCUMENT: " << doc.toString();
-    /*QDomNode props = doc.elementsByTagName("properties").item(0);
-    if (!props.isNull()) {
-        cursorPos = props.toElement().attribute("timeline_position").toInt();
-    }*/
-
     // parse project tracks
     QDomElement mlt = doc.firstChildElement("mlt");
-    if (mlt.hasAttribute("LC_NUMERIC")) m_locale = QLocale(mlt.attribute("LC_NUMERIC"));
     QDomElement tractor = mlt.firstChildElement("tractor");
     QDomNodeList tracks = tractor.elementsByTagName("track");
     QDomNodeList playlists = doc.elementsByTagName("playlist");
@@ -368,13 +360,15 @@ void TrackView::parseDocument(QDomDocument doc)
                                 if (!e.isNull() && e.attribute("tag") == paramName) {
                                     if (e.attribute("type") == "double") {
                                         QString factor = e.attribute("factor", "1");
-                                        if (factor != "1") {
+                                        double offset = e.attribute("offset", "0").toDouble();
+                                        if (factor != "1" || offset != 0) {
                                             double fact;
                                             if (factor.contains('%')) {
                                                 fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
-                                            } else fact = factor.toDouble();
-                                            double val = paramValue.toDouble() * fact;
-                                            paramValue = QString::number(val);
+                                            } else {
+                                                fact = factor.toDouble();
+                                            }
+                                            paramValue = QLocale().toString(offset + paramValue.toDouble() * fact);
                                         }
                                     }
                                     e.setAttribute("value", paramValue);
@@ -414,8 +408,6 @@ void TrackView::parseDocument(QDomDocument doc)
             }
         }
     }
-
-
     QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
 
     // Add guides
@@ -608,8 +600,9 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNod
             double speed = 1.0;
             int strobe = 1;
             if (idString.startsWith("slowmotion")) {
+                QLocale locale;
                 id = idString.section(':', 1, 1);
-                speed = m_locale.toDouble(idString.section(':', 2, 2));
+                speed = locale.toDouble(idString.section(':', 2, 2));
                 strobe = idString.section(':', 3, 3).toInt();
                 if (strobe == 0) strobe = 1;
             }
@@ -750,6 +743,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNod
 void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex)
 {
     int effectNb = 0;
+    QLocale locale;
     for (int ix = 0; ix < effects.count(); ix++) {
         bool disableeffect = false;
         QDomElement effect = effects.at(ix).toElement();
@@ -800,6 +794,7 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                 QString factor;
                 QString starttag;
                 QString endtag;
+                double offset = 0;
                 QDomNodeList params = currenteffect.elementsByTagName("parameter");
                 for (int i = 0; i < params.count(); i++) {
                     QDomElement e = params.item(i).toElement();
@@ -807,6 +802,7 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                         starttag = e.attribute("starttag", "start");
                         endtag = e.attribute("endtag", "end");
                         factor = e.attribute("factor", "1");
+                        offset = e.attribute("offset", "0").toDouble();
                         break;
                     }
                 }
@@ -816,23 +812,24 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                 double startvalue = 0;
                 double endvalue = 0;
                 double fact;
-                if (factor.isEmpty()) fact = 1;
-                else if (factor.contains('%')) {
+                if (factor.contains('%')) {
                     fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
-                } else fact = factor.toDouble();
+                } else {
+                    fact = factor.toDouble();
+                }
                 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
                     // parse effect parameters
                     QDomElement effectparam = n3.toElement();
                     if (effectparam.attribute("name") == starttag)
-                        startvalue = effectparam.text().toDouble() * fact;
+                        startvalue = offset + effectparam.text().toDouble() * fact;
                     if (effectparam.attribute("name") == endtag)
-                        endvalue = effectparam.text().toDouble() * fact;
+                        endvalue = offset + effectparam.text().toDouble() * fact;
                 }
                 // add first keyframe
                 if (effectout <= effectin) {
                     // there is only one keyframe
-                    keyframes.append(QString::number(effectin) + ':' + m_locale.toString(startvalue) + ';');
-                } else keyframes.append(QString::number(effectin) + ':' + m_locale.toString(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
+                    keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';');
+                } else keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
                 QDomNode lastParsedEffect;
                 ix++;
                 QDomNode n2 = effects.at(ix);
@@ -852,12 +849,12 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                             continueParsing = false;
                             break;
                         } else if (subeffectparam.attribute("name") == endtag) {
-                            endvalue = subeffectparam.text().toDouble() * fact;
+                            endvalue = offset + subeffectparam.text().toDouble() * fact;
                             break;
                         }
                     }
                     if (continueParsing) {
-                        keyframes.append(QString::number(effectout) + ':' + m_locale.toString(endvalue) + ';');
+                        keyframes.append(QString::number(effectout) + ':' + locale.toString(endvalue) + ';');
                         ix++;
                     }
                 }
@@ -900,18 +897,19 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                         } else {
                             fact = factor.toDouble();
                         }
+                        double offset = e.attribute("offset", "0").toDouble();
                         if (type == "simplekeyframe") {
                             QStringList kfrs = paramvalue.split(";");
                             for (int l = 0; l < kfrs.count(); l++) {
                                 QString fr = kfrs.at(l).section('=', 0, 0);
-                                double val = m_locale.toDouble(kfrs.at(l).section('=', 1, 1));
-                                //kfrs[l] = fr + ":" + m_locale.toString((int)(val * fact));
-                                kfrs[l] = fr + ":" + QString::number((int) (val * fact));
+                                double val = locale.toDouble(kfrs.at(l).section('=', 1, 1));
+                                //kfrs[l] = fr + ":" + locale.toString((int)(val * fact));
+                                kfrs[l] = fr + ":" + QString::number((int) (offset + val * fact));
                             }
                             e.setAttribute("keyframes", kfrs.join(";"));
                         } else if (type == "double" || type == "constant") {
                             bool ok;
-                            e.setAttribute("value", m_locale.toDouble(paramvalue, &ok) * fact);
+                            e.setAttribute("value", offset + locale.toDouble(paramvalue, &ok) * fact);
                             if (!ok)
                                 e.setAttribute("value", paramvalue);
                         } else {