- if (m_valueItems.isEmpty() || m_params.isNull()) return;
- const QDomElement oldparam = m_params.cloneNode().toElement();
- QDomElement newparam = oldparam.cloneNode().toElement();
- QDomNodeList namenode = newparam.elementsByTagName("parameter");
- QLocale locale;
-
- for (int i = 0; i < namenode.count() ; i++) {
- QDomNode pa = namenode.item(i);
- QDomElement na = pa.firstChildElement("name");
- QString type = pa.attributes().namedItem("type").nodeValue();
- QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
- if (type == "complex")
- paramName.append("complex");
- else if (type == "position")
- paramName.append("position");
- else if (type == "geometry")
- paramName.append("geometry");
- else if (type == "keyframe")
- paramName.append("keyframe");
- if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) {
- kDebug() << "// Param: " << paramName << " NOT FOUND";
- continue;
- }
-
- QString setValue;
- if (type == "double" || type == "constant") {
- DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
- setValue = locale.toString(doubleparam->getValue());
- } else if (type == "list") {
- KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
- setValue = box->itemData(box->currentIndex()).toString();
- } else if (type == "bool") {
- QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
- setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
- } else if (type == "color") {
- ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
- setValue = choosecolor->getColor().name();
- } else if (type == "complex") {
- ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
- namenode.item(i) = complex->getParamDesc();
- } else if (type == "geometry") {
- if (KdenliveSettings::on_monitor_effects()) {
- if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue());
- } else {
- Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
- namenode.item(i).toElement().setAttribute("value", geom->getValue());
- }
- } else if (type == "addedgeometry") {
- namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name")));
- } else if (type == "position") {
- PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
- int pos = pedit->getPosition();
- setValue = QString::number(pos);
- if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
- // Make sure duration is not longer than clip
- /*if (pos > m_out) {
- pos = m_out;
- pedit->setPosition(pos);
- }*/
- EffectsList::setParameter(newparam, "in", QString::number(m_in));
- EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
- setValue.clear();
- } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
- // Make sure duration is not longer than clip
- /*if (pos > m_out) {
- pos = m_out;
- pedit->setPosition(pos);
- }*/
- EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
- EffectsList::setParameter(newparam, "out", QString::number(m_out));
- setValue.clear();
- }
- } else if (type == "curve") {
- KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
- QList<QPointF> points = curve->curve().points();
- QString number = pa.attributes().namedItem("number").nodeValue();
- QString inName = pa.attributes().namedItem("inpoints").nodeValue();
- QString outName = pa.attributes().namedItem("outpoints").nodeValue();
- int off = pa.attributes().namedItem("min").nodeValue().toInt();
- int end = pa.attributes().namedItem("max").nodeValue().toInt();
- EffectsList::setParameter(newparam, number, QString::number(points.count()));
- for (int j = 0; (j < points.count() && j + off <= end); j++) {
- QString in = inName;
- in.replace("%i", QString::number(j + off));
- QString out = outName;
- out.replace("%i", QString::number(j + off));
- EffectsList::setParameter(newparam, in, locale.toString(points.at(j).x()));
- EffectsList::setParameter(newparam, out, locale.toString(points.at(j).y()));
- }
- QString depends = pa.attributes().namedItem("depends").nodeValue();
- if (!depends.isEmpty())
- meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
- } else if (type == "bezier_spline") {
- BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
- setValue = widget->spline();
- QString depends = pa.attributes().namedItem("depends").nodeValue();
- if (!depends.isEmpty())
- meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
-#ifdef QJSON
- } else if (type == "roto-spline") {
- RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
- setValue = widget->getSpline();
-#endif
- } else if (type == "wipe") {
- Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
- wipeInfo info;
- if (wp->start_left->isChecked())
- info.start = LEFT;
- else if (wp->start_right->isChecked())
- info.start = RIGHT;
- else if (wp->start_up->isChecked())
- info.start = UP;
- else if (wp->start_down->isChecked())
- info.start = DOWN;
- else if (wp->start_center->isChecked())
- info.start = CENTER;
- else
- info.start = LEFT;
- info.startTransparency = wp->start_transp->value();
-
- if (wp->end_left->isChecked())
- info.end = LEFT;
- else if (wp->end_right->isChecked())
- info.end = RIGHT;
- else if (wp->end_up->isChecked())
- info.end = UP;
- else if (wp->end_down->isChecked())
- info.end = DOWN;
- else if (wp->end_center->isChecked())
- info.end = CENTER;
- else
- info.end = RIGHT;
- info.endTransparency = wp->end_transp->value();
-
- setValue = getWipeString(info);
- } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
- QDomElement elem = pa.toElement();
- QString realName = i18n(na.toElement().text().toUtf8().data());
- QString val = m_keyframeEditor->getValue(realName);
- elem.setAttribute("keyframes", val);
-
- if (m_keyframeEditor->isVisibleParam(realName))
- elem.setAttribute("intimeline", "1");
- else if (elem.hasAttribute("intimeline"))
- elem.removeAttribute("intimeline");
- } else if (type == "url") {
- KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
- setValue = req->url().path();
- }
-
- if (!setValue.isNull())
- pa.attributes().namedItem("value").setNodeValue(setValue);
-
- }
- emit parameterChanged(oldparam, newparam);