+int ClipItem::selectedEffectIndex() const {
+ return m_selectedEffect;
+}
+
+
+void ClipItem::setSelectedEffect(int ix) {
+ //if (ix == m_selectedEffect) return;
+ m_selectedEffect = ix;
+ QDomElement effect = effectAt(m_selectedEffect);
+ QDomNodeList params = effect.elementsByTagName("parameter");
+
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull() && e.attribute("type") == "keyframe") {
+ int max = e.attribute("max").toInt();
+ int min = e.attribute("min").toInt();
+ int def = e.attribute("default").toInt();
+ int factor = e.attribute("factor").toInt();
+ if (factor == 0) factor = 1;
+
+ // Effect has a keyframe type parameter, we need to set the values
+ if (e.attribute("keyframes").isEmpty()) {
+ // no keyframes defined, set up 2 keyframes (start and end) with default value.
+ m_keyframes[m_cropStart.frames(m_fps)] = 100 * def / (max - min);
+ m_keyframes[(m_cropStart + m_cropDuration).frames(m_fps)] = 100 * def / (max - min);
+ } else {
+ // parse keyframes
+ QStringList keyframes = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+ foreach(QString str, keyframes) {
+ int pos = str.section(":", 0, 0).toInt();
+ double val = str.section(":", 1, 1).toDouble();
+ m_keyframes[pos] = val;
+ }
+ }
+ update();
+ return;
+ }
+ }
+ if (!m_keyframes.isEmpty()) {
+ m_keyframes.clear();
+ update();
+ }
+}
+
+void ClipItem::updateKeyframeEffect() {
+ QDomElement effect = effectAt(m_selectedEffect);
+ QDomNodeList params = effect.elementsByTagName("parameter");
+
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull() && e.attribute("type") == "keyframe") {
+ int max = e.attribute("max").toInt();
+ int min = e.attribute("min").toInt();
+ int def = e.attribute("default").toInt();
+ int factor = e.attribute("factor").toInt();
+ if (factor == 0) factor = 1;
+ QString keyframes;
+
+ if (m_keyframes.count() > 1) {
+ QMap<int, double>::const_iterator i = m_keyframes.constBegin();
+ double x1;
+ double y1;
+ while (i != m_keyframes.constEnd()) {
+ keyframes.append(QString::number(i.key()) + ":" + QString::number(i.value()) + ";");
+ /*x1 = m_cropDuration.frames(m_fps) * i.key() / 100.0;
+ y1 = (min + i.value() * (max - min) / 100.0) / factor;
+ keyframes.append(QString::number(x1) + ":" + QString::number(y1) + ";");*/
+ ++i;
+ }
+ }
+ // Effect has a keyframe type parameter, we need to set the values
+ kDebug() << "::::::::::::::: SETTING EFFECT KEYFRAMES: " << keyframes;
+ e.setAttribute("keyframes", keyframes);
+ break;
+ }
+ }
+}
+
+QDomElement ClipItem::selectedEffect() {
+ if (m_selectedEffect == -1 || m_effectList.isEmpty()) return QDomElement();
+ return effectAt(m_selectedEffect);
+}
+
+void ClipItem::resetThumbs() {
+ slotFetchThumbs();
+ audioThumbCachePic.clear();
+}
+
+
+void ClipItem::refreshClip() {
+ m_maxDuration = m_clip->maxDuration();
+ if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW) slotFetchThumbs();
+ else if (m_clipType == COLOR) {
+ QString colour = m_clip->getProperty("colour");
+ colour = colour.replace(0, 2, "#");
+ setBrush(QColor(colour.left(7)));
+ } else if (m_clipType == IMAGE || m_clipType == TEXT) {
+ m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(50 * KdenliveSettings::project_display_ratio()), 50);
+ m_endPix = m_startPix;
+ }
+}
+