for (int i = 0; i < list.count(); i++) {
if (list.at(i)->data().toString() == "paste_effects") m_pasteEffectsAction = list.at(i);
else if (list.at(i)->data().toString() == "ungroup_clip") m_ungroupAction = list.at(i);
+ else if (list.at(i)->data().toString() == "A") m_audioActions.append(list.at(i));
+ else if (list.at(i)->data().toString() == "A+V") m_avActions.append(list.at(i));
}
m_timelineContextTransitionMenu = transition;
if (event->buttons() != Qt::NoButton && event->modifiers() == Qt::NoModifier) {
QGraphicsView::mouseMoveEvent(event);
m_moveOpMode = SEEK;
- seekCursorPos(mappedXPos);
- slotCheckPositionScrolling();
+ if (mappedXPos != m_document->renderer()->getCurrentSeekPosition() && mappedXPos != cursorPos()) {
+ seekCursorPos(mappedXPos);
+ slotCheckPositionScrolling();
+ }
return;
} else m_moveOpMode = NONE;
}
m_dragGuide = NULL;
if (m_tool != RAZORTOOL) activateMonitor();
- else if (m_document->renderer()->playSpeed() != 0.0) {
+ else if (m_document->renderer()->isPlaying()) {
m_document->renderer()->pause();
return;
}
AbstractGroupItem *dragGroup = NULL;
AbstractClipItem *collisionClip = NULL;
bool found = false;
+ QStringList lockedTracks;
+ double yOffset = 0;
while (!m_dragGuide && ct < collisionList.count()) {
if (collisionList.at(ct)->type() == AVWIDGET || collisionList.at(ct)->type() == TRANSITIONWIDGET) {
collisionClip = static_cast <AbstractClipItem *>(collisionList.at(ct));
m_dragItem = collisionClip;
}
found = true;
-
- m_dragItem->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
+ for (int i = 0; i < m_document->tracksCount(); i++) {
+ if (m_document->trackInfoAt(i).isLocked) lockedTracks << QString::number(m_document->tracksCount() - i - 1);
+ }
+ yOffset = mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y();
+ m_dragItem->setProperty("y_absolute", yOffset);
+ m_dragItem->setProperty("locked_tracks", lockedTracks);
m_dragItemInfo = m_dragItem->info();
- if (m_selectionGroup) m_selectionGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
- if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET && m_dragItem->parentItem() != m_selectionGroup) {
+ if (m_selectionGroup) {
+ m_selectionGroup->setProperty("y_absolute", yOffset);
+ m_selectionGroup->setProperty("locked_tracks", lockedTracks);
+ }
+ if (dragGroup) {
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
- dragGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
+ dragGroup->setProperty("y_absolute", yOffset);
+ dragGroup->setProperty("locked_tracks", lockedTracks);
}
break;
}
bool selected = !m_dragItem->isSelected();
QGraphicsView::mousePressEvent(event);
-
if (dragGroup) {
dragGroup->setSelected(selected);
- if (dragGroup->parentItem())
+ QList<QGraphicsItem *> children = dragGroup->childItems();
+ for (int i = 0; i < children.count(); i++) {
+ children.at(i)->setSelected(selected);
+ }
+ if (dragGroup->parentItem()) {
dragGroup->parentItem()->setSelected(selected);
+ }
}
else
m_dragItem->setSelected(selected);
m_dragItem = NULL;
}
groupSelectedItems(QList <QGraphicsItem*>(), false, true);
+ if (m_selectionGroup) {
+ m_selectionGroup->setProperty("y_absolute", yOffset);
+ m_selectionGroup->setProperty("locked_tracks", lockedTracks);
+ }
+
if (m_dragItem) {
ClipItem *clip = static_cast <ClipItem *>(m_dragItem);
updateClipTypeActions(dragGroup == NULL ? clip : NULL);
QSet <QGraphicsItem *> itemsList;
for (int i = 0; i < selection.count(); i++) {
+ if (selectNewGroup) selection.at(i)->setSelected(true);
if (selection.at(i)->type() == GROUPWIDGET) {
groupsList.insert(static_cast<AbstractGroupItem*> (selection.at(i)));
}
return;
}
- AddTimelineClipCommand *command = new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), pasteInfo, EffectsList(), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT, true, false);
- updateTrackDuration(pasteInfo.track, command);
- m_commandStack->push(command);
+ // Add refresh command for undo
+ QUndoCommand *addCommand = new QUndoCommand();
+ addCommand->setText(i18n("Add timeline clip"));
+ new RefreshMonitorCommand(this, false, true, addCommand);
+ new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), pasteInfo, EffectsList(), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT, true, false, addCommand);
+ new RefreshMonitorCommand(this, true, false, addCommand);
+ updateTrackDuration(pasteInfo.track, addCommand);
+
+ m_commandStack->push(addCommand);
selectClip(true, false);
// Automatic audio split
m_document->updateClip(item->baseClip()->getId());
setDocumentModified();
KdenliveSettings::setSnaptopoints(snap);
- if (execute && item->isSelected())
- emit clipItemSelected(item);
+ if (execute && item->isSelected()) {
+ m_scene->clearSelection();
+ dup->setSelected(true);
+ m_dragItem = dup;
+ emit clipItemSelected(dup);
+ }
return dup;
} else {
// uncut clip
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
- bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, info.endPos - info.startPos);
+ bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, info.endPos - info.startPos, false);
if (success) {
item->resizeEnd((int) info.endPos.frames(m_document->fps()));
setDocumentModified();
QUndoCommand *addCommand = new QUndoCommand();
addCommand->setText(i18n("Add timeline clip"));
QList <ClipItem *> brokenClips;
+
+ // Add refresh command for undo
+ new RefreshMonitorCommand(this, false, true, addCommand);
for (int i = 0; i < items.count(); i++) {
ClipItem *item = static_cast <ClipItem *>(items.at(i));
}
item->setSelected(true);
}
+ // Add refresh command for redo
+ new RefreshMonitorCommand(this, false, false, addCommand);
+
qDeleteAll(brokenClips);
brokenClips.clear();
if (addCommand->childCount() > 0) m_commandStack->push(addCommand);
item->updateRectGeometry();
if (item->cropDuration().frames(m_document->fps()) != endPos)
item->resizeEnd((int) info.startPos.frames(m_document->fps()) + endPos - 1);
- updatePositionEffects(item, info);
+ updatePositionEffects(item, info, false);
setDocumentModified();
} else {
emit displayMessage(i18n("Invalid clip"), ErrorMessage);
if (effectPos != -1) {
QDomElement effect = item->getEffectAtIndex(effectPos);
int max = item->cropDuration().frames(m_document->fps());
- int end = max + item->cropStart().frames(m_document->fps());
+ int end = max + item->cropStart().frames(m_document->fps()) - 1;
if (start > max) {
// Make sure the fade effect is not longer than the clip
item->setFadeOut(max);
if (effectPos != -1) {
QDomElement effect = item->getEffectAtIndex(effectPos);
int max = item->cropDuration().frames(m_document->fps());
- int end = max + item->cropStart().frames(m_document->fps());
+ int end = max + item->cropStart().frames(m_document->fps()) - 1;
if (start > max) {
// Make sure the fade effect is not longer than the clip
item->setFadeOut(max);
void CustomTrackView::editGuide(const GenTime &oldPos, const GenTime &pos, const QString &comment)
{
- if (oldPos > GenTime() && pos > GenTime()) {
- // move guide
+ if (comment.isEmpty() && pos < GenTime()) {
+ // Delete guide
+ bool found = false;
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == oldPos) {
- Guide *item = m_guides.at(i);
- item->updateGuide(pos, comment);
+ delete m_guides.takeAt(i);
+ found = true;
break;
}
}
- } else if (pos > GenTime()) addGuide(pos, comment);
- else {
- // remove guide
- bool found = false;
+ if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
+ }
+
+ else if (oldPos >= GenTime()) {
+ // move guide
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == oldPos) {
- delete m_guides.takeAt(i);
- found = true;
+ Guide *item = m_guides.at(i);
+ item->updateGuide(pos, comment);
break;
}
}
- if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
- }
+ } else addGuide(pos, comment);
qSort(m_guides.begin(), m_guides.end(), sortGuidesList);
m_document->syncGuides(m_guides);
}
bool found = false;
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == pos) {
- EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true);
+ EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(-1), QString(), true);
m_commandStack->push(command);
found = true;
break;
void CustomTrackView::slotDeleteTimeLineGuide()
{
if (m_dragGuide == NULL) return;
- EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(), QString(), true);
+ EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(-1), QString(), true);
m_commandStack->push(command);
}
QUndoCommand *deleteAll = new QUndoCommand();
deleteAll->setText("Delete all guides");
for (int i = 0; i < m_guides.count(); i++) {
- new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true, deleteAll);
+ new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(-1), QString(), true, deleteAll);
}
m_commandStack->push(deleteAll);
}
QList<QGraphicsItem *> selection = m_scene->items(r);
QUndoCommand *deleteTrack = new QUndoCommand();
deleteTrack->setText("Delete track");
+ new RefreshMonitorCommand(this, false, true, deleteTrack);
// Delete all clips in selected track
for (int i = 0; i < selection.count(); i++) {
}
new AddTrackCommand(this, ix, trackinfo, false, deleteTrack);
+ new RefreshMonitorCommand(this, true, false, deleteTrack);
m_commandStack->push(deleteTrack);
}
void CustomTrackView::updateClipTypeActions(ClipItem *clip)
{
+ bool hasAudio;
+ bool hasAV;
if (clip == NULL || (clip->clipType() != AV && clip->clipType() != PLAYLIST)) {
m_clipTypeGroup->setEnabled(false);
+ hasAudio = clip != NULL && clip->clipType() == AUDIO;
+ hasAV = false;
} else {
+ switch (clip->clipType()) {
+ case AV:
+ case PLAYLIST:
+ hasAudio = true;
+ hasAV = true;
+ break;
+ case AUDIO:
+ hasAudio = true;
+ hasAV = false;
+ break;
+ default:
+ hasAudio = false;
+ hasAV = false;
+ }
m_clipTypeGroup->setEnabled(true);
QList <QAction *> actions = m_clipTypeGroup->actions();
QString lookup;
}
}
}
+
+ for (int i = 0; i < m_audioActions.count(); i++) {
+ m_audioActions.at(i)->setEnabled(hasAudio);
+ }
+ for (int i = 0; i < m_avActions.count(); i++) {
+ m_avActions.at(i)->setEnabled(hasAV);
+ }
}
void CustomTrackView::slotGoToMarker(QAction *action)