m_commandStack = doc->commandStack();
else
m_commandStack = NULL;
-
+ m_ct = 0;
setMouseTracking(true);
setAcceptDrops(true);
setFrameShape(QFrame::NoFrame);
m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
-#if KDE_IS_VERSION(4,5,0)
- m_pixmapCache = new KImageCache("kdenlive-thumbs", 1000000);
-#else
- m_pixmapCache = new KPixmapCache("kdenlive-thumbs");
-#endif
-
m_animationTimer = new QTimeLine(800);
m_animationTimer->setFrameRange(0, 5);
m_animationTimer->setUpdateInterval(100);
qDeleteAll(m_guides);
m_guides.clear();
m_waitingThumbs.clear();
- delete m_pixmapCache;
delete m_animationTimer;
}
event->accept();
return;
}
- opMode = clip->operationMode(mapToScene(event->pos()));
+
+ if (m_selectionGroup && clip->parentItem() == m_selectionGroup) {
+ // all other modes break the selection, so the user probably wants to move it
+ opMode = MOVE;
+ } else {
+ opMode = clip->operationMode(mapToScene(event->pos()));
+ }
+
const double size = 5;
if (opMode == m_moveOpMode) {
QGraphicsView::mouseMoveEvent(event);
m_blockRefresh = true;
m_dragGuide = NULL;
- bool collision = false;
if (m_tool != RAZORTOOL) activateMonitor();
else if (m_document->renderer()->playSpeed() != 0.0) {
m_dragGuide = (Guide *) collisionList.at(i);
if (event->button() == Qt::LeftButton) { // move it
m_dragGuide->setFlag(QGraphicsItem::ItemIsMovable, true);
- collision = true;
m_operationMode = MOVEGUIDE;
// deselect all clips so that only the guide will move
m_scene->clearSelection();
if (event->modifiers() != Qt::ControlModifier && m_operationMode == NONE) QGraphicsView::mousePressEvent(event);
m_clickPoint = QPoint((int)(mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps())), (int)(event->pos().y() - m_dragItem->pos().y()));
- m_operationMode = m_dragItem->operationMode(mapToScene(event->pos()));
+ if (m_selectionGroup && m_dragItem->parentItem() == m_selectionGroup) {
+ // all other modes break the selection, so the user probably wants to move it
+ m_operationMode = MOVE;
+ } else {
+ m_operationMode = m_dragItem->operationMode(mapToScene(event->pos()));
+ }
m_controlModifier = (event->modifiers() == Qt::ControlModifier);
// Update snap points
{
int track = m_document->tracksCount() - clip->track();
GenTime pos = clip->startPos();
- if (!m_document->renderer()->mltRemoveEffect(track, pos, "-1", false, false)) {
+ if (!m_document->renderer()->mltRemoveEffect(track, pos, -1, false, false)) {
emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
return;
}
emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
return;
}
- double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
+ QLocale locale;
+ double speed = locale.toDouble(EffectsList::parameter(effect, "speed")) / 100.0;
int strobe = EffectsList::parameter(effect, "strobe").toInt();
if (strobe == 0) strobe = 1;
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, 1.0, strobe, clip->baseClip()->getId());
QString index = effect.attribute("kdenlive_ix");
if (pos < GenTime()) {
// Delete track effect
- if (m_document->renderer()->mltRemoveTrackEffect(track, index, true)) {
+ if (m_document->renderer()->mltRemoveTrackEffect(track, index.toInt(), true)) {
m_document->removeTrackEffect(track - 1, effect);
}
else emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
clip->deleteEffect(index);
emit clipItemSelected(clip);
- m_document->renderer()->mltRemoveEffect(track, pos, index, true);
+ m_document->renderer()->mltRemoveEffect(track, pos, index.toInt(), true);
return;
}
}
- if (!m_document->renderer()->mltRemoveEffect(track, pos, index, true)) {
+ if (!m_document->renderer()->mltRemoveEffect(track, pos, index.toInt(), true)) {
kDebug() << "// ERROR REMOV EFFECT: " << index << ", DISABLE: " << effect.attribute("disable");
emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
return;
}
item->initEffect(effect);
- // Old LADSPA filter, deprecated
- /*
- if (effect.attribute("tag") == "ladspa") {
- QString ladpsaFile = m_document->getLadspaFile();
- initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- effect.setAttribute("src", ladpsaFile);
- }*/
new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
count++;
}
} else {
item->initEffect(effect);
}
- // Old LADSPA filter, deprecated
- /* if (effect.attribute("tag") == "ladspa") {
- QString ladpsaFile = m_document->getLadspaFile();
- initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- effect.setAttribute("src", ladpsaFile);
- }
- */
new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
}
}
if (pos < GenTime()) {
// editing a track effect
EffectsParameterList effectParams = getEffectArgs(effect);
- // Old LADSPA filter, deprecated
- /*if (effect.attribute("tag") == "ladspa") {
- // Update the ladspa affect file
- initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- }*/
// check if we are trying to reset a keyframe effect
/*if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
clip->initEffect(effect);
if (effect.attribute("disable") == "1") {
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
} else {
- double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
+ QLocale locale;
+ double speed = locale.toDouble(EffectsList::parameter(effect, "speed")) / 100.0;
int strobe = EffectsList::parameter(effect, "strobe").toInt();
if (strobe == 0) strobe = 1;
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, clip->speed(), strobe, clip->baseClip()->getId());
}
EffectsParameterList effectParams = getEffectArgs(effect);
- // Old LADSPA filter, deprecated
- /*if (effect.attribute("tag") == "ladspa") {
- // Update the ladspa affect file
- initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- }*/
// check if we are trying to reset a keyframe effect
if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
clip->initEffect(effect);
if (dup->checkKeyFrames())
slotRefreshEffects(dup);
- updatePanZoom(item);
- updatePanZoom(dup, cutTime - item->startPos());
-
item->baseClip()->addReference();
m_document->updateClip(item->baseClip()->getId());
setDocumentModified();
bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, info.endPos - info.startPos);
if (success) {
item->resizeEnd((int) info.endPos.frames(m_document->fps()));
-
- updatePanZoom(item);
-
setDocumentModified();
} else {
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
{
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
-
+ m_ct++;
+ if (!item) kDebug()<<"// PROBLEM FINDING CLIP ITEM TO REMOVVE!!!!!!!!!";
+ else kDebug()<<"// deleting CLIP: "<<info.startPos.frames(m_document->fps())<<", "<<item->baseClip()->fileURL();
+ //m_document->renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement());
if (!item || m_document->renderer()->mltRemoveClip(m_document->tracksCount() - info.track, info.startPos) == false) {
emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
+ kDebug()<<"CANNOT REMOVE: "<<info.startPos.frames(m_document->fps())<<", TK: "<<info.track;
+ //m_document->renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement());
+ exit(1);
return;
}
m_waitingThumbs.removeAll(item);
scene()->clearSelection();
QUndoCommand *deleteSelected = new QUndoCommand();
- bool resetGroup = false;
int groupCount = 0;
int clipCount = 0;
int transitionCount = 0;
QList<QGraphicsItem *> children = itemList.at(i)->childItems();
QList <ItemInfo> clipInfos;
QList <ItemInfo> transitionInfos;
- GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
for (int j = 0; j < children.count(); j++) {
if (children.at(j)->type() == AVWIDGET) {
AbstractClipItem *clip = static_cast <AbstractClipItem *>(children.at(j));
if (itemList.at(i)->type() == AVWIDGET) {
clipCount++;
ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
- if (item->parentItem()) resetGroup = true;
//kDebug()<<"// DELETE CLP AT: "<<item->info().startPos.frames(25);
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, true, true, deleteSelected);
emit clipItemSelected(NULL);
transitionCount++;
Transition *item = static_cast <Transition *>(itemList.at(i));
//kDebug()<<"// DELETE TRANS AT: "<<item->info().startPos.frames(25);
- if (item->parentItem()) resetGroup = true;
new AddTransitionCommand(this, item->info(), item->transitionEndTrack(), item->toXML(), true, true, deleteSelected);
emit transitionItemSelected(NULL);
}
void CustomTrackView::changeClipSpeed()
{
+ // TODO: remove after string freeze
QList<QGraphicsItem *> itemList = scene()->selectedItems();
if (itemList.count() == 0) {
emit displayMessage(i18n("Select clip to change speed"), ErrorMessage);
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
- ItemInfo info = item->info();
if (percent == -1) percent = QInputDialog::getInteger(this, i18n("Edit Clip Speed"), i18n("New speed (percents)"), item->speed() * 100, 1, 10000, 1, &ok);
if (!ok) break;
double speed = (double) percent / 100.0;
QList<QGraphicsItem *> itemList = scene()->selectedItems();
QList <ItemInfo> clipInfos;
QList <ItemInfo> transitionInfos;
- GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
// Expand groups
int max = itemList.count();
clip = static_cast <ClipItem *>(list.at(i));
if (clip->clipProducer() == clipId) {
ItemInfo info = clip->info();
- if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer(info.track))) {
+ Mlt::Producer *prod = NULL;
+ if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(info.track);
+ else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer();
+ else prod = clip->baseClip()->producer(info.track);
+ if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), prod)) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
}
else clipList.append(clip);
// parse parameters to check if we need to adjust to the new crop start
int diff = (newstart - oldstart).frames(m_document->fps());
int max = (newstart + duration).frames(m_document->fps());
+ QLocale locale;
QDomNodeList params = xml.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
double val = str.section(':', 1, 1).toDouble();
pos += diff;
if (pos > max) {
- newKeyFrames.append(QString::number(max) + ':' + QString::number(val));
+ newKeyFrames.append(QString::number(max) + ':' + locale.toString(val));
break;
- } else newKeyFrames.append(QString::number(pos) + ':' + QString::number(val));
+ } else newKeyFrames.append(QString::number(pos) + ':' + locale.toString(val));
}
//kDebug()<<"ORIGIN: "<<keys<<", FIXED: "<<newKeyFrames;
e.setAttribute("keyframes", newKeyFrames.join(";"));
} else {
QString startThumb = thumbBase + item->baseClip()->getClipHash() + '_';
QString endThumb = startThumb;
- startThumb.append(QString::number(item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
- endThumb.append(QString::number((item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
+ startThumb.append(QString::number((int) item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
+ endThumb.append(QString::number((int) (item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
if (QFile::exists(startThumb)) {
QPixmap pix(startThumb);
if (pix.isNull()) KIO::NetAccess::del(KUrl(startThumb), this);
} else {
QString startThumb = thumbBase + item->baseClip()->getClipHash() + '_';
QString endThumb = startThumb;
- startThumb.append(QString::number(item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
- endThumb.append(QString::number((item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
+ startThumb.append(QString::number((int) item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
+ endThumb.append(QString::number((int) (item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
if (!QFile::exists(startThumb)) {
QPixmap pix(item->startThumb());
pix.save(startThumb);
setDocumentModified();
}
-
-QStringList CustomTrackView::getLadspaParams(QDomElement effect) const
-{
- QStringList result;
- 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") == "constant") {
- if (e.hasAttribute("factor")) {
- double factor = e.attribute("factor").toDouble();
- double value = e.attribute("value").toDouble();
- value = value / factor;
- result.append(QString::number(value));
- } else result.append(e.attribute("value"));
- }
- }
- return result;
-}
-
void CustomTrackView::clipNameChanged(const QString id, const QString name)
{
QList<QGraphicsItem *> list = scene()->items();
if (clip->parentItem()) {
emit displayMessage(i18n("Cannot split audio of grouped clips"), ErrorMessage);
} else {
- new SplitAudioCommand(this, clip->track(), clip->startPos(), splitCommand);
+ EffectsList effects;
+ effects.clone(clip->effectList());
+ new SplitAudioCommand(this, clip->track(), clip->startPos(), effects, splitCommand);
}
}
}
}
}
-void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
+void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList effects, bool split)
{
ClipItem *clip = getClipItemAt(pos, track);
if (clip == NULL) {
}
audioClip->setSelected(true);
audioClip->setAudioOnly(true);
+
+ // keep video effects, move audio effects to audio clip
+ int videoIx = 0;
+ int audioIx = 0;
+ for (int i = 0; i < effects.count(); ++i) {
+ if (effects.at(i).attribute("type") == "audio") {
+ deleteEffect(m_document->tracksCount() - track, pos, clip->effectAt(videoIx));
+ audioIx++;
+ } else {
+ deleteEffect(freetrack, pos, audioClip->effectAt(audioIx));
+ videoIx++;
+ }
+ }
+
groupSelectedItems(false, true);
}
}
ItemInfo info = clip->info();
deleteClip(clp->info());
clip->setVideoOnly(false);
+
if (!m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->producer(info.track))) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
}
+
+ // re-add audio effects
+ for (int i = 0; i < effects.count(); ++i) {
+ if (effects.at(i).attribute("type") == "audio") {
+ addEffect(m_document->tracksCount() - track, pos, effects.at(i));
+ }
+ }
+
break;
}
}
EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
{
EffectsParameterList parameters;
+ QLocale locale;
parameters.addParam("tag", effect.attribute("tag"));
if (effect.hasAttribute("region")) parameters.addParam("region", effect.attribute("region"));
parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
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") == "geometry" && !e.hasAttribute("fixed")) {
+ // effects with geometry param need in / out synced with the clip, request it...
+ parameters.addParam("_sync_in_out", "1");
+ }
if (e.attribute("type") == "simplekeyframe") {
QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
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);
+ values[j] = pos + "=" + locale.toString(val);
}
// kDebug() << "/ / / /SENDING KEYFR:" << values;
parameters.addParam(e.attribute("name"), values.join(";"));
} else {
if (e.attribute("factor", "1") != "1") {
double fact;
- if (e.attribute("factor").startsWith('%')) {
+ if (e.attribute("factor").contains('%')) {
fact = ProfilesDialog::getStringEval(m_document->mltProfile(), e.attribute("factor"));
} else fact = e.attribute("factor", "1").toDouble();
- parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
+ parameters.addParam(e.attribute("name"), locale.toString(e.attribute("value").toDouble() / fact));
} else {
parameters.addParam(e.attribute("name"), e.attribute("value"));
}
return parameters;
}
-void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos)
-{
- QList <int> effects = item->updatePanZoom(m_document->width(), m_document->height(), cutPos.frames(m_document->fps()));
-
- for (int i = 0; i < effects.count(); ++i) {
- if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(item->effectAt(effects.at(i)))))
- emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-
- // if effect is displayed, update the effect edit widget with new clip duration
- /*if (item->isSelected() && effects.at(i) == item->selectedEffectIndex())
- emit clipItemSelected(item, effects.at(i));*/
- }
- // update always, otherwise there might problems when resizing groups
- if (effects.count())
- emit clipItemSelected(item, item->selectedEffectIndex());
-}
-
void CustomTrackView::updateTrackNames(int track, bool added)
{
QList <TrackInfo> tracks = m_document->tracksList();