X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcustomtrackview.cpp;h=cf1ac2294f639750d4c89a083dd5bc059db64500;hb=b949fe03a03817aabb21605fc831546a9f0202b7;hp=76e4bb1cecb3f927b12eab7e8fce2ebc91b5ab5b;hpb=f41ee253ade9dfda45752f232ea0ff35e26dce95;p=kdenlive diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 76e4bb1c..cf1ac229 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -87,6 +87,8 @@ #include #endif +#define SEEK_INACTIVE (-1) + //#define DEBUG bool sortGuidesList(const Guide *g1 , const Guide *g2) @@ -388,12 +390,13 @@ void CustomTrackView::slotCheckPositionScrolling() // If mouse is at a border of the view, scroll if (m_moveOpMode != SEEK) return; if (mapFromScene(m_cursorPos, 0).x() < 3) { + if (horizontalScrollBar()->value() == 0) return; horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 2); QTimer::singleShot(200, this, SLOT(slotCheckPositionScrolling())); - setCursorPos(mapToScene(QPoint(-2, 0)).x()); + seekCursorPos(mapToScene(QPoint(-2, 0)).x()); } else if (viewport()->width() - 3 < mapFromScene(m_cursorPos + 1, 0).x()) { horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 2); - setCursorPos(mapToScene(QPoint(viewport()->width(), 0)).x() + 1); + seekCursorPos(mapToScene(QPoint(viewport()->width(), 0)).x() + 1); QTimer::singleShot(200, this, SLOT(slotCheckPositionScrolling())); } } @@ -420,6 +423,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) bool move = (event->pos() - m_clickEvent).manhattanLength() >= QApplication::startDragDistance(); if (m_dragItem && m_tool == SELECTTOOL) { if (m_operationMode == MOVE && move) { + //m_dragItem->setProperty("y_absolute", event->pos().y()); QGraphicsView::mouseMoveEvent(event); // If mouse is at a border of the view, scroll if (pos < 5) { @@ -621,7 +625,11 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) // all other modes break the selection, so the user probably wants to move it opMode = MOVE; } else { - opMode = clip->operationMode(mapToScene(event->pos())); + if (clip->rect().width() * transform().m11() < 15) { + // If the item is very small, only allow move + opMode = MOVE; + } + else opMode = clip->operationMode(mapToScene(event->pos())); } const double size = 5; @@ -702,7 +710,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) if (event->buttons() != Qt::NoButton && event->modifiers() == Qt::NoModifier) { QGraphicsView::mouseMoveEvent(event); m_moveOpMode = SEEK; - setCursorPos(mappedXPos); + seekCursorPos(mappedXPos); slotCheckPositionScrolling(); return; } else m_moveOpMode = NONE; @@ -793,6 +801,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) else m_dragItem = collisionClip; found = true; + m_dragItem->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y()); m_dragItemInfo = m_dragItem->info(); if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET && m_dragItem->parentItem() != m_selectionGroup) { // kDebug()<<"// KLIK FOUND GRP: "<sceneBoundingRect(); @@ -934,7 +943,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) } m_operationMode = SPACER; } else { - setCursorPos((int)(mapToScene(event->x(), 0).x())); + seekCursorPos((int)(mapToScene(event->x(), 0).x())); } //QGraphicsView::mousePressEvent(event); event->ignore(); @@ -1010,7 +1019,11 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) // 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())); + if (m_dragItem->rect().width() * transform().m11() < 15) { + // If the item is very small, only allow move + m_operationMode = MOVE; + } + else m_operationMode = m_dragItem->operationMode(mapToScene(event->pos())); } m_controlModifier = (event->modifiers() == Qt::ControlModifier); @@ -1292,7 +1305,7 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event) ClipItem * item = static_cast (m_dragItem); //QString previous = item->keyframes(item->selectedEffectIndex()); QDomElement oldEffect = item->selectedEffect().cloneNode().toElement(); - item->insertKeyframe(item->getEffectAt(item->selectedEffectIndex()), keyFramePos.frames(m_document->fps()), val); + item->insertKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), keyFramePos.frames(m_document->fps()), val); //item->updateKeyframeEffect(); //QString next = item->keyframes(item->selectedEffectIndex()); QDomElement newEffect = item->selectedEffect().cloneNode().toElement(); @@ -1348,14 +1361,15 @@ void CustomTrackView::editItemDuration() else getClipAvailableSpace(item, minimum, maximum); - ClipDurationDialog d(item, m_document->timecode(), minimum, maximum, this); - if (d.exec() == QDialog::Accepted) { + QPointer d = new ClipDurationDialog(item, + m_document->timecode(), minimum, maximum, this); + if (d->exec() == QDialog::Accepted) { ItemInfo clipInfo = item->info(); ItemInfo startInfo = clipInfo; if (item->type() == TRANSITIONWIDGET) { // move & resize transition - clipInfo.startPos = d.startPos(); - clipInfo.endPos = clipInfo.startPos + d.duration(); + clipInfo.startPos = d->startPos(); + clipInfo.endPos = clipInfo.startPos + d->duration(); clipInfo.track = item->track(); MoveTransitionCommand *command = new MoveTransitionCommand(this, startInfo, clipInfo, true); updateTrackDuration(clipInfo.track, command); @@ -1365,10 +1379,10 @@ void CustomTrackView::editItemDuration() ClipItem *clip = static_cast(item); QUndoCommand *moveCommand = new QUndoCommand(); moveCommand->setText(i18n("Edit clip")); - if (d.duration() < item->cropDuration() || d.cropStart() != clipInfo.cropStart) { + if (d->duration() < item->cropDuration() || d->cropStart() != clipInfo.cropStart) { // duration was reduced, so process it first - clipInfo.endPos = clipInfo.startPos + d.duration(); - clipInfo.cropStart = d.cropStart(); + clipInfo.endPos = clipInfo.startPos + d->duration(); + clipInfo.cropStart = d->cropStart(); resizeClip(startInfo, clipInfo); new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand); @@ -1376,18 +1390,18 @@ void CustomTrackView::editItemDuration() new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand); } - if (d.startPos() != clipInfo.startPos) { + if (d->startPos() != clipInfo.startPos) { startInfo = clipInfo; - clipInfo.startPos = d.startPos(); + clipInfo.startPos = d->startPos(); clipInfo.endPos = item->endPos() + (clipInfo.startPos - startInfo.startPos); new MoveClipCommand(this, startInfo, clipInfo, true, moveCommand); } - if (d.duration() > item->cropDuration()) { + if (d->duration() > item->cropDuration()) { // duration was increased, so process it after move startInfo = clipInfo; - clipInfo.endPos = clipInfo.startPos + d.duration(); - clipInfo.cropStart = d.cropStart(); + clipInfo.endPos = clipInfo.startPos + d->duration(); + clipInfo.cropStart = d->cropStart(); resizeClip(startInfo, clipInfo); new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand); @@ -1398,6 +1412,7 @@ void CustomTrackView::editItemDuration() m_commandStack->push(moveCommand); } } + delete d; } else { emit displayMessage(i18n("Item is locked"), ErrorMessage); } @@ -1645,7 +1660,7 @@ void CustomTrackView::slotRefreshEffects(ClipItem *clip) } bool success = true; for (int i = 0; i < clip->effectsCount(); i++) { - if (!m_document->renderer()->mltAddEffect(track, pos, getEffectArgs(clip->effectAt(i)), false)) success = false; + if (!m_document->renderer()->mltAddEffect(track, pos, getEffectArgs(clip->effect(i)), false)) success = false; } if (!success) emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage); m_document->renderer()->doRefresh(); @@ -1733,6 +1748,7 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem * QList itemList = group->childItems(); QUndoCommand *effectCommand = new QUndoCommand(); QString effectName; + int offset = effect.attribute("clipstart").toInt(); QDomElement namenode = effect.firstChildElement("name"); if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data()); else effectName = i18n("effect"); @@ -1754,11 +1770,11 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem * subeffect.setAttribute("kdenlive_info", effectInfo.toString()); } } - processEffect(item, subeffect, effectCommand); + processEffect(item, subeffect, offset, effectCommand); } } else { - processEffect(item, effect, effectCommand); + processEffect(item, effect, offset, effectCommand); } } } @@ -1778,6 +1794,8 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) QList itemList; QUndoCommand *effectCommand = new QUndoCommand(); QString effectName; + + int offset = effect.attribute("clipstart").toInt(); if (effect.tagName() == "effectgroup") { effectName = effect.attribute("name"); } else { @@ -1821,10 +1839,10 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) subeffect.setAttribute("kdenlive_info", effectInfo.toString()); } } - processEffect(item, subeffect, effectCommand); + processEffect(item, subeffect, offset, effectCommand); } } - else processEffect(item, effect, effectCommand); + else processEffect(item, effect, offset, effectCommand); } } if (effectCommand->childCount() > 0) { @@ -1839,6 +1857,7 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) if (!clip->isSelected()) { clearSelection(false); clip->setSelected(true); + m_dragItem = clip; emit clipItemSelected(clip); } break; @@ -1848,7 +1867,7 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) } else delete effectCommand; } -void CustomTrackView::processEffect(ClipItem *item, QDomElement effect, QUndoCommand *effectCommand) +void CustomTrackView::processEffect(ClipItem *item, QDomElement effect, int offset, QUndoCommand *effectCommand) { if (effect.attribute("type") == "audio") { // Don't add audio effects on video clips @@ -1878,9 +1897,9 @@ void CustomTrackView::processEffect(ClipItem *item, QDomElement effect, QUndoCom } if (effect.attribute("id") == "freeze" && m_cursorPos > item->startPos().frames(m_document->fps()) && m_cursorPos < item->endPos().frames(m_document->fps())) { - item->initEffect(effect, m_cursorPos - item->startPos().frames(m_document->fps())); + item->initEffect(effect, m_cursorPos - item->startPos().frames(m_document->fps()), offset); } else { - item->initEffect(effect); + item->initEffect(effect, 0, offset); } new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand); } @@ -1919,7 +1938,7 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef ClipItem *item = static_cast (items.at(i)); int ix = item->hasEffect(effect.attribute("tag"), effect.attribute("id")); if (ix != -1) { - QDomElement eff = item->effectAt(ix); + QDomElement eff = item->effectAtIndex(ix); new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), eff, false, delCommand); } } @@ -1996,11 +2015,11 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") { // A fade effect was modified, update the clip if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") { - int pos = effectParams.paramValue("out").toInt() - effectParams.paramValue("in").toInt(); + int pos = EffectsList::parameter(effect, "out").toInt() - EffectsList::parameter(effect, "in").toInt(); clip->setFadeIn(pos); } if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") { - int pos = effectParams.paramValue("out").toInt() - effectParams.paramValue("in").toInt(); + int pos = EffectsList::parameter(effect, "out").toInt() - EffectsList::parameter(effect, "in").toInt(); clip->setFadeOut(pos); } } @@ -2089,13 +2108,13 @@ void CustomTrackView::moveEffect(int track, GenTime pos, QList oldPos, QLi } int old_position = oldPos.at(0); for (int i = 0; i < newPos.count(); i++) { - QDomElement act = clip->effectAt(new_position); + QDomElement act = clip->effectAtIndex(new_position); if (old_position > new_position) { // Moving up, we need to adjust index old_position = oldPos.at(i); new_position = newPos.at(i); } - QDomElement before = clip->effectAt(old_position); + QDomElement before = clip->effectAtIndex(old_position); if (act.isNull() || before.isNull()) { emit displayMessage(i18n("Cannot move effect"), ErrorMessage); return; @@ -2124,7 +2143,7 @@ void CustomTrackView::slotChangeEffectState(ClipItem *clip, int track, QList speedEffectIndexes; for (int i = 0; i < effectIndexes.count(); i++) { - QDomElement effect = clip->effectAt(effectIndexes.at(i)); + QDomElement effect = clip->effectAtIndex(effectIndexes.at(i)); if (effect.attribute("id") == "speed") { // speed effect speedEffectIndexes << effectIndexes.at(i); @@ -2164,7 +2183,7 @@ void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, int track, QDomElemen void CustomTrackView::slotUpdateClipRegion(ClipItem *clip, int ix, QString region) { - QDomElement effect = clip->getEffectAt(ix); + QDomElement effect = clip->getEffectAtIndex(ix); QDomElement oldeffect = effect.cloneNode().toElement(); effect.setAttribute("region", region); EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, true, true); @@ -2186,7 +2205,13 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo return NULL; } - if (execute) m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime); + if (execute) { + if (!m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime)) { + // Error cuting clip in playlist + m_blockRefresh = false; + return NULL; + } + } int cutPos = (int) cutTime.frames(m_document->fps()); ItemInfo newPos; newPos.startPos = cutTime; @@ -2203,23 +2228,23 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo // fade in from 2nd part of the clip int ix = dup->hasEffect(QString(), "fadein"); if (ix != -1) { - QDomElement oldeffect = dup->effectAt(ix); + QDomElement oldeffect = dup->effectAtIndex(ix); dup->deleteEffect(oldeffect.attribute("kdenlive_ix")); } ix = dup->hasEffect(QString(), "fade_from_black"); if (ix != -1) { - QDomElement oldeffect = dup->effectAt(ix); + QDomElement oldeffect = dup->effectAtIndex(ix); dup->deleteEffect(oldeffect.attribute("kdenlive_ix")); } // fade out from 1st part of the clip ix = item->hasEffect(QString(), "fadeout"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); item->deleteEffect(oldeffect.attribute("kdenlive_ix")); } ix = item->hasEffect(QString(), "fade_to_black"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); item->deleteEffect(oldeffect.attribute("kdenlive_ix")); } @@ -2260,12 +2285,12 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo // join fade effects again int ix = dup->hasEffect(QString(), "fadeout"); if (ix != -1) { - QDomElement effect = dup->effectAt(ix); + QDomElement effect = dup->effectAtIndex(ix); item->addEffect(effect); } ix = dup->hasEffect(QString(), "fade_to_black"); if (ix != -1) { - QDomElement effect = dup->effectAt(ix); + QDomElement effect = dup->effectAtIndex(ix); item->addEffect(effect); } @@ -3062,15 +3087,19 @@ void CustomTrackView::slotRemoveSpace() if (m_menuPosition.isNull()) { pos = GenTime(cursorPos(), m_document->fps()); - 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(); + QPointer d = new TrackDialog(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) { + delete d; + return; + } + track = d->comboTracks->currentIndex(); + delete d; } else { pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps()); track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight); @@ -3165,10 +3194,15 @@ void CustomTrackView::slotInsertSpace() pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps()); track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight) + 1; } - SpacerDialog d(GenTime(65, m_document->fps()), m_document->timecode(), track, m_document->tracksList(), this); - if (d.exec() != QDialog::Accepted) return; - GenTime spaceDuration = d.selectedDuration(); - track = d.selectedTrack(); + QPointer d = new SpacerDialog(GenTime(65, m_document->fps()), + m_document->timecode(), track, m_document->tracksList(), this); + if (d->exec() != QDialog::Accepted) { + delete d; + return; + } + GenTime spaceDuration = d->selectedDuration(); + track = d->selectedTrack(); + delete d; QList items; if (track >= 0) { @@ -3313,14 +3347,27 @@ void CustomTrackView::deleteClip(const QString &clipId) } } +void CustomTrackView::seekCursorPos(int pos) +{ + m_document->renderer()->seek(qMax(pos, 0)); + emit updateRuler(); +} + +int CustomTrackView::seekPosition() const +{ + return m_document->renderer()->requestedSeekPosition; +} + + void CustomTrackView::setCursorPos(int pos, bool seek) { - if (pos == m_cursorPos) return; - emit cursorMoved((int)(m_cursorPos), (int)(pos)); - m_cursorPos = pos; - if (seek) m_document->renderer()->seek(m_cursorPos); - else if (m_autoScroll) checkScrolling(); - m_cursorLine->setPos(m_cursorPos, 0); + if (pos != m_cursorPos) { + emit cursorMoved((int)(m_cursorPos), (int)(pos)); + m_cursorPos = pos; + m_cursorLine->setPos(m_cursorPos, 0); + if (m_autoScroll) checkScrolling(); + } + else emit updateRuler(); } void CustomTrackView::updateCursorPos() @@ -3335,11 +3382,15 @@ int CustomTrackView::cursorPos() void CustomTrackView::moveCursorPos(int delta) { - if (m_cursorPos + delta < 0) delta = 0 - m_cursorPos; - emit cursorMoved((int)(m_cursorPos), (int)((m_cursorPos + delta))); - m_cursorPos += delta; - m_cursorLine->setPos(m_cursorPos, 0); - m_document->renderer()->seek(m_cursorPos); + int currentPos = m_document->renderer()->requestedSeekPosition; + if (currentPos == SEEK_INACTIVE) { + currentPos = m_document->renderer()->seekPosition().frames(m_document->fps()) + delta; + } + else { + currentPos += delta; + } + m_document->renderer()->seek(qMax(0, currentPos)); + emit updateRuler(); } void CustomTrackView::initCursorPos(int pos) @@ -3390,6 +3441,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) track = -1; } else track = (int)(mapToScene(m_clickEvent).y() / m_tracksHeight); GenTime timeOffset = GenTime((int)(m_selectionGroup->scenePos().x()), m_document->fps()) - m_selectionGroupInfo.startPos; + QList groups; if (timeOffset != GenTime()) { QList items = m_selectionGroup->childItems(); @@ -3407,8 +3459,11 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) } for (int i = 0; i < items.count(); i++) { - if (items.at(i)->type() == GROUPWIDGET) - items += items.at(i)->childItems(); + if (items.at(i)->type() == GROUPWIDGET) { + AbstractGroupItem* group = (AbstractGroupItem*)items.at(i); + if (!groups.contains(group)) groups.append(group); + items += items.at(i)->childItems(); + } } for (int i = 0; i < items.count(); i++) { @@ -3438,7 +3493,13 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) setDocumentModified(); } } - resetSelectionGroup(false); + for (int i = 0; i < groups.count(); i++) + rebuildGroup(groups.at(i)); + + resetSelectionGroup(); + + clearSelection(); + m_operationMode = NONE; } else if (m_operationMode == RUBBERSELECTION) { resetSelectionGroup(); @@ -3581,7 +3642,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) KdenliveSettings::setSnaptopoints(false); item->setPos((int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItemInfo.track * m_tracksHeight + 1)); KdenliveSettings::setSnaptopoints(snap); - emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(m_dragItemInfo.startPos.frames(m_document->fps()))), ErrorMessage); + emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps()))), ErrorMessage); } setDocumentModified(); } else if (m_dragItem->type() == TRANSITIONWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) { @@ -3612,7 +3673,6 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) else group = static_cast (m_dragItem->parentItem()); QList items = group->childItems(); - QList clipsToMove; QList transitionsToMove; @@ -3670,7 +3730,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) adjustTimelineClips(m_scene->editMode(), clip, ItemInfo(), moveGroup); m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT); for (int i = 0; i < clip->effectsCount(); i++) { - m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false); + m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effect(i)), false); } } else { Transition *tr = static_cast (item); @@ -3696,13 +3756,19 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps()); m_selectionGroupInfo.track = m_selectionGroup->track(); + QList groupList; for (int i = 0; i < items.count(); ++i) { if (items.at(i)->type() == GROUPWIDGET) { - rebuildGroup((AbstractGroupItem*)items.at(i)); + AbstractGroupItem* group = (AbstractGroupItem*)items.at(i); + if (!groupList.contains(group)) groupList.append(group); items.removeAt(i); --i; } } + for (int i = 0; i < groupList.count(); ++i) { + rebuildGroup(groupList.at(i)); + } + for (int i = 0; i < items.count(); ++i) { if (items.at(i)) { items.at(i)->setSelected(true); @@ -3774,7 +3840,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) int ix = item->hasEffect("volume", "fadein"); int ix2 = item->hasEffect("", "fade_from_black"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); int start = item->cropStart().frames(m_document->fps()); int end = item->fadeIn(); if (end == 0) { @@ -3797,7 +3863,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) slotAddEffect(effect, m_dragItem->startPos(), m_dragItem->track()); } if (ix2 != -1) { - QDomElement oldeffect = item->effectAt(ix2); + QDomElement oldeffect = item->effectAtIndex(ix2); int start = item->cropStart().frames(m_document->fps()); int end = item->fadeIn(); if (end == 0) { @@ -3812,12 +3878,12 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) } } } else if (m_operationMode == FADEOUT) { - // resize fade in effect + // resize fade out effect ClipItem * item = static_cast (m_dragItem); int ix = item->hasEffect("volume", "fadeout"); int ix2 = item->hasEffect("", "fade_to_black"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps()); int start = item->fadeOut(); if (start == 0) { @@ -3837,12 +3903,14 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) // add video fade effect = MainWindow::videoEffects.getEffectByTag("", "fade_to_black").cloneNode().toElement(); } else effect = MainWindow::audioEffects.getEffectByTag("volume", "fadeout").cloneNode().toElement(); - EffectsList::setParameter(effect, "in", QString::number(item->fadeOut())); - EffectsList::setParameter(effect, "out", QString::number(0)); + int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps()); + int start = end-item->fadeOut(); + EffectsList::setParameter(effect, "in", QString::number(start)); + EffectsList::setParameter(effect, "out", QString::number(end)); slotAddEffect(effect, m_dragItem->startPos(), m_dragItem->track()); } if (ix2 != -1) { - QDomElement oldeffect = item->effectAt(ix2); + QDomElement oldeffect = item->effectAtIndex(ix2); int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps()); int start = item->fadeOut(); if (start == 0) { @@ -3872,9 +3940,9 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) if ((val < -50 || val > 150) && item->editedKeyFramePos() != start && item->editedKeyFramePos() != end && item->keyFrameNumber() > 1) { //delete keyframe - item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0); + item->movedKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0); } else { - item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue()); + item->movedKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue()); } QDomElement newEffect = item->selectedEffect().cloneNode().toElement(); @@ -4274,7 +4342,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i info.track = m_document->tracksCount() - info.track; m_document->renderer()->mltInsertClip(info, xml, item->getProducer(producerTrack), overwrite, push); for (int i = 0; i < item->effectsCount(); i++) { - m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effectAt(i)), false); + m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effect(i)), false); } setDocumentModified(); if (refresh) @@ -4302,7 +4370,7 @@ void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload) ItemInfo info = clip->info(); Mlt::Producer *prod = NULL; if (clip->isAudioOnly()) prod = baseClip->audioProducer(info.track); - else if (clip->isVideoOnly()) prod = baseClip->videoProducer(); + else if (clip->isVideoOnly()) prod = baseClip->videoProducer(info.track); else prod = baseClip->getProducer(info.track); if (reload && !m_document->renderer()->mltUpdateClip(tractor, info, clip->xml(), prod)) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage); @@ -4545,6 +4613,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta //m_selectionGroup->moveBy(offset.frames(m_document->fps()), trackOffset *(qreal) m_tracksHeight); QList children = m_selectionGroup->childItems(); + QList groupList; // Expand groups int max = children.count(); for (int i = 0; i < max; i++) { @@ -4554,6 +4623,8 @@ void CustomTrackView::moveGroup(QList startClip, QList sta //grp->moveBy(offset.frames(m_document->fps()), trackOffset *(qreal) m_tracksHeight); /*m_document->clipManager()->removeGroup(grp); m_scene->destroyItemGroup(grp);*/ + AbstractGroupItem *group = (AbstractGroupItem*) children.at(i); + if (!groupList.contains(group)) groupList.append(group); children.removeAll(children.at(i)); i--; } @@ -4578,7 +4649,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta info.track = m_document->tracksCount() - info.track; m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer)); for (int i = 0; i < clip->effectsCount(); i++) { - m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false); + m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effect(i)), false); } } else if (item->type() == TRANSITIONWIDGET) { Transition *tr = static_cast (item); @@ -4595,11 +4666,9 @@ void CustomTrackView::moveGroup(QList startClip, QList sta } resetSelectionGroup(false); + for (int i = 0; i < groupList.count(); i++) + rebuildGroup(groupList.at(i)); - for (int i = 0; i < children.count(); i++) { - if (children.at(i)->parentItem()) - rebuildGroup((AbstractGroupItem*)children.at(i)->parentItem()); - } clearSelection(); KdenliveSettings::setSnaptopoints(snap); @@ -4694,7 +4763,7 @@ void CustomTrackView::resizeClip(const ItemInfo &start, const ItemInfo &end, boo kDebug() << "// RESIZE CROP, DIFF: " << (end.cropStart - start.cropStart).frames(25); ItemInfo clipinfo = end; clipinfo.track = m_document->tracksCount() - end.track; - bool success = m_document->renderer()->mltResizeClipCrop(clipinfo, end.cropStart - start.cropStart); + bool success = m_document->renderer()->mltResizeClipCrop(clipinfo, end.cropStart); if (success) { item->setCropStart(end.cropStart); item->resetThumbs(true); @@ -4769,7 +4838,6 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol new ResizeClipCommand(this, oldInfo, info, false, true, command); adjustEffects(clip, oldInfo, command); new ResizeClipCommand(this, oldInfo, info, false, true, command); - emit clipItemSelected(clip); } else { KdenliveSettings::setSnaptopoints(false); item->resizeStart((int) oldInfo.startPos.frames(m_document->fps())); @@ -4864,7 +4932,6 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI new ResizeClipCommand(this, oldInfo, info, false, true, command); adjustEffects(clip, oldInfo, command); new ResizeClipCommand(this, oldInfo, info, false, true, command); - emit clipItemSelected(clip); } else { KdenliveSettings::setSnaptopoints(false); item->resizeEnd((int) oldInfo.endPos.frames(m_document->fps())); @@ -4907,7 +4974,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool // there is a fade in effect int effectPos = item->hasEffect("volume", "fadein"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int start = item->cropStart().frames(m_document->fps()); int max = item->cropDuration().frames(m_document->fps()); if (end > max) { @@ -4928,7 +4995,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool } effectPos = item->hasEffect("brightness", "fade_from_black"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int start = item->cropStart().frames(m_document->fps()); int max = item->cropDuration().frames(m_document->fps()); if (end > max) { @@ -4954,7 +5021,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool // there is a fade out effect int effectPos = item->hasEffect("volume", "fadeout"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int max = item->cropDuration().frames(m_document->fps()); int end = max + item->cropStart().frames(m_document->fps()); if (start > max) { @@ -4975,7 +5042,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool } effectPos = item->hasEffect("brightness", "fade_to_black"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int max = item->cropDuration().frames(m_document->fps()); int end = max + item->cropStart().frames(m_document->fps()); if (start > max) { @@ -5000,7 +5067,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool if (effectPos != -1) { // Freeze effect needs to be adjusted with clip resize int diff = (info.startPos - item->startPos()).frames(m_document->fps()); - QDomElement eff = item->getEffectAt(effectPos); + QDomElement eff = item->getEffectAtIndex(effectPos); if (!eff.isNull() && diff != 0) { int freeze_pos = EffectsList::parameter(eff, "frame").toInt() + diff; EffectsList::setParameter(eff, "frame", QString::number(freeze_pos)); @@ -5098,7 +5165,7 @@ void CustomTrackView::slotSeekToPreviousSnap() { updateSnapPoints(NULL); GenTime res = m_scene->previousSnapPoint(GenTime(m_cursorPos, m_document->fps())); - setCursorPos((int) res.frames(m_document->fps())); + seekCursorPos((int) res.frames(m_document->fps())); checkScrolling(); } @@ -5106,7 +5173,7 @@ void CustomTrackView::slotSeekToNextSnap() { updateSnapPoints(NULL); GenTime res = m_scene->nextSnapPoint(GenTime(m_cursorPos, m_document->fps())); - setCursorPos((int) res.frames(m_document->fps())); + seekCursorPos((int) res.frames(m_document->fps())); checkScrolling(); } @@ -5114,7 +5181,7 @@ void CustomTrackView::clipStart() { AbstractClipItem *item = getMainActiveClip(); if (item != NULL) { - setCursorPos((int) item->startPos().frames(m_document->fps())); + seekCursorPos((int) item->startPos().frames(m_document->fps())); checkScrolling(); } } @@ -5123,7 +5190,7 @@ void CustomTrackView::clipEnd() { AbstractClipItem *item = getMainActiveClip(); if (item != NULL) { - setCursorPos((int) item->endPos().frames(m_document->fps()) - 1); + seekCursorPos((int) item->endPos().frames(m_document->fps()) - 1); checkScrolling(); } } @@ -5185,7 +5252,7 @@ void CustomTrackView::buildGuidesMenu(QMenu *goMenu) const goMenu->clear(); double fps = m_document->fps(); for (int i = 0; i < m_guides.count(); i++) { - act = goMenu->addAction(m_guides.at(i)->label() + "/" + Timecode::getStringTimecode(m_guides.at(i)->position().frames(fps), fps)); + act = goMenu->addAction(m_guides.at(i)->label() + '/' + Timecode::getStringTimecode(m_guides.at(i)->position().frames(fps), fps)); act->setData(m_guides.at(i)->position().frames(m_document->fps())); } goMenu->setEnabled(!m_guides.isEmpty()); @@ -5239,10 +5306,14 @@ void CustomTrackView::slotAddGuide(bool dialog) { CommentedTime marker(GenTime(m_cursorPos, m_document->fps()), i18n("Guide")); if (dialog) { - MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this); - if (d.exec() != QDialog::Accepted) return; - marker = d.newMarker(); - + QPointer d = new MarkerDialog(NULL, marker, + m_document->timecode(), i18n("Add Guide"), this); + if (d->exec() != QDialog::Accepted) { + delete d; + return; + } + marker = d->newMarker(); + delete d; } else { marker.setComment(m_document->timecode().getDisplayTimecodeFromFrames(m_cursorPos, false)); } @@ -5270,11 +5341,12 @@ void CustomTrackView::slotEditGuide(int guidePos) void CustomTrackView::slotEditGuide(CommentedTime guide) { - MarkerDialog d(NULL, guide, m_document->timecode(), i18n("Edit Guide"), this); - if (d.exec() == QDialog::Accepted) { - EditGuideCommand *command = new EditGuideCommand(this, guide.time(), guide.comment(), d.newMarker().time(), d.newMarker().comment(), true); + QPointer d = new MarkerDialog(NULL, guide, m_document->timecode(), i18n("Edit Guide"), this); + if (d->exec() == QDialog::Accepted) { + EditGuideCommand *command = new EditGuideCommand(this, guide.time(), guide.comment(), d->newMarker().time(), d->newMarker().comment(), true); m_commandStack->push(command); } + delete d; } @@ -5282,11 +5354,13 @@ void CustomTrackView::slotEditTimeLineGuide() { if (m_dragGuide == NULL) return; CommentedTime guide = m_dragGuide->info(); - MarkerDialog d(NULL, guide, m_document->timecode(), i18n("Edit Guide"), this); - if (d.exec() == QDialog::Accepted) { - EditGuideCommand *command = new EditGuideCommand(this, guide.time(), guide.comment(), d.newMarker().time(), d.newMarker().comment(), true); + QPointer d = new MarkerDialog(NULL, guide, + m_document->timecode(), i18n("Edit Guide"), this); + if (d->exec() == QDialog::Accepted) { + EditGuideCommand *command = new EditGuideCommand(this, guide.time(), guide.comment(), d->newMarker().time(), d->newMarker().comment(), true); m_commandStack->push(command); } + delete d; } void CustomTrackView::slotDeleteGuide(int guidePos) @@ -5400,7 +5474,7 @@ bool CustomTrackView::findString(const QString &text) for (int i = 0; i < m_searchPoints.size(); ++i) { marker = m_searchPoints.at(i).comment(); if (marker.contains(text, Qt::CaseInsensitive)) { - setCursorPos(m_searchPoints.at(i).time().frames(m_document->fps()), true); + seekCursorPos(m_searchPoints.at(i).time().frames(m_document->fps())); int vert = verticalScrollBar()->value(); int hor = cursorPos(); ensureVisible(hor, vert + 10, 2, 2, 50, 0); @@ -5413,7 +5487,7 @@ bool CustomTrackView::findString(const QString &text) void CustomTrackView::selectFound(QString track, QString pos) { - setCursorPos(m_document->timecode().getFrameCount(pos), true); + seekCursorPos(m_document->timecode().getFrameCount(pos)); slotSelectTrack(track.toInt()); selectClip(true); int vert = verticalScrollBar()->value(); @@ -5427,7 +5501,7 @@ bool CustomTrackView::findNextString(const QString &text) for (int i = m_findIndex + 1; i < m_searchPoints.size(); ++i) { marker = m_searchPoints.at(i).comment(); if (marker.contains(text, Qt::CaseInsensitive)) { - setCursorPos(m_searchPoints.at(i).time().frames(m_document->fps()), true); + seekCursorPos(m_searchPoints.at(i).time().frames(m_document->fps())); int vert = verticalScrollBar()->value(); int hor = cursorPos(); ensureVisible(hor, vert + 10, 2, 2, 50, 0); @@ -5690,8 +5764,8 @@ void CustomTrackView::pasteClipEffects() for (int i = 0; i < clips.count(); ++i) { if (clips.at(i)->type() == AVWIDGET) { ClipItem *item = static_cast < ClipItem *>(clips.at(i)); - for (int j = 1; j <= clip->effectsCount(); j++) { - QDomElement eff = clip->effectAt(j); + for (int j = 0; j < clip->effectsCount(); j++) { + QDomElement eff = clip->effect(j); if (eff.attribute("unique", "0") == "0" || item->hasEffect(eff.attribute("tag"), eff.attribute("id")) == -1) { adjustKeyfames(clip->cropStart(), item->cropStart(), item->cropDuration(), eff); new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), eff, true, paste); @@ -5724,7 +5798,7 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { QString def = e.attribute("default"); // Effect has a keyframe type parameter, we need to adjust the values - QStringList keys = e.attribute("keyframes").split(";", QString::SkipEmptyParts); + QStringList keys = e.attribute("keyframes").split(';', QString::SkipEmptyParts); QStringList newKeyFrames; foreach(const QString &str, keys) { int pos = str.section(':', 0, 0).toInt(); @@ -5806,7 +5880,26 @@ void CustomTrackView::setInPoint() return; } } - prepareResizeClipStart(clip, clip->info(), m_cursorPos, true); + + AbstractGroupItem *parent = static_cast (clip->parentItem()); + if (parent) { + // Resizing a group + QUndoCommand *resizeCommand = new QUndoCommand(); + resizeCommand->setText(i18n("Resize group")); + QList items = parent->childItems(); + for (int i = 0; i < items.count(); ++i) { + AbstractClipItem *item = static_cast(items.at(i)); + if (item && item->type() == AVWIDGET) { + prepareResizeClipStart(item, item->info(), m_cursorPos, true, resizeCommand); + } + } + if (resizeCommand->childCount() > 0) m_commandStack->push(resizeCommand); + else { + //TODO warn user of failed resize + delete resizeCommand; + } + } + else prepareResizeClipStart(clip, clip->info(), m_cursorPos, true); } void CustomTrackView::setOutPoint() @@ -5820,7 +5913,25 @@ void CustomTrackView::setOutPoint() return; } } - prepareResizeClipEnd(clip, clip->info(), m_cursorPos, true); + AbstractGroupItem *parent = static_cast (clip->parentItem()); + if (parent) { + // Resizing a group + QUndoCommand *resizeCommand = new QUndoCommand(); + resizeCommand->setText(i18n("Resize group")); + QList items = parent->childItems(); + for (int i = 0; i < items.count(); ++i) { + AbstractClipItem *item = static_cast(items.at(i)); + if (item && item->type() == AVWIDGET) { + prepareResizeClipEnd(item, item->info(), m_cursorPos, true, resizeCommand); + } + } + if (resizeCommand->childCount() > 0) m_commandStack->push(resizeCommand); + else { + //TODO warn user of failed resize + delete resizeCommand; + } + } + else prepareResizeClipEnd(clip, clip->info(), m_cursorPos, true); } void CustomTrackView::slotUpdateAllThumbs() @@ -5903,21 +6014,21 @@ void CustomTrackView::saveThumbnails() void CustomTrackView::slotInsertTrack(int ix) { - TrackDialog d(m_document, parentWidget()); - d.comboTracks->setCurrentIndex(ix); - d.label->setText(i18n("Insert track")); - d.setWindowTitle(i18n("Insert New Track")); + QPointer d = new TrackDialog(m_document, parentWidget()); + d->comboTracks->setCurrentIndex(ix); + d->label->setText(i18n("Insert track")); + d->setWindowTitle(i18n("Insert New Track")); - if (d.exec() == QDialog::Accepted) { - ix = d.comboTracks->currentIndex(); - if (d.before_select->currentIndex() == 1) + if (d->exec() == QDialog::Accepted) { + ix = d->comboTracks->currentIndex(); + if (d->before_select->currentIndex() == 1) ix++; TrackInfo info; info.duration = 0; info.isMute = false; info.isLocked = false; info.effectsList = EffectsList(true); - if (d.video_track->isChecked()) { + if (d->video_track->isChecked()) { info.type = VIDEOTRACK; info.isBlind = false; } else { @@ -5928,41 +6039,45 @@ void CustomTrackView::slotInsertTrack(int ix) m_commandStack->push(addTrack); setDocumentModified(); } + delete d; } void CustomTrackView::slotDeleteTrack(int ix) { if (m_document->tracksCount() < 2) return; - TrackDialog d(m_document, parentWidget()); - d.comboTracks->setCurrentIndex(ix); - d.label->setText(i18n("Delete track")); - d.before_select->setHidden(true); - d.setWindowTitle(i18n("Delete Track")); - d.video_track->setHidden(true); - d.audio_track->setHidden(true); - if (d.exec() == QDialog::Accepted) { - ix = d.comboTracks->currentIndex(); + QPointer d = new TrackDialog(m_document, parentWidget()); + d->comboTracks->setCurrentIndex(ix); + d->label->setText(i18n("Delete track")); + d->before_select->setHidden(true); + d->setWindowTitle(i18n("Delete Track")); + d->video_track->setHidden(true); + d->audio_track->setHidden(true); + if (d->exec() == QDialog::Accepted) { + ix = d->comboTracks->currentIndex(); TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - ix - 1); deleteTimelineTrack(ix, info); setDocumentModified(); /*AddTrackCommand* command = new AddTrackCommand(this, ix, info, false); m_commandStack->push(command);*/ } + delete d; } void CustomTrackView::slotConfigTracks(int ix) { - TracksConfigDialog d(m_document, ix, parentWidget()); - if (d.exec() == QDialog::Accepted) { - ConfigTracksCommand *configTracks = new ConfigTracksCommand(this, m_document->tracksList(), d.tracksList()); + QPointer d = new TracksConfigDialog(m_document, + ix, parentWidget()); + if (d->exec() == QDialog::Accepted) { + ConfigTracksCommand *configTracks = new ConfigTracksCommand(this, m_document->tracksList(), d->tracksList()); m_commandStack->push(configTracks); - QList toDelete = d.deletedTracks(); + QList toDelete = d->deletedTracks(); for (int i = 0; i < toDelete.count(); ++i) { TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - toDelete.at(i) + i - 1); deleteTimelineTrack(toDelete.at(i) - i, info); } setDocumentModified(); } + delete d; } void CustomTrackView::deleteTimelineTrack(int ix, TrackInfo trackinfo) @@ -6123,11 +6238,15 @@ void CustomTrackView::setAudioAlignReference() if (clip->clipType() == AV || clip->clipType() == AUDIO) { m_audioAlignmentReference = clip; - AudioEnvelope *envelope = new AudioEnvelope(clip->getProducer(clip->track())); + AudioEnvelope *envelope = new AudioEnvelope(clip->baseClip()->fileURL().path(), clip->getProducer(clip->track())); m_audioCorrelator = new AudioCorrelation(envelope); + +#ifdef DEBUG envelope->drawEnvelope().save("kdenlive-audio-reference-envelope.png"); envelope->dumpInfo(); +#endif + emit displayMessage(i18n("Audio align reference set."), InformationMessage); } @@ -6164,9 +6283,7 @@ void CustomTrackView::alignAudio() } if (clip->clipType() == AV || clip->clipType() == AUDIO) { - AudioEnvelope *envelope = new AudioEnvelope(clip->getProducer(clip->track()), - clip->info().cropStart.frames(m_document->fps()), - clip->info().cropDuration.frames(m_document->fps())); + AudioEnvelope *envelope = new AudioEnvelope(clip->baseClip()->fileURL().path(), clip->getProducer(clip->track()), clip->info().cropStart.frames(m_document->fps()), clip->info().cropDuration.frames(m_document->fps())); // FFT only for larger vectors. We could use it all time, but for small vectors // the (anyway not noticeable) overhead is smaller with a nested for loop correlation. @@ -6174,11 +6291,12 @@ void CustomTrackView::alignAudio() int shift = m_audioCorrelator->getShift(index); counter++; + +#ifdef DEBUG m_audioCorrelator->info(index)->toImage().save("kdenlive-audio-align-cross-correlation.png"); envelope->drawEnvelope().save("kdenlive-audio-align-envelope.png"); envelope->dumpInfo(); -#ifdef DEBUG int targetPos = m_audioAlignmentReference->startPos().frames(m_document->fps()) + shift; qDebug() << "Reference starts at " << m_audioAlignmentReference->startPos().frames(m_document->fps()); qDebug() << "We will start at " << targetPos; @@ -6239,7 +6357,7 @@ void CustomTrackView::alignAudio() if (counter == 0) { emit displayMessage(i18n("No audio clips selected."), ErrorMessage); } else { - emit displayMessage(i18n("Auto-aligned %1 clips.").arg(counter), InformationMessage); + emit displayMessage(i18n("Auto-aligned %1 clips.", counter), InformationMessage); } } @@ -6281,7 +6399,7 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList ef if (audioClip) { Mlt::Tractor *tractor = m_document->renderer()->lockService(); clip->setVideoOnly(true); - if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) { + if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer(info.track)) == false) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage); } if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) { @@ -6296,10 +6414,10 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList ef 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)); + deleteEffect(m_document->tracksCount() - track, pos, clip->effect(videoIx)); audioIx++; } else { - deleteEffect(freetrack, pos, audioClip->effectAt(audioIx)); + deleteEffect(freetrack, pos, audioClip->effect(audioIx)); videoIx++; } } @@ -6441,7 +6559,7 @@ void CustomTrackView::doChangeClipType(const GenTime &pos, int track, bool video int start = pos.frames(m_document->fps()); clip->setVideoOnly(true); clip->setAudioOnly(false); - if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) { + if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer(track)) == false) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage); } } else if (audioOnly) { @@ -6487,7 +6605,7 @@ void CustomTrackView::updateClipTypeActions(ClipItem *clip) void CustomTrackView::slotGoToMarker(QAction *action) { int pos = action->data().toInt(); - setCursorPos(pos, true); + seekCursorPos(pos); } void CustomTrackView::reloadTransitionLumas() @@ -6987,13 +7105,13 @@ void CustomTrackView::adjustEffectParameters(EffectsParameterList ¶meters, Q parameters.addParam("_sync_in_out", "1"); } if (e.attribute("type") == "simplekeyframe") { - QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts); + 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() - offset) / factor; - values[j] = pos + "=" + locale.toString(val); + values[j] = pos + '=' + locale.toString(val); } // kDebug() << "/ / / /SENDING KEYFR:" << values; parameters.addParam(paramname, values.join(";")); @@ -7130,7 +7248,7 @@ void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoComma if (effects.count()) { QMap::const_iterator i = effects.constBegin(); while (i != effects.constEnd()) { - new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, false, command); + new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effect(i.key()), i.value().attribute("kdenlive_ix").toInt(), true, true, command); ++i; } } @@ -7145,7 +7263,7 @@ void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPo return; } QDomElement newEffect; - QDomElement effect = clip->getEffectAt(clip->selectedEffectIndex()); + QDomElement effect = clip->getEffectAtIndex(clip->selectedEffectIndex()); if (effect.attribute("id") == filter) { newEffect = effect.cloneNode().toElement(); QMap::const_iterator i = filterParams.constBegin(); @@ -7157,8 +7275,7 @@ void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPo EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true); m_commandStack->push(command); emit clipItemSelected(clip); - } - + } }