From b2bd9defdc3542ea5fbc33d8cb129f08c023d7d1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Fri, 22 Feb 2013 18:39:24 +0100 Subject: [PATCH] Fix keyframes cutting (first part) --- src/clipitem.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index d5372fda..9c7a9a17 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -368,7 +368,7 @@ bool ClipItem::checkKeyFrames() int lastPos = -1; double lastValue = -1; int start = cropStart().frames(m_fps); - int end = (cropStart() + cropDuration()).frames(m_fps); + int end = (cropStart() + cropDuration()).frames(m_fps) - 1; // go through all keyframes for one param foreach(const QString &str, keyframes) { @@ -382,8 +382,8 @@ bool ClipItem::checkKeyFrames() if (pos > start) { int diff = pos - lastPos; double ratio = (double)(start - lastPos) / diff; - double newValue = lastValue + (val - lastValue) * ratio; - newKeyFrames.append(QString::number(start) + ':' + locale.toString(newValue)); + int newValue = lastValue + (val - lastValue) * ratio; + newKeyFrames.append(QString::number(start) + ':' + QString::number(newValue)); modified = true; } cutKeyFrame = false; @@ -394,13 +394,13 @@ bool ClipItem::checkKeyFrames() int diff = pos - lastPos; if (diff != 0) { double ratio = (double)(end - lastPos) / diff; - double newValue = lastValue + (val - lastValue) * ratio; - newKeyFrames.append(QString::number(end) + ':' + locale.toString(newValue)); + int newValue = lastValue + (val - lastValue) * ratio; + newKeyFrames.append(QString::number(end) + ':' + QString::number(newValue)); modified = true; } break; } else { - newKeyFrames.append(QString::number(pos) + ':' + locale.toString(val)); + newKeyFrames.append(QString::number(pos) + ':' + QString::number(val)); } } lastPos = pos; @@ -430,9 +430,9 @@ void ClipItem::setKeyframes(const int ix, const QStringList keyframes) int keyframeParams = 0; for (int i = 0; i < params.count(); i++) { QDomElement e = params.item(i).toElement(); - if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") { + if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && (!e.hasAttribute("intimeline") || e.attribute("intimeline") == "1")) { e.setAttribute("keyframes", keyframes.at(keyframeParams)); - if (ix == m_selectedEffect && keyframeParams == 0) { + if (ix + 1 == m_selectedEffect && keyframeParams == 0) { m_keyframes.clear(); m_visibleParam = i; double max = locale.toDouble(e.attribute("max")); -- 2.39.2