X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcustomtrackview.cpp;h=078edddad9e5f869ee19f58b572f928f7beb16c5;hb=49c3f9376d4b9f7d185c4d6b22e662b127debdcb;hp=844a171e64ffaa0b6934f91aff7236b851163218;hpb=3bebf5f7285a1310867640ee2ae293bd8c95d3f0;p=kdenlive diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 844a171e..078eddda 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -130,7 +130,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen m_commandStack = doc->commandStack(); else m_commandStack = NULL; - + m_ct = 0; setMouseTracking(true); setAcceptDrops(true); setFrameShape(QFrame::NoFrame); @@ -142,12 +142,6 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen 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); @@ -192,7 +186,6 @@ CustomTrackView::~CustomTrackView() qDeleteAll(m_guides); m_guides.clear(); m_waitingThumbs.clear(); - delete m_pixmapCache; delete m_animationTimer; } @@ -591,7 +584,14 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) 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); @@ -708,7 +708,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) m_blockRefresh = true; m_dragGuide = NULL; - bool collision = false; if (m_tool != RAZORTOOL) activateMonitor(); else if (m_document->renderer()->playSpeed() != 0.0) { @@ -736,7 +735,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) 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(); @@ -976,7 +974,12 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) 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 @@ -1368,7 +1371,7 @@ void CustomTrackView::editItemDuration() } } -void CustomTrackView::editKeyFrame(const GenTime /*pos*/, const int /*track*/, const int /*index*/, const QString /*keyframes*/) +void CustomTrackView::editKeyFrame(const GenTime & /*pos*/, const int /*track*/, const int /*index*/, const QString & /*keyframes*/) { /*ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track); if (clip) { @@ -1453,7 +1456,7 @@ void CustomTrackView::insertClipCut(DocClipBase *clip, int in, int out) splitAudio(); } -bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos) +bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos) { if (data->hasFormat("kdenlive/clip")) { m_clipDrag = true; @@ -1598,7 +1601,7 @@ void CustomTrackView::slotRefreshEffects(ClipItem *clip) { 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; } @@ -1629,7 +1632,8 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect) 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()); @@ -1650,7 +1654,7 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect) 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); @@ -1665,11 +1669,11 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect) 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; @@ -1686,8 +1690,8 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem * QList itemList = group->childItems(); QUndoCommand *effectCommand = new QUndoCommand(); QString effectName; - QDomNode namenode = effect.elementsByTagName("name").item(0); - if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data()); + QDomElement namenode = effect.firstChildElement("name"); + if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data()); else effectName = i18n("effect"); effectCommand->setText(i18n("Add %1", effectName)); int count = 0; @@ -1711,13 +1715,6 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem * } 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++; } @@ -1733,8 +1730,8 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) QList itemList; QUndoCommand *effectCommand = new QUndoCommand(); QString effectName; - QDomNode namenode = effect.elementsByTagName("name").item(0); - if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data()); + QDomElement namenode = effect.firstChildElement("name"); + if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data()); else effectName = i18n("effect"); effectCommand->setText(i18n("Add %1", effectName)); @@ -1790,13 +1787,6 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) } 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); } } @@ -1835,8 +1825,8 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef QList items = m_selectionGroup->childItems(); QUndoCommand *delCommand = new QUndoCommand(); QString effectName; - QDomNode namenode = effect.elementsByTagName("name").item(0); - if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data()); + QDomElement namenode = effect.firstChildElement("name"); + if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data()); else effectName = i18n("effect"); delCommand->setText(i18n("Delete %1", effectName)); @@ -1883,11 +1873,6 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE 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); @@ -1908,7 +1893,8 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE 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()); @@ -1923,11 +1909,6 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE } 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); @@ -2099,9 +2080,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo if (dup->checkKeyFrames()) slotRefreshEffects(dup); - updatePanZoom(item); - updatePanZoom(dup, cutTime - item->startPos()); - item->baseClip()->addReference(); m_document->updateClip(item->baseClip()->getId()); setDocumentModified(); @@ -2158,9 +2136,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo 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); @@ -2916,9 +2891,16 @@ void CustomTrackView::slotRemoveSpace() int track = 0; if (m_menuPosition.isNull()) { pos = GenTime(cursorPos(), m_document->fps()); - bool ok; - track = QInputDialog::getInteger(this, i18n("Remove Space"), i18n("Track"), 0, 0, m_document->tracksCount() - 1, 1, &ok); - if (!ok) return; + + TrackDialog d(m_document, parentWidget()); + d.comboTracks->setCurrentIndex(m_selectedTrack); + d.label->setText(i18n("Track")); + d.before_select->setHidden(true); + d.setWindowTitle(i18n("Remove Space")); + d.video_track->setHidden(true); + d.audio_track->setHidden(true); + if (d.exec() != QDialog::Accepted) return; + track = d.comboTracks->currentIndex(); } else { pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps()); track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight); @@ -2935,7 +2917,6 @@ void CustomTrackView::slotRemoveSpace() return; } int length = m_document->renderer()->mltGetSpaceLength(pos, m_document->tracksCount() - track, true); - //kDebug() << "// GOT LENGT; " << length; if (length <= 0) { emit displayMessage(i18n("You must be in an empty space to remove space (time: %1, track: %2)", m_document->timecode().getTimecodeFromFrames(mapToScene(m_menuPosition).x()), track), ErrorMessage); return; @@ -2967,6 +2948,38 @@ void CustomTrackView::slotRemoveSpace() } } + if (!transitionsToMove.isEmpty()) { + // Make sure that by moving the items, we don't get a transition collision + // Find first transition + ItemInfo info = transitionsToMove.at(0); + for (int i = 1; i < transitionsToMove.count(); i++) + if (transitionsToMove.at(i).startPos < info.startPos) info = transitionsToMove.at(i); + + // make sure there are no transitions on the way + QRectF rect(info.startPos.frames(m_document->fps()) - length, track * m_tracksHeight + m_tracksHeight / 2, length - 1, m_tracksHeight / 2 - 2); + items = scene()->items(rect); + int transitionCorrection = -1; + for (int i = 0; i < items.count(); i++) { + if (items.at(i)->type() == TRANSITIONWIDGET) { + // There is a transition on the way + AbstractClipItem *item = static_cast (items.at(i)); + int transitionEnd = item->endPos().frames(m_document->fps()); + if (transitionEnd > transitionCorrection) transitionCorrection = transitionEnd; + } + } + + if (transitionCorrection > 0) { + // We need to fix the move length + length = info.startPos.frames(m_document->fps()) - transitionCorrection; + } + + // Make sure we don't send transition before 0 + if (info.startPos.frames(m_document->fps()) < length) { + // reduce length to maximum possible + length = info.startPos.frames(m_document->fps()); + } + } + InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, GenTime(-length, m_document->fps()), true); updateTrackDuration(track, command); m_commandStack->push(command); @@ -3032,7 +3045,7 @@ void CustomTrackView::slotInsertSpace() } } -void CustomTrackView::insertSpace(QList clipsToMove, QList transToMove, int track, const GenTime duration, const GenTime offset) +void CustomTrackView::insertSpace(QList clipsToMove, QList transToMove, int track, const GenTime &duration, const GenTime &offset) { int diff = duration.frames(m_document->fps()); resetSelectionGroup(); @@ -3724,9 +3737,15 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) 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: "<fps())<<", "<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: "<fps())<<", TK: "<renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement()); + exit(1); return; } m_waitingThumbs.removeAll(item); @@ -3776,7 +3795,6 @@ void CustomTrackView::deleteSelectedClips() scene()->clearSelection(); QUndoCommand *deleteSelected = new QUndoCommand(); - bool resetGroup = false; int groupCount = 0; int clipCount = 0; int transitionCount = 0; @@ -3787,7 +3805,6 @@ void CustomTrackView::deleteSelectedClips() QList children = itemList.at(i)->childItems(); QList clipInfos; QList 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 (children.at(j)); @@ -3813,7 +3830,6 @@ void CustomTrackView::deleteSelectedClips() if (itemList.at(i)->type() == AVWIDGET) { clipCount++; ClipItem *item = static_cast (itemList.at(i)); - if (item->parentItem()) resetGroup = true; //kDebug()<<"// DELETE CLP AT: "<info().startPos.frames(25); new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, true, true, deleteSelected); emit clipItemSelected(NULL); @@ -3821,7 +3837,6 @@ void CustomTrackView::deleteSelectedClips() transitionCount++; Transition *item = static_cast (itemList.at(i)); //kDebug()<<"// DELETE TRANS AT: "<info().startPos.frames(25); - if (item->parentItem()) resetGroup = true; new AddTransitionCommand(this, item->info(), item->transitionEndTrack(), item->toXML(), true, true, deleteSelected); emit transitionItemSelected(NULL); } @@ -3839,6 +3854,7 @@ void CustomTrackView::deleteSelectedClips() void CustomTrackView::changeClipSpeed() { + // TODO: remove after string freeze QList itemList = scene()->selectedItems(); if (itemList.count() == 0) { emit displayMessage(i18n("Select clip to change speed"), ErrorMessage); @@ -3852,7 +3868,6 @@ void CustomTrackView::changeClipSpeed() for (int i = 0; i < itemList.count(); i++) { if (itemList.at(i)->type() == AVWIDGET) { ClipItem *item = static_cast (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; @@ -4002,7 +4017,6 @@ void CustomTrackView::groupClips(bool group) QList itemList = scene()->selectedItems(); QList clipInfos; QList transitionInfos; - GenTime currentPos = GenTime(m_cursorPos, m_document->fps()); // Expand groups int max = itemList.count(); @@ -4130,19 +4144,26 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload) { QList list = scene()->items(); + QList clipList; ClipItem *clip = NULL; for (int i = 0; i < list.size(); ++i) { if (list.at(i)->type() == AVWIDGET) { clip = static_cast (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); } - clip->refreshClip(true, true); + else clipList.append(clip); } } } + for (int i = 0; i < clipList.count(); i++) + clipList.at(i)->refreshClip(true, true); } ClipItem *CustomTrackView::getClipItemAtEnd(GenTime pos, int track) @@ -4249,7 +4270,7 @@ Transition *CustomTrackView::getTransitionItemAtStart(GenTime pos, int track) return clip; } -void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool refresh) +void CustomTrackView::moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh) { if (m_selectionGroup) resetSelectionGroup(false); ClipItem *item = getClipItemAt((int) start.startPos.frames(m_document->fps()), start.track); @@ -4292,7 +4313,7 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool re if (refresh) m_document->renderer()->doRefresh(); } -void CustomTrackView::moveGroup(QList startClip, QList startTransition, const GenTime offset, const int trackOffset, bool reverseMove) +void CustomTrackView::moveGroup(QList startClip, QList startTransition, const GenTime &offset, const int trackOffset, bool reverseMove) { // Group Items resetSelectionGroup(); @@ -4410,7 +4431,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta } else kDebug() << "///////// WARNING; NO GROUP TO MOVE"; } -void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, bool m_refresh) +void CustomTrackView::moveTransition(const ItemInfo &start, const ItemInfo &end, bool m_refresh) { Transition *item = getTransitionItemAt(start.startPos, start.track); if (!item) { @@ -4458,7 +4479,7 @@ void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, b setDocumentModified(); } -void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool dontWorry) +void CustomTrackView::resizeClip(const ItemInfo &start, const ItemInfo &end, bool dontWorry) { bool resizeClipStart = (start.startPos != end.startPos); ClipItem *item = getClipItemAtStart(start.startPos, start.track); @@ -4962,7 +4983,7 @@ void CustomTrackView::slotDeleteAllClipMarkers(const QString &id) m_commandStack->push(deleteMarkers); } -void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString comment) +void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString &comment) { DocClipBase *base = m_document->clipManager()->getClipById(id); if (!comment.isEmpty()) base->addSnapMarker(pos, comment); @@ -4994,7 +5015,7 @@ void CustomTrackView::buildGuidesMenu(QMenu *goMenu) const goMenu->setEnabled(!m_guides.isEmpty()); } -void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const QString &comment) +void CustomTrackView::editGuide(const GenTime &oldPos, const GenTime &pos, const QString &comment) { if (oldPos > GenTime() && pos > GenTime()) { // move guide @@ -5022,7 +5043,7 @@ void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const Q m_document->syncGuides(m_guides); } -bool CustomTrackView::addGuide(const GenTime pos, const QString &comment) +bool CustomTrackView::addGuide(const GenTime &pos, const QString &comment) { for (int i = 0; i < m_guides.count(); i++) { if (m_guides.at(i)->position() == pos) { @@ -5520,6 +5541,7 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime // 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(); @@ -5533,9 +5555,9 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime 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: "<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); @@ -5686,8 +5708,8 @@ void CustomTrackView::saveThumbnails() } 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); @@ -5811,26 +5833,7 @@ void CustomTrackView::autoTransition() 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) +void CustomTrackView::clipNameChanged(const QString &id, const QString &name) { QList list = scene()->items(); ClipItem *clip = NULL; @@ -5877,7 +5880,7 @@ void CustomTrackView::getTransitionAvailableSpace(AbstractClipItem *item, GenTim } } -void CustomTrackView::loadGroups(const QDomNodeList groups) +void CustomTrackView::loadGroups(const QDomNodeList &groups) { for (int i = 0; i < groups.count(); i++) { QDomNodeList children = groups.at(i).childNodes(); @@ -5915,7 +5918,9 @@ void CustomTrackView::splitAudio() 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); } } } @@ -5926,7 +5931,7 @@ void CustomTrackView::splitAudio() } } -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) { @@ -5971,6 +5976,20 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split) } 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); } } @@ -5992,9 +6011,18 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split) 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; } } @@ -6526,7 +6554,7 @@ bool CustomTrackView::hasAudio(int track) const return false; } -void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix) +void CustomTrackView::slotAddTrackEffect(const QDomElement &effect, int ix) { AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - ix, GenTime(-1), effect, true); m_commandStack->push(command); @@ -6534,9 +6562,10 @@ void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix) } -EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) +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")); @@ -6549,15 +6578,19 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) 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); double factor = e.attribute("factor", "1").toDouble(); + double offset = e.attribute("offset", "0").toDouble(); 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); + double val = (values.at(j).section(':', 1, 1).toDouble() - offset) / factor; + values[j] = pos + "=" + locale.toString(val); } // kDebug() << "/ / / /SENDING KEYFR:" << values; parameters.addParam(e.attribute("name"), values.join(";")); @@ -6571,6 +6604,7 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) parameters.addParam("max", e.attribute("max")); parameters.addParam("min", e.attribute("min")); parameters.addParam("factor", e.attribute("factor", "1")); + parameters.addParam("offset", e.attribute("offset", "0")); parameters.addParam("starttag", e.attribute("starttag", "start")); parameters.addParam("endtag", e.attribute("endtag", "end")); } else if (e.attribute("namedesc").contains(';')) { @@ -6587,12 +6621,15 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) } parameters.addParam("start", neu); } else { - if (e.attribute("factor", "1") != "1") { + if (e.attribute("factor", "1") != "1" || e.attribute("offset", "0") != "0") { 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)); + } else { + fact = e.attribute("factor", "1").toDouble(); + } + double offset = e.attribute("offset", "0").toDouble(); + parameters.addParam(e.attribute("name"), locale.toString((e.attribute("value").toDouble() - offset) / fact)); } else { parameters.addParam(e.attribute("name"), e.attribute("value")); } @@ -6601,23 +6638,6 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) return parameters; } -void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos) -{ - QList 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 tracks = m_document->tracksList();