if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
m_baseColor = QColor(141, 166, 215);
- m_hasThumbs = true;
- m_startThumbTimer.setSingleShot(true);
- connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
- m_endThumbTimer.setSingleShot(true);
- connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
+ if (!m_clip->isPlaceHolder()) {
+ m_hasThumbs = true;
+ m_startThumbTimer.setSingleShot(true);
+ connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
+ m_endThumbTimer.setSingleShot(true);
+ connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
- connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
+ connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
- connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
- connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
- if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
+ connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+ connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+ if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
+ }
} else if (m_clipType == COLOR) {
QString colour = m_clip->getProperty("colour");
blockSignals(true);
if (scene()) scene()->removeItem(this);
if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
- disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
- disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+ //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+ //disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
}
delete m_timeLine;
}
// Effect has a keyframe type parameter, we need to set the values
if (e.attribute("keyframes").isEmpty()) {
e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + def + ';' + QString::number((cropStart() + cropDuration()).frames(m_fps) - 1) + ':' + def);
- //kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
+ kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
//break;
}
}
void ClipItem::setKeyframes(const int ix, const QString keyframes)
{
QDomElement effect = getEffectAt(ix);
- if (effect.attribute("disabled") == "1") return;
+ if (effect.attribute("disable") == "1") return;
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
m_keyframeFactor = 100.0 / (max - min);
m_keyframeDefault = e.attribute("default").toDouble();
m_selectedKeyframe = 0;
- m_editedKeyframe = -1;
// parse keyframes
const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
foreach(const QString &str, keyframes) {
double val = str.section(':', 1, 1).toDouble();
m_keyframes[pos] = val;
}
+ if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
+ if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
update();
return;
}
QDomElement effect = effectAt(m_selectedEffect);
if (effect.isNull() == false) {
QDomNodeList params = effect.elementsByTagName("parameter");
- if (effect.attribute("disabled") != "1")
+ if (effect.attribute("disable") != "1")
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")) {
m_keyframeFactor = 100.0 / (max - min);
m_keyframeDefault = e.attribute("default").toDouble();
m_selectedKeyframe = 0;
- m_editedKeyframe = -1;
+
// parse keyframes
const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
foreach(const QString &str, keyframes) {
double val = str.section(':', 1, 1).toDouble();
m_keyframes[pos] = val;
}
+ if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
update();
return;
}
{
// regenerate xml parameter from the clip keyframes
QDomElement effect = getEffectAt(m_selectedEffect);
- if (effect.attribute("disabled") == "1") return;
+ if (effect.attribute("disable") == "1") return;
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
if (KdenliveSettings::videothumbnails() && !isAudioOnly()) {
QPen pen = painter->pen();
pen.setColor(QColor(255, 255, 255, 150));
- const QRectF source(0.0, 0.0, (double) m_startPix.width(), (double) m_startPix.height());
painter->setPen(pen);
if ((m_clipType == IMAGE || m_clipType == TEXT) && !m_startPix.isNull()) {
const QPointF top = mapped.topRight() - QPointF(m_startPix.width() - 1, 0);
} else mappedRect = mapped;
double scale = painter->matrix().m11();
- int channels = baseClip()->getProperty("channels").toInt();
+ int channels = 0;
+ if (isEnabled() && m_clip) channels = m_clip->getProperty("channels").toInt();
if (scale != m_framePixelWidth)
m_audioThumbCachePic.clear();
double cropLeft = m_info.cropStart.frames(m_fps);
// draw markers
- QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
- QList < CommentedTime >::Iterator it = markers.begin();
- GenTime pos;
- double framepos;
- QBrush markerBrush(QColor(120, 120, 0, 140));
- QPen pen = painter->pen();
- pen.setColor(QColor(255, 255, 255, 200));
- pen.setStyle(Qt::DotLine);
-
- for (; it != markers.end(); ++it) {
- pos = GenTime((int)((*it).time().frames(m_fps) / m_speed + 0.5), m_fps) - cropStart();
- if (pos > GenTime()) {
- if (pos > cropDuration()) break;
- QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
- QLineF l2 = painter->matrix().map(l);
- //framepos = scale * pos.frames(m_fps);
- //QLineF l(framepos, 5, framepos, itemHeight - 5);
- painter->setPen(pen);
- painter->drawLine(l2);
- if (KdenliveSettings::showmarkers()) {
- framepos = rect().x() + pos.frames(m_fps);
- const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
- const QRectF r2 = painter->matrix().mapRect(r1);
- const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
- painter->setBrush(markerBrush);
- painter->setPen(Qt::NoPen);
- painter->drawRoundedRect(txtBounding3, 3, 3);
- painter->setBrush(QBrush(Qt::NoBrush));
- painter->setPen(Qt::white);
- painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
+ if (isEnabled() && m_clip) {
+ QList < CommentedTime > markers = m_clip->commentedSnapMarkers();
+ QList < CommentedTime >::Iterator it = markers.begin();
+ GenTime pos;
+ double framepos;
+ QBrush markerBrush(QColor(120, 120, 0, 140));
+ QPen pen = painter->pen();
+ pen.setColor(QColor(255, 255, 255, 200));
+ pen.setStyle(Qt::DotLine);
+
+ for (; it != markers.end(); ++it) {
+ pos = GenTime((int)((*it).time().frames(m_fps) / m_speed + 0.5), m_fps) - cropStart();
+ if (pos > GenTime()) {
+ if (pos > cropDuration()) break;
+ QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom());
+ QLineF l2 = painter->matrix().map(l);
+ painter->setPen(pen);
+ painter->drawLine(l2);
+ if (KdenliveSettings::showmarkers()) {
+ framepos = rect().x() + pos.frames(m_fps);
+ const QRectF r1(framepos + 0.04, 10, rect().width() - framepos - 2, rect().height() - 10);
+ const QRectF r2 = painter->matrix().mapRect(r1);
+ const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
+ painter->setBrush(markerBrush);
+ painter->setPen(Qt::NoPen);
+ painter->drawRoundedRect(txtBounding3, 3, 3);
+ painter->setBrush(QBrush(Qt::NoBrush));
+ painter->setPen(Qt::white);
+ painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment());
+ }
+ //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
}
- //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
}
}
const double scale = projectScene()->scale().x();
double maximumOffset = 6 / scale;
if (isSelected() || (parentItem() && parentItem()->isSelected())) {
- m_editedKeyframe = mouseOverKeyFrames(pos, maximumOffset);
- if (m_editedKeyframe != -1) return KEYFRAME;
+ int kf = mouseOverKeyFrames(pos, maximumOffset);
+ if (kf != -1) {
+ m_editedKeyframe = kf;
+ return KEYFRAME;
+ }
}
QRectF rect = sceneBoundingRect();
int addtransitionOffset = 10;
//virtual
QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
+ if (change == QGraphicsItem::ItemSelectedChange) {
+ if (value.toBool()) setZValue(10);
+ else setZValue(2);
+ }
if (change == ItemPositionChange && scene()) {
// calculate new position.
//if (parentItem()) return pos();
parameters.addParam("tag", effect.attribute("tag"));
parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
- if (effect.hasAttribute("disabled")) parameters.addParam("disabled", effect.attribute("disabled"));
+ if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
QString effectId = effect.attribute("id");
parameters.addParam("factor", e.attribute("factor", "1"));
parameters.addParam("starttag", e.attribute("starttag", "start"));
parameters.addParam("endtag", e.attribute("endtag", "end"));
- }
-
- if (e.attribute("factor", "1") == "1") {
+ } else if (e.attribute("factor", "1") == "1") {
parameters.addParam(e.attribute("name"), e.attribute("value"));
// check if it is a fade effect
parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
parameters.addParam("id", effect.attribute("id"));
if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
- if (effect.hasAttribute("disabled")) parameters.addParam("disabled", effect.attribute("disabled"));
+ if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
//kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
if (e.attribute("type") == "simplekeyframe") {
- kDebug() << "/ / / /SENDING KEYFR EFFECT TYPE";
+
QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
double factor = e.attribute("factor", "1").toDouble();
- if (factor != 1) {
- for (int j = 0; j < values.count(); j++) {
- QString pos = values.at(j).section(":", 0, 0);
- double val = values.at(j).section(":", 1, 1).toDouble() / factor;
- values[j] = pos + "=" + QString::number(val);
- }
+ for (int j = 0; j < values.count(); j++) {
+ QString pos = values.at(j).section(":", 0, 0);
+ double val = values.at(j).section(":", 1, 1).toDouble() / factor;
+ values[j] = pos + "=" + QString::number(val);
}
+ // kDebug() << "/ / / /SENDING KEYFR:" << values;
parameters.addParam(e.attribute("name"), values.join(";"));
/*parameters.addParam(e.attribute("name"), e.attribute("keyframes").replace(":", "="));
parameters.addParam("max", e.attribute("max"));
return m_videoOnly;
}
+void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
+{
+ if (effect.attribute("disable") == "1") return;
+ effect.setAttribute("active_keyframe", pos);
+ m_editedKeyframe = pos;
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ QString kfr = e.attribute("keyframes");
+ const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
+ QStringList newkfr;
+ bool added = false;
+ foreach(const QString &str, keyframes) {
+ int kpos = str.section(':', 0, 0).toInt();
+ double newval = str.section(':', 1, 1).toDouble();
+ if (kpos < pos) {
+ newkfr.append(str);
+ } else if (!added) {
+ if (i == 0) newkfr.append(QString::number(pos) + ":" + QString::number(val));
+ else newkfr.append(QString::number(pos) + ":" + QString::number(newval));
+ if (kpos > pos) newkfr.append(str);
+ added = true;
+ } else newkfr.append(str);
+ }
+ if (!added) newkfr.append(QString::number(pos) + ":" + QString::number(val));
+ e.setAttribute("keyframes", newkfr.join(";"));
+ }
+}
+
+void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double value)
+{
+ if (effect.attribute("disable") == "1") return;
+ effect.setAttribute("active_keyframe", newpos);
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ int start = cropStart().frames(m_fps);
+ int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ QString kfr = e.attribute("keyframes");
+ const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
+ QStringList newkfr;
+ foreach(const QString &str, keyframes) {
+ if (str.section(':', 0, 0).toInt() != oldpos) {
+ newkfr.append(str);
+ } else if (newpos != -1) {
+ newpos = qMax(newpos, start);
+ newpos = qMin(newpos, end);
+ if (i == 0) newkfr.append(QString::number(newpos) + ":" + QString::number(value));
+ else newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1));
+ }
+ }
+ e.setAttribute("keyframes", newkfr.join(";"));
+ }
+
+ updateKeyframes(effect);
+ update();
+}
+void ClipItem::updateKeyframes(QDomElement effect)
+{
+ m_keyframes.clear();
+ // parse keyframes
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ QDomElement e = params.item(0).toElement();
+ const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
+ foreach(const QString &str, keyframes) {
+ int pos = str.section(':', 0, 0).toInt();
+ double val = str.section(':', 1, 1).toDouble();
+ m_keyframes[pos] = val;
+ }
+ if (!m_keyframes.contains(m_selectedKeyframe)) m_selectedKeyframe = -1;
+}
#include "clipitem.moc"