1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include "customtrackview.h"
23 #include "customtrackscene.h"
25 #include "docclipbase.h"
26 #include "transition.h"
27 #include "kdenlivesettings.h"
29 #include "profilesdialog.h"
31 #include "rotoscoping/rotowidget.h"
39 #include <QStyleOptionGraphicsItem>
40 #include <QGraphicsScene>
43 static int FRAME_SIZE;
45 ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, int strobe, int frame_width, bool generateThumbs) :
46 AbstractClipItem(info, QRectF(), fps),
52 m_startPix(QPixmap()),
57 m_startThumbRequested(false),
58 m_endThumbRequested(false),
63 m_limitedKeyFrames(false)
66 FRAME_SIZE = frame_width;
67 setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double) itemHeight());
68 setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1 + itemOffset());
70 // set speed independant info
71 if (m_speed <= 0 && m_speed > -1)
73 m_speedIndependantInfo = m_info;
74 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
75 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
77 m_videoPix = KIcon("kdenlive-show-video").pixmap(QSize(16, 16));
78 m_audioPix = KIcon("kdenlive-show-audio").pixmap(QSize(16, 16));
81 m_clipName = m_clip->name();
83 m_clipName = m_clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
85 m_producer = m_clip->getId();
86 m_clipType = m_clip->clipType();
87 //m_cropStart = info.cropStart;
88 m_maxDuration = m_clip->maxDuration();
90 m_audioThumbReady = m_clip->audioThumbCreated();
91 //setAcceptsHoverEvents(true);
92 connect(this , SIGNAL(prepareAudioThumb(double, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, int, int, int)));
94 if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
95 m_baseColor = QColor(141, 166, 215);
96 if (!m_clip->isPlaceHolder()) {
98 m_startThumbTimer.setSingleShot(true);
99 connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
100 m_endThumbTimer.setSingleShot(true);
101 connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
103 connect(this, SIGNAL(getThumb(int, int)), m_clip, SLOT(slotExtractImage(int, int)));
105 connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
106 connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
107 if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
110 } else if (m_clipType == COLOR) {
111 QString colour = m_clip->getProperty("colour");
112 colour = colour.replace(0, 2, "#");
113 m_baseColor = QColor(colour.left(7));
114 } else if (m_clipType == IMAGE || m_clipType == TEXT) {
115 m_baseColor = QColor(141, 166, 215);
116 if (m_clipType == TEXT) {
117 connect(this, SIGNAL(getThumb(int, int)), m_clip, SLOT(slotExtractImage(int, int)));
118 connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
120 //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
121 } else if (m_clipType == AUDIO) {
122 m_baseColor = QColor(141, 215, 166);
123 connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
128 ClipItem::~ClipItem()
131 if (scene()) scene()->removeItem(this);
132 if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
133 //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
134 //disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
139 ClipItem *ClipItem::clone(ItemInfo info) const
141 ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed, m_strobe, FRAME_SIZE);
142 if (m_clipType == IMAGE || m_clipType == TEXT) duplicate->slotSetStartThumb(m_startPix);
143 else if (m_clipType != COLOR) {
144 if (info.cropStart == m_info.cropStart) duplicate->slotSetStartThumb(m_startPix);
145 if (info.cropStart + (info.endPos - info.startPos) == m_info.cropStart + (m_info.endPos - m_info.startPos)) duplicate->slotSetEndThumb(m_endPix);
147 //kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
148 duplicate->setEffectList(m_effectList);
149 duplicate->setVideoOnly(m_videoOnly);
150 duplicate->setAudioOnly(m_audioOnly);
151 duplicate->setFades(fadeIn(), fadeOut());
152 //duplicate->setSpeed(m_speed);
156 void ClipItem::setEffectList(const EffectsList effectList)
158 m_effectList.clone(effectList);
159 m_effectNames = m_effectList.effectNames().join(" / ");
160 if (!m_effectList.isEmpty()) {
161 for (int i = 0; i < m_effectList.count(); i++) {
162 QString effectId = m_effectList.item(i).attribute("id");
163 // check if it is a fade effect
164 QDomNodeList params = m_effectList.item(i).elementsByTagName("parameter");
166 for (int j = 0; j < params.count(); j++) {
167 QDomElement e = params.item(j).toElement();
169 if (effectId == "fadein") {
170 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
171 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
172 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
174 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
175 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
176 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
178 } else if (effectId == "fade_from_black") {
179 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
180 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
181 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
183 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
184 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
185 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
187 } else if (effectId == "fadeout") {
188 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
189 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
190 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
192 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
193 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
194 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
196 } else if (effectId == "fade_to_black") {
197 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
198 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
199 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
201 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
202 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
203 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
213 setSelectedEffect(0);
217 const EffectsList ClipItem::effectList() const
222 int ClipItem::selectedEffectIndex() const
224 return m_selectedEffect;
227 void ClipItem::initEffect(QDomElement effect, int diff)
229 // the kdenlive_ix int is used to identify an effect in mlt's playlist, should
231 if (effect.attribute("kdenlive_ix").toInt() == 0)
232 effect.setAttribute("kdenlive_ix", QString::number(effectsCounter()));
234 if (effect.attribute("id") == "freeze" && diff > 0) {
235 EffectsList::setParameter(effect, "frame", QString::number(diff));
238 // Init parameter value & keyframes if required
239 QDomNodeList params = effect.elementsByTagName("parameter");
240 for (int i = 0; i < params.count(); i++) {
241 QDomElement e = params.item(i).toElement();
246 // Check if this effect has a variable parameter
247 if (e.attribute("default").contains('%')) {
248 double evaluatedValue = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("default"));
249 e.setAttribute("default", evaluatedValue);
250 if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
251 e.setAttribute("value", evaluatedValue);
255 if (effect.attribute("id") == "crop") {
256 // default use_profile to 1 for clips with proxies to avoid problems when rendering
257 if (e.attribute("name") == "use_profile" && !(m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-"))
258 e.setAttribute("value", "1");
261 if ((e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("keyframes").isEmpty()) {
262 // Effect has a keyframe type parameter, we need to set the values
263 e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + e.attribute("default"));
266 if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
267 if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
268 int end = (cropDuration() + cropStart()).frames(m_fps) - 1;
270 if (effect.attribute("id") == "fadeout") {
271 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
272 int effectDuration = EffectsList::parameter(effect, "in").toInt();
273 if (effectDuration > cropDuration().frames(m_fps)) {
274 effectDuration = cropDuration().frames(m_fps) / 2;
276 start -= effectDuration;
278 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
279 start -= EffectsList::parameter(fadeout, "out").toInt() - EffectsList::parameter(fadeout, "in").toInt();
281 } else if (effect.attribute("id") == "fade_to_black") {
282 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
283 int effectDuration = EffectsList::parameter(effect, "in").toInt();
284 if (effectDuration > cropDuration().frames(m_fps)) {
285 effectDuration = cropDuration().frames(m_fps) / 2;
287 start -= effectDuration;
289 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
290 start -= EffectsList::parameter(fadeout, "out").toInt() - EffectsList::parameter(fadeout, "in").toInt();
293 EffectsList::setParameter(effect, "in", QString::number(start));
294 EffectsList::setParameter(effect, "out", QString::number(end));
295 } else if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
296 int start = cropStart().frames(m_fps);
298 if (effect.attribute("id") == "fadein") {
299 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
300 int effectDuration = EffectsList::parameter(effect, "out").toInt();
301 if (effectDuration > cropDuration().frames(m_fps)) {
302 effectDuration = cropDuration().frames(m_fps) / 2;
304 end += effectDuration;
306 end += EffectsList::parameter(m_effectList.getEffectByTag(QString(), "fade_from_black"), "out").toInt();
307 } else if (effect.attribute("id") == "fade_from_black") {
308 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
309 int effectDuration = EffectsList::parameter(effect, "out").toInt();
310 if (effectDuration > cropDuration().frames(m_fps)) {
311 effectDuration = cropDuration().frames(m_fps) / 2;
313 end += effectDuration;
315 end += EffectsList::parameter(m_effectList.getEffectByTag(QString(), "fadein"), "out").toInt();
317 EffectsList::setParameter(effect, "in", QString::number(start));
318 EffectsList::setParameter(effect, "out", QString::number(end));
323 bool ClipItem::checkKeyFrames()
325 bool clipEffectsModified = false;
327 // go through all effects this clip has
328 for (int ix = 0; ix < m_effectList.count(); ++ix) {
329 QStringList keyframeParams = keyframes(ix);
330 QStringList newKeyFrameParams;
331 bool effModified = false;
333 // go through all params which have keyframes
334 foreach(const QString &kfr, keyframeParams) {
335 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
336 QStringList newKeyFrames;
337 bool cutKeyFrame = false;
338 bool modified = false;
340 double lastValue = -1;
341 int start = cropStart().frames(m_fps);
342 int end = (cropStart() + cropDuration()).frames(m_fps);
344 // go through all keyframes for one param
345 foreach(const QString &str, keyframes) {
346 int pos = str.section(':', 0, 0).toInt();
347 double val = locale.toDouble(str.section(':', 1, 1));
348 if (pos - start < 0) {
349 // a keyframe is defined before the start of the clip
351 } else if (cutKeyFrame) {
352 // create new keyframe at clip start, calculate interpolated value
354 int diff = pos - lastPos;
355 double ratio = (double)(start - lastPos) / diff;
356 double newValue = lastValue + (val - lastValue) * ratio;
357 newKeyFrames.append(QString::number(start) + ':' + locale.toString(newValue));
364 // create new keyframe at clip end, calculate interpolated value
365 int diff = pos - lastPos;
367 double ratio = (double)(end - lastPos) / diff;
368 double newValue = lastValue + (val - lastValue) * ratio;
369 newKeyFrames.append(QString::number(end) + ':' + locale.toString(newValue));
374 newKeyFrames.append(QString::number(pos) + ':' + locale.toString(val));
381 newKeyFrameParams.append(newKeyFrames.join(";"));
388 setKeyframes(ix, newKeyFrameParams);
389 clipEffectsModified = true;
392 return clipEffectsModified;
395 void ClipItem::setKeyframes(const int ix, const QStringList keyframes)
397 QDomElement effect = getEffectAt(ix);
398 if (effect.attribute("disable") == "1") return;
400 QDomNodeList params = effect.elementsByTagName("parameter");
401 int keyframeParams = 0;
402 for (int i = 0; i < params.count(); i++) {
403 QDomElement e = params.item(i).toElement();
404 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
405 e.setAttribute("keyframes", keyframes.at(keyframeParams));
406 if (ix == m_selectedEffect && keyframeParams == 0) {
409 double max = locale.toDouble(e.attribute("max"));
410 double min = locale.toDouble(e.attribute("min"));
411 m_keyframeFactor = 100.0 / (max - min);
412 m_keyframeOffset = min;
413 m_keyframeDefault = locale.toDouble(e.attribute("default"));
414 m_selectedKeyframe = 0;
416 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
417 foreach(const QString &str, keyframes) {
418 int pos = str.section(':', 0, 0).toInt();
419 double val = locale.toDouble(str.section(':', 1, 1));
420 m_keyframes[pos] = val;
422 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
423 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
432 void ClipItem::setSelectedEffect(const int ix)
434 m_selectedEffect = ix;
436 QDomElement effect = effectAt(m_selectedEffect);
437 if (!effect.isNull() && effect.attribute("disable") != "1") {
438 QDomNodeList params = effect.elementsByTagName("parameter");
439 for (int i = 0; i < params.count(); i++) {
440 QDomElement e = params.item(i).toElement();
441 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
443 m_limitedKeyFrames = e.attribute("type") == "keyframe";
445 double max = locale.toDouble(e.attribute("max"));
446 double min = locale.toDouble(e.attribute("min"));
447 m_keyframeFactor = 100.0 / (max - min);
448 m_keyframeOffset = min;
449 m_keyframeDefault = locale.toDouble(e.attribute("default"));
450 m_selectedKeyframe = 0;
453 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
454 foreach(const QString &str, keyframes) {
455 int pos = str.section(':', 0, 0).toInt();
456 double val = locale.toDouble(str.section(':', 1, 1));
457 m_keyframes[pos] = val;
459 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end())
460 m_editedKeyframe = -1;
467 if (!m_keyframes.isEmpty()) {
473 QStringList ClipItem::keyframes(const int index)
476 QDomElement effect = effectAt(index);
477 QDomNodeList params = effect.elementsByTagName("parameter");
479 for (int i = 0; i < params.count(); i++) {
480 QDomElement e = params.item(i).toElement();
481 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe"))
482 result.append(e.attribute("keyframes"));
487 void ClipItem::updateKeyframeEffect()
489 // regenerate xml parameter from the clip keyframes
490 QDomElement effect = getEffectAt(m_selectedEffect);
491 if (effect.attribute("disable") == "1") return;
492 QDomNodeList params = effect.elementsByTagName("parameter");
493 QDomElement e = params.item(m_visibleParam).toElement();
497 if (m_keyframes.count() > 0) {
498 QMap<int, int>::const_iterator i = m_keyframes.constBegin();
499 while (i != m_keyframes.constEnd()) {
500 keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';');
504 // Effect has a keyframe type parameter, we need to set the values
505 e.setAttribute("keyframes", keyframes);
509 QDomElement ClipItem::selectedEffect()
511 if (m_selectedEffect == -1 || m_effectList.isEmpty()) return QDomElement();
512 return effectAt(m_selectedEffect);
515 void ClipItem::resetThumbs(bool clearExistingThumbs)
517 if (clearExistingThumbs) {
518 m_startPix = QPixmap();
519 m_endPix = QPixmap();
520 m_audioThumbCachePic.clear();
522 kDebug()<<"........... RESET THMBS";
527 void ClipItem::refreshClip(bool checkDuration, bool forceResetThumbs)
529 if (checkDuration && (m_maxDuration != m_clip->maxDuration())) {
530 m_maxDuration = m_clip->maxDuration();
531 if (m_clipType != IMAGE && m_clipType != TEXT && m_clipType != COLOR) {
532 if (m_maxDuration != GenTime() && m_info.cropStart + m_info.cropDuration > m_maxDuration) {
533 // Clip duration changed, make sure to stay in correct range
534 if (m_info.cropStart > m_maxDuration) {
535 m_info.cropStart = GenTime();
536 m_info.cropDuration = qMin(m_info.cropDuration, m_maxDuration);
538 m_info.cropDuration = m_maxDuration;
540 updateRectGeometry();
544 if (m_clipType == COLOR) {
545 QString colour = m_clip->getProperty("colour");
546 colour = colour.replace(0, 2, "#");
547 m_baseColor = QColor(colour.left(7));
549 } else resetThumbs(forceResetThumbs);
552 void ClipItem::slotFetchThumbs()
554 if (scene() == NULL || m_clipType == AUDIO || m_clipType == COLOR) return;
555 if (m_clipType == IMAGE) {
556 if (m_startPix.isNull()) {
557 m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
563 if (m_clipType == TEXT) {
564 if (m_startPix.isNull()) slotGetStartThumb();
568 if (m_endPix.isNull() && m_startPix.isNull()) {
569 m_startThumbRequested = true;
570 m_endThumbRequested = true;
571 emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
573 if (m_endPix.isNull()) {
576 if (m_startPix.isNull()) {
582 void ClipItem::slotGetStartThumb()
584 m_startThumbRequested = true;
585 emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), -1);
588 void ClipItem::slotGetEndThumb()
590 m_endThumbRequested = true;
591 emit getThumb(-1, (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
595 void ClipItem::slotSetStartThumb(QImage img)
597 if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
598 QPixmap pix = QPixmap::fromImage(img);
600 QRectF r = sceneBoundingRect();
601 r.setRight(pix.width() + 2);
606 void ClipItem::slotSetEndThumb(QImage img)
608 if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
609 QPixmap pix = QPixmap::fromImage(img);
611 QRectF r = sceneBoundingRect();
612 r.setLeft(r.right() - pix.width() - 2);
617 void ClipItem::slotThumbReady(int frame, QImage img)
619 if (scene() == NULL) return;
620 QRectF r = boundingRect();
621 QPixmap pix = QPixmap::fromImage(img);
622 double width = pix.width() / projectScene()->scale().x();
623 if (m_startThumbRequested && frame == m_speedIndependantInfo.cropStart.frames(m_fps)) {
625 m_startThumbRequested = false;
626 update(r.left(), r.top(), width, pix.height());
627 if (m_clipType == IMAGE || m_clipType == TEXT) {
628 update(r.right() - width, r.top(), width, pix.height());
630 } else if (m_endThumbRequested && frame == (m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1) {
632 m_endThumbRequested = false;
633 update(r.right() - width, r.top(), width, pix.height());
637 void ClipItem::slotSetStartThumb(const QPixmap pix)
642 void ClipItem::slotSetEndThumb(const QPixmap pix)
647 QPixmap ClipItem::startThumb() const
652 QPixmap ClipItem::endThumb() const
657 void ClipItem::slotGotAudioData()
659 m_audioThumbReady = true;
660 if (m_clipType == AV && !isAudioOnly()) {
661 QRectF r = boundingRect();
662 r.setTop(r.top() + r.height() / 2 - 1);
667 int ClipItem::type() const
672 DocClipBase *ClipItem::baseClip() const
677 QDomElement ClipItem::xml() const
682 QDomElement ClipItem::itemXml() const
684 QDomElement xml = m_clip->toXML();
685 if (m_speed != 1.0) xml.setAttribute("speed", m_speed);
686 if (m_strobe > 1) xml.setAttribute("strobe", m_strobe);
687 if (m_audioOnly) xml.setAttribute("audio_only", 1);
688 else if (m_videoOnly) xml.setAttribute("video_only", 1);
692 int ClipItem::clipType() const
697 QString ClipItem::clipName() const
702 void ClipItem::setClipName(const QString &name)
707 const QString ClipItem::clipProducer() const
712 void ClipItem::flashClip()
714 if (m_timeLine == 0) {
715 m_timeLine = new QTimeLine(750, this);
716 m_timeLine->setUpdateInterval(80);
717 m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve);
718 m_timeLine->setFrameRange(0, 100);
719 connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animate(qreal)));
721 //m_timeLine->start();
724 void ClipItem::animate(qreal /*value*/)
726 QRectF r = boundingRect();
732 void ClipItem::paint(QPainter *painter,
733 const QStyleOptionGraphicsItem *option,
738 if (parentItem()) paintColor = QColor(255, 248, 149);
739 else paintColor = m_baseColor;
740 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
741 paintColor = paintColor.darker();
742 framePen.setColor(Qt::red);
743 framePen.setWidthF(2.0);
746 framePen.setColor(paintColor.darker());
749 const QRectF exposed = option->exposedRect;
750 painter->setClipRect(exposed);
751 painter->fillRect(exposed, paintColor);
752 painter->setWorldMatrixEnabled(false);;
753 const QRectF mapped = painter->worldTransform().mapRect(rect());
755 if (KdenliveSettings::videothumbnails() && !isAudioOnly()) {
756 QPen pen = painter->pen();
757 pen.setColor(QColor(255, 255, 255, 150));
758 painter->setPen(pen);
759 if ((m_clipType == IMAGE || m_clipType == TEXT) && !m_startPix.isNull()) {
760 const QPointF top = mapped.topRight() - QPointF(m_startPix.width() - 1, 0);
761 painter->drawPixmap(top, m_startPix);
762 QLineF l2(top.x(), mapped.top(), top.x(), mapped.bottom());
763 painter->drawLine(l2);
764 } else if (!m_endPix.isNull()) {
765 const QPointF top = mapped.topRight() - QPointF(m_endPix.width() - 1, 0);
766 painter->drawPixmap(top, m_endPix);
767 QLineF l2(top.x(), mapped.top(), top.x(), mapped.bottom());
768 painter->drawLine(l2);
770 if (!m_startPix.isNull()) {
771 painter->drawPixmap(mapped.topLeft(), m_startPix);
772 QLineF l2(mapped.left() + m_startPix.width(), mapped.top(), mapped.left() + m_startPix.width(), mapped.bottom());
773 painter->drawLine(l2);
776 // if we are in full zoom, paint thumbnail for every frame
777 if (m_clip->thumbProducer() && clipType() != COLOR && clipType() != AUDIO && !m_audioOnly && painter->worldTransform().m11() == FRAME_SIZE) {
778 int offset = (m_info.startPos - m_info.cropStart).frames(m_fps);
779 int left = qMax((int) m_info.cropStart.frames(m_fps) + 1, (int) mapToScene(exposed.left(), 0).x() - offset);
780 int right = qMin((int)(m_info.cropStart + m_info.cropDuration).frames(m_fps) - 1, (int) mapToScene(exposed.right(), 0).x() - offset);
781 QPointF startPos = mapped.topLeft();
782 int startOffset = m_info.cropStart.frames(m_fps);
783 if (clipType() == IMAGE || clipType() == TEXT) {
784 for (int i = left; i <= right; i++) {
785 painter->drawPixmap(startPos + QPointF(FRAME_SIZE *(i - startOffset), 0), m_startPix);
789 #if KDE_IS_VERSION(4,5,0)
790 if (m_clip && m_clip->thumbProducer()) {
791 QString path = m_clip->fileURL().path() + "_";
794 pen.setStyle(Qt::DotLine);
795 painter->setPen(pen);
797 for (int i = left; i <= right; i++) {
798 img = m_clip->thumbProducer()->findCachedThumb(path + QString::number(i));
799 QPointF xpos = startPos + QPointF(FRAME_SIZE *(i - startOffset), 0);
800 if (img.isNull()) missing << i;
801 else painter->drawImage(xpos, img);
802 painter->drawLine(xpos, xpos + QPointF(0, mapped.height()));
804 if (!missing.isEmpty()) {
805 m_clip->thumbProducer()->queryIntraThumbs(missing);
806 connect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache()));
812 painter->setPen(Qt::black);
815 // draw audio thumbnails
816 if (KdenliveSettings::audiothumbnails() && m_speed == 1.0 && !isVideoOnly() && ((m_clipType == AV && (exposed.bottom() > (rect().height() / 2) || isAudioOnly())) || m_clipType == AUDIO) && m_audioThumbReady) {
818 double startpixel = exposed.left();
821 double endpixel = exposed.right();
824 //kDebug()<<"/// REPAINTING AUDIO THMBS ZONE: "<<startpixel<<"x"<<endpixel;
826 /*QPainterPath path = m_clipType == AV ? roundRectPathLower : resultClipPath;*/
828 if (m_clipType == AV && !isAudioOnly()) {
830 mappedRect.setTop(mappedRect.bottom() - mapped.height() / 2);
831 } else mappedRect = mapped;
833 double scale = painter->worldTransform().m11();
835 if (isEnabled() && m_clip) channels = m_clip->getProperty("channels").toInt();
836 if (scale != m_framePixelWidth)
837 m_audioThumbCachePic.clear();
838 double cropLeft = m_info.cropStart.frames(m_fps);
839 const int clipStart = mappedRect.x();
840 const int mappedStartPixel = painter->worldTransform().map(QPointF(startpixel + cropLeft, 0)).x() - clipStart;
841 const int mappedEndPixel = painter->worldTransform().map(QPointF(endpixel + cropLeft, 0)).x() - clipStart;
842 cropLeft = cropLeft * scale;
845 emit prepareAudioThumb(scale, mappedStartPixel, mappedEndPixel, channels);
848 for (int startCache = mappedStartPixel - (mappedStartPixel) % 100; startCache < mappedEndPixel; startCache += 100) {
849 if (m_audioThumbCachePic.contains(startCache) && !m_audioThumbCachePic[startCache].isNull())
850 painter->drawPixmap(clipStart + startCache - cropLeft, mappedRect.y(), m_audioThumbCachePic[startCache]);
854 // only paint details if clip is big enough
855 if (mapped.width() > 20) {
857 // Draw effects names
858 if (!m_effectNames.isEmpty() && mapped.width() > 40) {
859 QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignLeft | Qt::AlignTop, m_effectNames);
861 if (m_timeLine && m_timeLine->state() == QTimeLine::Running) {
862 qreal value = m_timeLine->currentValue();
863 txtBounding.setWidth(txtBounding.width() * value);
864 bgColor.setRgb(50 + 200 *(1.0 - value), 50, 50, 100 + 50 * value);
865 } else bgColor.setRgb(50, 50, 90, 180);
867 QPainterPath rounded;
868 rounded.moveTo(txtBounding.bottomRight());
869 rounded.arcTo(txtBounding.right() - txtBounding.height() - 2, txtBounding.top() - txtBounding.height(), txtBounding.height() * 2, txtBounding.height() * 2, 270, 90);
870 rounded.lineTo(txtBounding.topLeft());
871 rounded.lineTo(txtBounding.bottomLeft());
872 painter->fillPath(rounded, bgColor);
873 painter->setPen(Qt::lightGray);
874 painter->drawText(txtBounding.adjusted(1, 0, 1, 0), Qt::AlignCenter, m_effectNames);
877 const QRectF txtBounding2 = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + m_clipName + ' ');
878 painter->setBrush(framePen.color());
879 painter->setPen(Qt::NoPen);
880 painter->drawRoundedRect(txtBounding2, 3, 3);
881 painter->setBrush(QBrush(Qt::NoBrush));
884 painter->drawPixmap(txtBounding2.topLeft() - QPointF(17, -1), m_videoPix);
885 } else if (m_audioOnly) {
886 painter->drawPixmap(txtBounding2.topLeft() - QPointF(17, -1), m_audioPix);
888 painter->setPen(Qt::white);
889 painter->drawText(txtBounding2, Qt::AlignCenter, m_clipName);
893 if (isEnabled() && m_clip) {
894 QList < CommentedTime > markers = m_clip->commentedSnapMarkers();
895 QList < CommentedTime >::Iterator it = markers.begin();
898 QBrush markerBrush(QColor(120, 120, 0, 140));
899 QPen pen = painter->pen();
900 pen.setColor(QColor(255, 255, 255, 200));
901 pen.setStyle(Qt::DotLine);
903 for (; it != markers.end(); ++it) {
904 pos = GenTime((int)((*it).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
905 if (pos > GenTime()) {
906 if (pos > cropDuration()) break;
907 QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
908 QLineF l2 = painter->worldTransform().map(l);
909 painter->setPen(pen);
910 painter->drawLine(l2);
911 if (KdenliveSettings::showmarkers()) {
912 framepos = rect().x() + pos.frames(m_fps);
913 const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
914 const QRectF r2 = painter->worldTransform().mapRect(r1);
915 const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
916 painter->setBrush(markerBrush);
917 painter->setPen(Qt::NoPen);
918 painter->drawRoundedRect(txtBounding3, 3, 3);
919 painter->setBrush(QBrush(Qt::NoBrush));
920 painter->setPen(Qt::white);
921 painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
923 //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
928 // draw start / end fades
931 fades = QBrush(QColor(200, 50, 50, 150));
932 } else fades = QBrush(QColor(200, 200, 200, 200));
934 if (m_startFade != 0) {
935 QPainterPath fadeInPath;
936 fadeInPath.moveTo(0, 0);
937 fadeInPath.lineTo(0, rect().height());
938 fadeInPath.lineTo(m_startFade, 0);
939 fadeInPath.closeSubpath();
940 QPainterPath f1 = painter->worldTransform().map(fadeInPath);
941 painter->fillPath(f1/*.intersected(resultClipPath)*/, fades);
942 /*if (isSelected()) {
943 QLineF l(m_startFade * scale, 0, 0, itemHeight);
944 painter->drawLine(l);
947 if (m_endFade != 0) {
948 QPainterPath fadeOutPath;
949 fadeOutPath.moveTo(rect().width(), 0);
950 fadeOutPath.lineTo(rect().width(), rect().height());
951 fadeOutPath.lineTo(rect().width() - m_endFade, 0);
952 fadeOutPath.closeSubpath();
953 QPainterPath f1 = painter->worldTransform().map(fadeOutPath);
954 painter->fillPath(f1/*.intersected(resultClipPath)*/, fades);
955 /*if (isSelected()) {
956 QLineF l(itemWidth - m_endFade * scale, 0, itemWidth, itemHeight);
957 painter->drawLine(l);
962 painter->setPen(QPen(Qt::lightGray));
963 // draw effect or transition keyframes
964 drawKeyFrames(painter, m_limitedKeyFrames);
968 // expand clip rect to allow correct painting of clip border
969 painter->setClipping(false);
970 painter->setPen(framePen);
971 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
972 painter->drawRect(mapped.adjusted(0.5, 0.5, -0.5, -0.5));
975 painter->drawRect(mapped.adjusted(0, 0, -0.5, 0));
980 OPERATIONTYPE ClipItem::operationMode(QPointF pos)
982 if (isItemLocked()) return NONE;
983 const double scale = projectScene()->scale().x();
984 double maximumOffset = 6 / scale;
985 if (isSelected() || (parentItem() && parentItem()->isSelected())) {
986 int kf = mouseOverKeyFrames(pos, maximumOffset);
988 m_editedKeyframe = kf;
992 QRectF rect = sceneBoundingRect();
993 int addtransitionOffset = 10;
994 // Don't allow add transition if track height is very small
995 if (rect.height() < 30) addtransitionOffset = 0;
997 if (qAbs((int)(pos.x() - (rect.x() + m_startFade))) < maximumOffset && qAbs((int)(pos.y() - rect.y())) < 6) {
999 } else if (pos.x() - rect.x() < maximumOffset && (rect.bottom() - pos.y() > addtransitionOffset)) {
1001 } else if (qAbs((int)(pos.x() - (rect.x() + rect.width() - m_endFade))) < maximumOffset && qAbs((int)(pos.y() - rect.y())) < 6) {
1003 } else if ((rect.right() - pos.x() < maximumOffset) && (rect.bottom() - pos.y() > addtransitionOffset)) {
1005 } else if ((pos.x() - rect.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
1006 return TRANSITIONSTART;
1007 } else if ((rect.right() - pos.x() < 16 / scale) && (rect.bottom() - pos.y() <= addtransitionOffset)) {
1008 return TRANSITIONEND;
1014 int ClipItem::itemHeight()
1016 return KdenliveSettings::trackheight() - 2;
1019 void ClipItem::resetFrameWidth(int width)
1025 QList <GenTime> ClipItem::snapMarkers() const
1027 QList < GenTime > snaps;
1028 QList < GenTime > markers = baseClip()->snapMarkers();
1031 for (int i = 0; i < markers.size(); i++) {
1032 pos = GenTime((int)(markers.at(i).frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
1033 if (pos > GenTime()) {
1034 if (pos > cropDuration()) break;
1035 else snaps.append(pos + startPos());
1041 QList <CommentedTime> ClipItem::commentedSnapMarkers() const
1043 QList < CommentedTime > snaps;
1044 QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
1047 for (int i = 0; i < markers.size(); i++) {
1048 pos = GenTime((int)(markers.at(i).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
1049 if (pos > GenTime()) {
1050 if (pos > cropDuration()) break;
1051 else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment()));
1057 void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, int endpixel, int channels)
1059 QRectF re = sceneBoundingRect();
1060 if (m_clipType == AV && !isAudioOnly()) re.setTop(re.y() + re.height() / 2);
1062 //kDebug() << "// PREP AUDIO THMB FRMO : scale:" << pixelForOneFrame<< ", from: " << startpixel << ", to: " << endpixel;
1063 //if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
1065 for (int startCache = startpixel - startpixel % 100; startCache < endpixel; startCache += 100) {
1066 //kDebug() << "creating " << startCache;
1067 //if (framePixelWidth!=pixelForOneFrame ||
1068 if (m_framePixelWidth == pixelForOneFrame && m_audioThumbCachePic.contains(startCache))
1070 if (m_audioThumbCachePic[startCache].isNull() || m_framePixelWidth != pixelForOneFrame) {
1071 m_audioThumbCachePic[startCache] = QPixmap(100, (int)(re.height()));
1072 m_audioThumbCachePic[startCache].fill(QColor(180, 180, 200, 140));
1074 bool fullAreaDraw = pixelForOneFrame < 10;
1075 QMap<int, QPainterPath > positiveChannelPaths;
1076 QMap<int, QPainterPath > negativeChannelPaths;
1077 QPainter pixpainter(&m_audioThumbCachePic[startCache]);
1079 audiopen.setWidth(0);
1080 pixpainter.setPen(audiopen);
1081 //pixpainter.setRenderHint(QPainter::Antialiasing,true);
1082 //pixpainter.drawLine(0,0,100,re.height());
1083 // Bail out, if caller provided invalid data
1084 if (channels <= 0) {
1085 kWarning() << "Unable to draw image with " << channels << "number of channels";
1089 int channelHeight = m_audioThumbCachePic[startCache].height() / channels;
1091 for (int i = 0; i < channels; i++) {
1093 positiveChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
1094 negativeChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
1097 for (int samples = 0; samples <= 100; samples++) {
1098 double frame = (double)(samples + startCache - 0) / pixelForOneFrame;
1099 int sample = (int)((frame - (int)(frame)) * 20); // AUDIO_FRAME_SIZE
1100 if (frame < 0 || sample < 0 || sample > 19)
1102 QMap<int, QByteArray> frame_channel_data = baseClip()->m_audioFrameCache[(int)frame];
1104 for (int channel = 0; channel < channels && frame_channel_data[channel].size() > 0; channel++) {
1106 int y = channelHeight * channel + channelHeight / 2;
1107 int delta = (int)(frame_channel_data[channel][sample] - 127 / 2) * channelHeight / 64;
1109 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + qAbs(delta));
1110 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - qAbs(delta));
1112 positiveChannelPaths[channel].lineTo(samples, 0.1 + y + delta);
1113 negativeChannelPaths[channel].lineTo(samples, 0.1 + y - delta);
1116 for (int channel = 0; channel < channels ; channel++)
1117 if (fullAreaDraw && samples == 100) {
1118 positiveChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
1119 negativeChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
1120 positiveChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
1121 negativeChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
1125 pixpainter.setPen(QPen(QColor(0, 0, 0)));
1126 pixpainter.setBrush(QBrush(QColor(60, 60, 60)));
1128 for (int i = 0; i < channels; i++) {
1130 //pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
1131 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
1133 pixpainter.drawPath(positiveChannelPaths[i]);
1136 //audioThumbWasDrawn=true;
1137 m_framePixelWidth = pixelForOneFrame;
1142 int ClipItem::fadeIn() const
1147 int ClipItem::fadeOut() const
1153 void ClipItem::setFadeIn(int pos)
1155 if (pos == m_startFade) return;
1156 int oldIn = m_startFade;
1157 m_startFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
1158 QRectF rect = boundingRect();
1159 update(rect.x(), rect.y(), qMax(oldIn, m_startFade), rect.height());
1162 void ClipItem::setFadeOut(int pos)
1164 if (pos == m_endFade) return;
1165 int oldOut = m_endFade;
1166 m_endFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
1167 QRectF rect = boundingRect();
1168 update(rect.x() + rect.width() - qMax(oldOut, m_endFade), rect.y(), qMax(oldOut, m_endFade), rect.height());
1172 void ClipItem::setFades(int in, int out)
1180 void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
1182 //if (e->pos().x() < 20) m_hover = true;
1184 if (isItemLocked()) return;
1186 QRectF r = boundingRect();
1187 double width = 35 / projectScene()->scale().x();
1188 double height = r.height() / 2;
1189 //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
1190 update(r.x(), r.y() + height, width, height);
1191 update(r.right() - width, r.y() + height, width, height);
1195 void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
1197 if (isItemLocked()) return;
1199 QRectF r = boundingRect();
1200 double width = 35 / projectScene()->scale().x();
1201 double height = r.height() / 2;
1202 //WARNING: seems like it generates a full repaint of the clip, maybe not so good...
1203 update(r.x(), r.y() + height, width, height);
1204 update(r.right() - width, r.y() + height, width, height);
1208 void ClipItem::resizeStart(int posx, bool /*size*/)
1210 bool sizeLimit = false;
1211 if (clipType() != IMAGE && clipType() != COLOR && clipType() != TEXT) {
1212 const int min = (startPos() - cropStart()).frames(m_fps);
1213 if (posx < min) posx = min;
1217 if (posx == startPos().frames(m_fps)) return;
1218 const int previous = cropStart().frames(m_fps);
1219 AbstractClipItem::resizeStart(posx, sizeLimit);
1221 // set speed independant info
1222 m_speedIndependantInfo = m_info;
1223 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
1224 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
1226 if ((int) cropStart().frames(m_fps) != previous) {
1227 if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
1228 m_startThumbTimer.start(150);
1233 void ClipItem::resizeEnd(int posx)
1235 const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps);
1236 if (posx > max && maxDuration() != GenTime()) posx = max;
1237 if (posx == endPos().frames(m_fps)) return;
1238 //kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
1239 const int previous = cropDuration().frames(m_fps);
1240 AbstractClipItem::resizeEnd(posx);
1242 // set speed independant info
1243 m_speedIndependantInfo = m_info;
1244 m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
1245 m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
1247 if ((int) cropDuration().frames(m_fps) != previous) {
1248 if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
1249 m_endThumbTimer.start(150);
1255 QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
1257 if (change == QGraphicsItem::ItemSelectedChange) {
1258 if (value.toBool()) setZValue(10);
1261 if (change == ItemPositionChange && scene()) {
1262 // calculate new position.
1263 //if (parentItem()) return pos();
1264 QPointF newPos = value.toPointF();
1265 //kDebug() << "/// MOVING CLIP ITEM.------------\n++++++++++";
1266 int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
1267 xpos = qMax(xpos, 0);
1269 int newTrack = newPos.y() / KdenliveSettings::trackheight();
1270 newTrack = qMin(newTrack, projectScene()->tracksCount() - 1);
1271 newTrack = qMax(newTrack, 0);
1272 newPos.setY((int)(newTrack * KdenliveSettings::trackheight() + 1));
1273 // Only one clip is moving
1274 QRectF sceneShape = rect();
1275 sceneShape.translate(newPos);
1276 QList<QGraphicsItem*> items;
1277 if (projectScene()->editMode() == NORMALEDIT)
1278 items = scene()->items(sceneShape, Qt::IntersectsItemShape);
1279 items.removeAll(this);
1280 bool forwardMove = newPos.x() > pos().x();
1282 if (!items.isEmpty()) {
1283 for (int i = 0; i < items.count(); i++) {
1284 if (!items.at(i)->isEnabled()) continue;
1285 if (items.at(i)->type() == type()) {
1287 QPointF otherPos = items.at(i)->pos();
1288 if ((int) otherPos.y() != (int) pos().y()) {
1292 offset = qMax(offset, (int)(newPos.x() - (static_cast < AbstractClipItem* >(items.at(i))->startPos() - cropDuration()).frames(m_fps)));
1294 offset = qMax(offset, (int)((static_cast < AbstractClipItem* >(items.at(i))->endPos().frames(m_fps)) - newPos.x()));
1299 sceneShape.translate(QPointF(-offset, 0));
1300 newPos.setX(newPos.x() - offset);
1302 sceneShape.translate(QPointF(offset, 0));
1303 newPos.setX(newPos.x() + offset);
1305 QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
1306 subitems.removeAll(this);
1307 for (int j = 0; j < subitems.count(); j++) {
1308 if (!subitems.at(j)->isEnabled()) continue;
1309 if (subitems.at(j)->type() == type()) {
1310 // move was not successful, revert to previous pos
1311 m_info.startPos = GenTime((int) pos().x(), m_fps);
1317 m_info.track = newTrack;
1318 m_info.startPos = GenTime((int) newPos.x(), m_fps);
1324 m_info.track = newTrack;
1325 m_info.startPos = GenTime((int) newPos.x(), m_fps);
1326 //kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
1329 return QGraphicsItem::itemChange(change, value);
1333 /*void ClipItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
1336 int ClipItem::effectsCounter()
1338 return effectsCount() + 1;
1341 int ClipItem::effectsCount()
1343 return m_effectList.count();
1346 int ClipItem::hasEffect(const QString &tag, const QString &id) const
1348 return m_effectList.hasEffect(tag, id);
1351 QStringList ClipItem::effectNames()
1353 return m_effectList.effectNames();
1356 QDomElement ClipItem::effectAt(int ix) const
1358 if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
1359 return m_effectList.at(ix).cloneNode().toElement();
1362 QDomElement ClipItem::getEffectAt(int ix) const
1364 if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
1365 return m_effectList.at(ix);
1368 void ClipItem::setEffectAt(int ix, QDomElement effect)
1370 if (ix < 0 || ix > (m_effectList.count() - 1) || effect.isNull()) {
1371 kDebug() << "Invalid effect index: " << ix;
1374 //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
1375 effect.setAttribute("kdenlive_ix", ix + 1);
1376 m_effectList.replace(ix, effect);
1377 m_effectNames = m_effectList.effectNames().join(" / ");
1378 QString id = effect.attribute("id");
1379 if (id == "fadein" || id == "fadeout" || id == "fade_from_black" || id == "fade_to_black")
1382 QRectF r = boundingRect();
1388 EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animate*/)
1390 bool needRepaint = false;
1393 if (!effect.hasAttribute("kdenlive_ix")) {
1394 ix = effectsCounter();
1395 } else ix = effect.attribute("kdenlive_ix").toInt();
1396 if (!m_effectList.isEmpty() && ix <= m_effectList.count()) {
1398 m_effectList.insert(ix - 1, effect);
1399 for (int i = ix; i < m_effectList.count(); i++) {
1400 int index = m_effectList.item(i).attribute("kdenlive_ix").toInt();
1401 if (index >= ix) m_effectList.item(i).setAttribute("kdenlive_ix", index + 1);
1403 } else m_effectList.append(effect);
1404 EffectsParameterList parameters;
1405 parameters.addParam("tag", effect.attribute("tag"));
1406 parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
1407 if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
1408 if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
1410 QString effectId = effect.attribute("id");
1411 if (effectId.isEmpty()) effectId = effect.attribute("tag");
1412 parameters.addParam("id", effectId);
1414 // special case: the affine effect needs in / out points
1416 QDomNodeList params = effect.elementsByTagName("parameter");
1418 bool needInOutSync = false;
1419 for (int i = 0; i < params.count(); i++) {
1420 QDomElement e = params.item(i).toElement();
1422 if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
1423 // Effects with a geometry parameter need to sync in / out with parent clip
1424 needInOutSync = true;
1426 if (e.attribute("type") == "simplekeyframe") {
1427 QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
1428 double factor = locale.toDouble(e.attribute("factor", "1"));
1429 double offset = e.attribute("offset", "0").toDouble();
1430 if (factor != 1 || offset != 0) {
1431 for (int j = 0; j < values.count(); j++) {
1432 QString pos = values.at(j).section(':', 0, 0);
1433 double val = (locale.toDouble(values.at(j).section(':', 1, 1)) - offset) / factor;
1434 values[j] = pos + "=" + locale.toString(val);
1437 parameters.addParam(e.attribute("name"), values.join(";"));
1438 /*parameters.addParam("max", e.attribute("max"));
1439 parameters.addParam("min", e.attribute("min"));
1440 parameters.addParam("factor", );*/
1441 } else if (e.attribute("type") == "keyframe") {
1442 parameters.addParam("keyframes", e.attribute("keyframes"));
1443 parameters.addParam("max", e.attribute("max"));
1444 parameters.addParam("min", e.attribute("min"));
1445 parameters.addParam("factor", e.attribute("factor", "1"));
1446 parameters.addParam("offset", e.attribute("offset", "0"));
1447 parameters.addParam("starttag", e.attribute("starttag", "start"));
1448 parameters.addParam("endtag", e.attribute("endtag", "end"));
1449 } else if (e.attribute("factor", "1") == "1" && e.attribute("offset", "0") == "0") {
1450 parameters.addParam(e.attribute("name"), e.attribute("value"));
1452 // check if it is a fade effect
1453 if (effectId == "fadein") {
1455 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
1456 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
1457 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
1459 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
1460 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
1461 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
1463 } else if (effectId == "fade_from_black") {
1465 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
1466 if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
1467 else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
1469 QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
1470 if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
1471 else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
1473 } else if (effectId == "fadeout") {
1475 if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
1476 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
1477 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
1479 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
1480 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
1481 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
1483 } else if (effectId == "fade_to_black") {
1485 if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
1486 if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
1487 else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
1489 QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
1490 if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
1491 else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
1496 if (e.attribute("factor").contains('%')) {
1497 fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
1499 fact = locale.toDouble(e.attribute("factor", "1"));
1501 double offset = e.attribute("offset", "0").toDouble();
1502 parameters.addParam(e.attribute("name"), locale.toString((locale.toDouble(e.attribute("value")) - offset) / fact));
1506 if (needInOutSync) {
1507 parameters.addParam("in", QString::number(cropStart().frames(m_fps)));
1508 parameters.addParam("out", QString::number((cropStart() + cropDuration()).frames(m_fps) - 1));
1509 parameters.addParam("_sync_in_out", "1");
1511 m_effectNames = m_effectList.effectNames().join(" / ");
1512 if (fade > 0) m_startFade = fade;
1513 else if (fade < 0) m_endFade = -fade;
1515 if (m_selectedEffect == -1) {
1516 setSelectedEffect(0);
1517 } else if (m_selectedEffect == ix - 1) setSelectedEffect(m_selectedEffect);
1518 if (needRepaint) update(boundingRect());
1522 else { /*if (!needRepaint) */
1523 QRectF r = boundingRect();
1530 void ClipItem::deleteEffect(QString index)
1532 bool needRepaint = false;
1535 for (int i = 0; i < m_effectList.count(); ++i) {
1536 ix = m_effectList.at(i).attribute("kdenlive_ix");
1538 QString effectId = m_effectList.at(i).attribute("id");
1539 if ((effectId == "fadein" && hasEffect(QString(), "fade_from_black") == -1) ||
1540 (effectId == "fade_from_black" && hasEffect(QString(), "fadein") == -1)) {
1543 } else if ((effectId == "fadeout" && hasEffect(QString(), "fade_to_black") == -1) ||
1544 (effectId == "fade_to_black" && hasEffect(QString(), "fadeout") == -1)) {
1547 } else if (EffectsList::hasKeyFrames(m_effectList.at(i))) needRepaint = true;
1548 m_effectList.removeAt(i);
1550 } else if (ix.toInt() > index.toInt()) {
1551 m_effectList.item(i).setAttribute("kdenlive_ix", ix.toInt() - 1);
1554 m_effectNames = m_effectList.effectNames().join(" / ");
1556 if (m_effectList.isEmpty() || m_selectedEffect + 1 == index.toInt()) {
1557 // Current effect was removed
1558 if (index.toInt() > m_effectList.count() - 1) {
1559 setSelectedEffect(m_effectList.count() - 1);
1560 } else setSelectedEffect(index.toInt());
1562 if (needRepaint) update(boundingRect());
1564 QRectF r = boundingRect();
1568 //if (!m_effectList.isEmpty()) flashClip();
1571 double ClipItem::speed() const
1576 int ClipItem::strobe() const
1581 void ClipItem::setSpeed(const double speed, const int strobe)
1584 if (m_speed <= 0 && m_speed > -1)
1587 if (m_speed == 1.0) m_clipName = baseClip()->name();
1588 else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + '%';
1589 m_info.cropStart = GenTime((int)(m_speedIndependantInfo.cropStart.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1590 m_info.cropDuration = GenTime((int)(m_speedIndependantInfo.cropDuration.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1594 GenTime ClipItem::maxDuration() const
1596 return GenTime((int)(m_maxDuration.frames(m_fps) / qAbs(m_speed) + 0.5), m_fps);
1599 GenTime ClipItem::speedIndependantCropStart() const
1601 return m_speedIndependantInfo.cropStart;
1604 GenTime ClipItem::speedIndependantCropDuration() const
1606 return m_speedIndependantInfo.cropDuration;
1610 const ItemInfo ClipItem::speedIndependantInfo() const
1612 return m_speedIndependantInfo;
1616 void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event)
1618 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
1620 doc.setContent(effects, true);
1621 const QDomElement e = doc.documentElement();
1622 if (scene() && !scene()->views().isEmpty()) {
1624 CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1625 if (view) view->slotAddEffect(e, m_info.startPos, track());
1630 void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
1632 if (isItemLocked()) event->setAccepted(false);
1633 else event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
1636 void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
1641 void ClipItem::addTransition(Transition* t)
1643 m_transitionsList.append(t);
1644 //CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1646 QDomElement e = doc.documentElement();
1647 //if (view) view->slotAddTransition(this, t->toXML() , t->startPos(), track());
1650 void ClipItem::setVideoOnly(bool force)
1652 m_videoOnly = force;
1655 void ClipItem::setAudioOnly(bool force)
1657 m_audioOnly = force;
1658 if (m_audioOnly) m_baseColor = QColor(141, 215, 166);
1660 if (m_clipType == COLOR) {
1661 QString colour = m_clip->getProperty("colour");
1662 colour = colour.replace(0, 2, "#");
1663 m_baseColor = QColor(colour.left(7));
1664 } else if (m_clipType == AUDIO) m_baseColor = QColor(141, 215, 166);
1665 else m_baseColor = QColor(141, 166, 215);
1667 m_audioThumbCachePic.clear();
1670 bool ClipItem::isAudioOnly() const
1675 bool ClipItem::isVideoOnly() const
1680 void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
1682 if (effect.attribute("disable") == "1") return;
1684 effect.setAttribute("active_keyframe", pos);
1685 m_editedKeyframe = pos;
1686 QDomNodeList params = effect.elementsByTagName("parameter");
1687 for (int i = 0; i < params.count(); i++) {
1688 QDomElement e = params.item(i).toElement();
1689 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
1690 QString kfr = e.attribute("keyframes");
1691 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
1694 foreach(const QString &str, keyframes) {
1695 int kpos = str.section(':', 0, 0).toInt();
1696 double newval = locale.toDouble(str.section(':', 1, 1));
1699 } else if (!added) {
1700 if (i == m_visibleParam)
1701 newkfr.append(QString::number(pos) + ":" + QString::number(val));
1703 newkfr.append(QString::number(pos) + ":" + locale.toString(newval));
1704 if (kpos > pos) newkfr.append(str);
1706 } else newkfr.append(str);
1709 if (i == m_visibleParam)
1710 newkfr.append(QString::number(pos) + ":" + QString::number(val));
1712 newkfr.append(QString::number(pos) + ":" + e.attribute("default"));
1714 e.setAttribute("keyframes", newkfr.join(";"));
1719 void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double value)
1721 if (effect.attribute("disable") == "1") return;
1723 effect.setAttribute("active_keyframe", newpos);
1724 QDomNodeList params = effect.elementsByTagName("parameter");
1725 int start = cropStart().frames(m_fps);
1726 int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
1727 for (int i = 0; i < params.count(); i++) {
1728 QDomElement e = params.item(i).toElement();
1729 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
1730 QString kfr = e.attribute("keyframes");
1731 const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
1733 foreach(const QString &str, keyframes) {
1734 if (str.section(':', 0, 0).toInt() != oldpos) {
1736 } else if (newpos != -1) {
1737 newpos = qMax(newpos, start);
1738 newpos = qMin(newpos, end);
1739 if (i == m_visibleParam)
1740 newkfr.append(QString::number(newpos) + ":" + locale.toString(value));
1742 newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1));
1745 e.setAttribute("keyframes", newkfr.join(";"));
1749 updateKeyframes(effect);
1753 void ClipItem::updateKeyframes(QDomElement effect)
1755 m_keyframes.clear();
1758 QDomNodeList params = effect.elementsByTagName("parameter");
1759 QDomElement e = params.item(m_visibleParam).toElement();
1760 if (e.attribute("intimeline") != "1") {
1761 setSelectedEffect(m_selectedEffect);
1764 m_limitedKeyFrames = e.attribute("type") == "keyframe";
1765 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
1766 foreach(const QString &str, keyframes) {
1767 int pos = str.section(':', 0, 0).toInt();
1768 double val = locale.toDouble(str.section(':', 1, 1));
1769 m_keyframes[pos] = val;
1771 if (!m_keyframes.contains(m_selectedKeyframe)) m_selectedKeyframe = -1;
1774 Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
1777 return m_clip->audioProducer(track);
1778 else if (isVideoOnly())
1779 return m_clip->videoProducer();
1781 return m_clip->producer(trackSpecific ? track : -1);
1784 QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo)
1786 QMap<int, QDomElement> effects;
1787 for (int i = 0; i < m_effectList.count(); i++) {
1788 QDomElement effect = m_effectList.at(i);
1790 if (effect.attribute("id").startsWith("fade")) {
1791 QString id = effect.attribute("id");
1792 int in = EffectsList::parameter(effect, "in").toInt();
1793 int out = EffectsList::parameter(effect, "out").toInt();
1794 int clipEnd = (cropStart() + cropDuration()).frames(m_fps) - 1;
1795 if (id == "fade_from_black" || id == "fadein") {
1796 if (in != cropStart().frames(m_fps)) {
1797 effects[i] = effect.cloneNode().toElement();
1798 int diff = in - cropStart().frames(m_fps);
1801 EffectsList::setParameter(effect, "in", QString::number(in));
1802 EffectsList::setParameter(effect, "out", QString::number(out));
1804 if (out > clipEnd) {
1805 if (!effects.contains(i))
1806 effects[i] = effect.cloneNode().toElement();
1807 EffectsList::setParameter(effect, "out", QString::number(clipEnd));
1809 if (effects.contains(i))
1810 setFadeIn(out - in);
1812 if (out != clipEnd) {
1813 effects[i] = effect.cloneNode().toElement();
1814 int diff = out - clipEnd;
1815 in = qMax(in - diff, (int) cropStart().frames(m_fps));
1817 EffectsList::setParameter(effect, "in", QString::number(in));
1818 EffectsList::setParameter(effect, "out", QString::number(out));
1820 if (in < cropStart().frames(m_fps)) {
1821 if (!effects.contains(i))
1822 effects[i] = effect.cloneNode().toElement();
1823 EffectsList::setParameter(effect, "in", QString::number(cropStart().frames(m_fps)));
1825 if (effects.contains(i))
1826 setFadeOut(out - in);
1829 } else if (effect.attribute("id") == "freeze" && cropStart() != oldInfo.cropStart) {
1830 effects[i] = effect.cloneNode().toElement();
1831 int diff = (oldInfo.cropStart - cropStart()).frames(m_fps);
1832 int frame = EffectsList::parameter(effect, "frame").toInt();
1833 EffectsList::setParameter(effect, "frame", QString::number(frame - diff));
1837 QDomNodeList params = effect.elementsByTagName("parameter");
1838 for (int j = 0; j < params.count(); j++) {
1839 QDomElement param = params.item(j).toElement();
1841 QString type = param.attribute("type");
1842 if (type == "geometry" && !param.hasAttribute("fixed")) {
1843 if (!effects.contains(i))
1844 effects[i] = effect.cloneNode().toElement();
1845 updateGeometryKeyframes(effect, j, width, height, oldInfo);
1846 } else if (type == "simplekeyframe" || type == "keyframe") {
1847 if (!effects.contains(i))
1848 effects[i] = effect.cloneNode().toElement();
1849 updateNormalKeyframes(param);
1851 } else if (type == "roto-spline") {
1852 if (!effects.contains(i))
1853 effects[i] = effect.cloneNode().toElement();
1854 QString value = param.attribute("value");
1855 if (adjustRotoDuration(&value, cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1))
1856 param.setAttribute("value", value);
1864 bool ClipItem::updateNormalKeyframes(QDomElement parameter)
1866 int in = cropStart().frames(m_fps);
1867 int out = (cropStart() + cropDuration()).frames(m_fps) - 1;
1870 const QStringList data = parameter.attribute("keyframes").split(';', QString::SkipEmptyParts);
1871 QMap <int, double> keyframes;
1872 foreach (QString keyframe, data)
1873 keyframes[keyframe.section(':', 0, 0).toInt()] = locale.toDouble(keyframe.section(':', 1, 1));
1876 QMap<int, double>::iterator i = keyframes.end();
1878 double lastValue = 0;
1882 * Take care of resize from start
1884 bool startFound = false;
1885 while (i-- != keyframes.begin()) {
1886 if (i.key() < in && !startFound) {
1889 keyframes[in] = i.value();
1891 relPos = (in - i.key()) / (qreal)(lastPos - i.key() + 1);
1892 keyframes[in] = i.value() + (lastValue - i.value()) * relPos;
1896 lastValue = i.value();
1898 i = keyframes.erase(i);
1902 * Take care of resize from end
1904 i = keyframes.begin();
1906 bool endFound = false;
1907 while (i != keyframes.end()) {
1908 if (i.key() > out && !endFound) {
1911 keyframes[out] = i.value();
1913 relPos = (out - lastPos) / (qreal)(i.key() - lastPos + 1);
1914 keyframes[out] = lastValue + (i.value() - lastValue) * relPos;
1918 lastValue = i.value();
1920 i = keyframes.erase(i);
1925 if (startFound || endFound) {
1927 QMap<int, double>::const_iterator k = keyframes.constBegin();
1928 while (k != keyframes.constEnd()) {
1929 newkfr.append(QString::number(k.key()) + ':' + QString::number(qRound(k.value())) + ';');
1932 parameter.setAttribute("keyframes", newkfr);
1939 void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, ItemInfo oldInfo)
1942 QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
1943 int offset = oldInfo.cropStart.frames(m_fps);
1944 QString data = param.attribute("value");
1946 QStringList kfrs = data.split(';');
1948 foreach (QString keyframe, kfrs) {
1949 if (keyframe.contains('=')) {
1950 int pos = keyframe.section('=', 0, 0).toInt();
1952 data.append(QString::number(pos) + "=" + keyframe.section('=', 1) + ";");
1954 else data.append(keyframe + ";");
1957 Mlt::Geometry geometry(data.toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
1958 param.setAttribute("value", geometry.serialise(cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1));
1961 void ClipItem::slotGotThumbsCache()
1963 disconnect(m_clip->thumbProducer(), SIGNAL(thumbsCached()), this, SLOT(slotGotThumbsCache()));
1967 #include "clipitem.moc"