m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
- pixmapCache = new KPixmapCache("kdenlive-thumbs");
+ m_pixmapCache = new KPixmapCache("kdenlive-thumbs");
m_animationTimer = new QTimeLine(800);
m_animationTimer->setFrameRange(0, 5);
qDeleteAll(m_guides);
m_guides.clear();
m_waitingThumbs.clear();
+ delete m_pixmapCache;
+ delete m_animationTimer;
}
//virtual
{
if (!m_waitingThumbs.isEmpty()) {
ClipItem *item = m_waitingThumbs.takeFirst();
- while ((item == NULL) && !m_waitingThumbs.isEmpty()) {
+ while (item == NULL && !m_waitingThumbs.isEmpty()) {
item = m_waitingThumbs.takeFirst();
}
if (item) item->slotFetchThumbs();
{
int pos = event->x();
int mappedXPos = qMax((int)(mapToScene(event->pos()).x() + 0.5), 0);
+
double snappedPos = getSnapPointForPos(mappedXPos);
emit mousePosition(mappedXPos);
}
m_moveOpMode = opMode;
setTipAnimation(clip, opMode, size);
+ ClipItem *ci = NULL;
+ if (item->type() == AVWIDGET)
+ ci = static_cast <ClipItem *>(item);
+ QString message;
if (opMode == MOVE) {
setCursor(Qt::OpenHandCursor);
- if (item->type() == AVWIDGET) {
- ClipItem *ci = static_cast <ClipItem *>(item);
- QString message = ci->clipName() + i18n(":");
+ if (ci) {
+ message = ci->clipName() + i18n(":");
message.append(i18n(" Position:") + m_document->timecode().getDisplayTimecode(ci->info().startPos, KdenliveSettings::frametimecode()));
message.append(i18n(" Duration:") + m_document->timecode().getDisplayTimecode(ci->cropDuration(), KdenliveSettings::frametimecode()));
if (clip->parentItem() && clip->parentItem()->type() == GROUPWIDGET) {
message.append(i18n(" Selection duration:") + m_document->timecode().getDisplayTimecode(parent2->duration(), KdenliveSettings::frametimecode()));
}
}
- emit displayMessage(message, InformationMessage);
}
} else if (opMode == RESIZESTART) {
setCursor(KCursor("left_side", Qt::SizeHorCursor));
+ if (ci)
+ message = i18n("Crop from start: ") + m_document->timecode().getDisplayTimecode(ci->cropStart(), KdenliveSettings::frametimecode());
if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
- emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+ message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
} else if (opMode == RESIZEEND) {
setCursor(KCursor("right_side", Qt::SizeHorCursor));
+ if (ci)
+ message = i18n("Duration: ") + m_document->timecode().getDisplayTimecode(ci->cropDuration(), KdenliveSettings::frametimecode());
if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
- emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+ message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
} else if (opMode == FADEIN || opMode == FADEOUT) {
setCursor(Qt::PointingHandCursor);
- emit displayMessage(i18n("Drag to add or resize a fade effect."), InformationMessage);
+ if (ci && opMode == FADEIN && ci->fadeIn()) {
+ message = i18n("Fade in duration: ");
+ message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeIn(), KdenliveSettings::frametimecode()));
+ } else if (ci && opMode == FADEOUT && ci->fadeOut()) {
+ message = i18n("Fade out duration: ");
+ message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeOut(), KdenliveSettings::frametimecode()));
+ } else {
+ message = i18n("Drag to add or resize a fade effect.");
+ }
} else if (opMode == TRANSITIONSTART || opMode == TRANSITIONEND) {
setCursor(Qt::PointingHandCursor);
- emit displayMessage(i18n("Click to add a transition."), InformationMessage);
+ message = i18n("Click to add a transition.");
} else if (opMode == KEYFRAME) {
setCursor(Qt::PointingHandCursor);
emit displayMessage(i18n("Move keyframe above or below clip to remove it, double click to add a new one."), InformationMessage);
}
+
+ if (!message.isEmpty())
+ emit displayMessage(message, InformationMessage);
} // no clip under mouse
else if (m_tool == RAZORTOOL) {
event->accept();
} else resetSelectionGroup();
dragGroup = NULL;
if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET) {
- //kDebug()<<"// KLIK FOUND GRP: "<<m_dragItem->sceneBoundingRect();
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
}
bool selected = !m_dragItem->isSelected();
children.at(i)->setSelected(selectItems);
}
}
+
m_selectionGroup = NULL;
KdenliveSettings::setSnaptopoints(snap);
}
kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0);
return false;
}
+ if (clip->producer() == NULL) {
+ emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+ return false;
+ }
QPointF framePos = mapToScene(pos);
ItemInfo info;
info.startPos = GenTime();
kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i);
return false;
}
+ if (clip->producer() == NULL) {
+ emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+ return false;
+ }
ItemInfo info;
info.startPos = start;
info.cropDuration = clip->duration();
}
}
}
- if (delCommand->childCount() > 0) m_commandStack->push(delCommand);
- else delete delCommand;
+ if (delCommand->childCount() > 0)
+ m_commandStack->push(delCommand);
+ else
+ delete delCommand;
+ setDocumentModified();
return;
}
AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, false);
return NULL;
}
- kDebug() << "///////// CUTTING CLIP : (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), INFO: (" << info.startPos.frames(25) << "-" << info.endPos.frames(25) << ")" << ", CUT: " << cutTime.frames(25);
-
if (execute) m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime);
int cutPos = (int) cutTime.frames(m_document->fps());
ItemInfo newPos;
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
ClipItem *dup = item->clone(newPos);
- // remove unwanted effects (fade in) from 2nd part of cutted clip
+
+ // remove unwanted effects
+ // fade in from 2nd part of the clip
int ix = dup->hasEffect(QString(), "fadein");
if (ix != -1) {
- QDomElement oldeffect = item->effectAt(ix);
+ QDomElement oldeffect = dup->effectAt(ix);
dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
}
ix = dup->hasEffect(QString(), "fade_from_black");
if (ix != -1) {
- QDomElement oldeffect = item->effectAt(ix);
+ QDomElement oldeffect = dup->effectAt(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);
+ item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+ }
+ ix = item->hasEffect(QString(), "fade_to_black");
+ if (ix != -1) {
+ QDomElement oldeffect = item->effectAt(ix);
+ item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+ }
+
+
item->resizeEnd(cutPos);
scene()->addItem(dup);
if (item->checkKeyFrames())
m_document->updateClip(item->baseClip()->getId());
setDocumentModified();
KdenliveSettings::setSnaptopoints(snap);
+ if (execute && item->isSelected())
+ emit clipItemSelected(item);
return dup;
- //kDebug() << "///////// CUTTING CLIP RESULT: (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), DUP: (" << dup->startPos().frames(25) << "-" << dup->endPos().frames(25) << ")" << ", CUT: " << cutTime.frames(25);
} else {
// uncut clip
return NULL;
}
- /*kDebug() << "// UNCUTTING CLIPS: ITEM 1 (" << item->startPos().frames(25) << "x" << item->endPos().frames(25) << ")";
- kDebug() << "// UNCUTTING CLIPS: ITEM 2 (" << dup->startPos().frames(25) << "x" << dup->endPos().frames(25) << ")";
- kDebug() << "// UNCUTTING CLIPS, INFO (" << info.startPos.frames(25) << "x" << info.endPos.frames(25) << ") , CUT: " << cutTime.frames(25);;*/
- //deleteClip(dup->info());
-
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
- if (dup->isSelected()) emit clipItemSelected(NULL);
+ // join fade effects again
+ int ix = dup->hasEffect(QString(), "fadeout");
+ if (ix != -1) {
+ QDomElement effect = dup->effectAt(ix);
+ item->addEffect(effect);
+ }
+ ix = dup->hasEffect(QString(), "fade_to_black");
+ if (ix != -1) {
+ QDomElement effect = dup->effectAt(ix);
+ item->addEffect(effect);
+ }
+
+ m_waitingThumbs.removeAll(dup);
+ bool selected = item->isSelected();
+ if (dup->isSelected()) {
+ selected = true;
+ item->setSelected(true);
+ emit clipItemSelected(NULL);
+ }
dup->baseClip()->removeReference();
m_document->updateClip(dup->baseClip()->getId());
scene()->removeItem(dup);
delete dup;
+ dup = NULL;
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
KdenliveSettings::setSnaptopoints(snap);
+ if (execute && selected)
+ emit clipItemSelected(item);
return item;
}
//QTimer::singleShot(3000, this, SLOT(slotEnableRefresh()));
kWarning() << "Unable to find transition at pos :" << pos.frames(m_document->fps()) << ", ON track: " << track;
return;
}
+
bool force = false;
if (oldTransition.attribute("transition_atrack") != transition.attribute("transition_atrack") || oldTransition.attribute("transition_btrack") != transition.attribute("transition_btrack"))
force = true;
adjustTimelineClips(m_scene->editMode(), item, ItemInfo(), addCommand);
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT, false, false, addCommand);
- updateTrackDuration(clipInfo.track, addCommand);
+ updateTrackDuration(info.track, addCommand);
if (item->baseClip()->isTransparent() && getTransitionItemAtStart(info.startPos, info.track) == NULL) {
// add transparency transition
}
} else if (clip->endPos() <= info.endPos) {
new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), clip->info(), clip->effectList(), false, false, false, true, command);
+ m_waitingThumbs.removeAll(clip);
scene()->removeItem(clip);
delete clip;
clip = NULL;
track = d.selectedTrack();
QList<QGraphicsItem *> items;
- if (track > 0) {
+ if (track >= 0) {
if (m_document->isTrackLocked(m_document->tracksCount() - track - 1)) {
emit displayMessage(i18n("Cannot insert space in a locked track"), ErrorMessage);
return;
if (pos == m_cursorPos) return;
emit cursorMoved((int)(m_cursorPos), (int)(pos));
m_cursorPos = pos;
- if (seek) m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+ if (seek) m_document->renderer()->seek(m_cursorPos);
else if (m_autoScroll) checkScrolling();
m_cursorLine->setPos(m_cursorPos, 0);
}
emit cursorMoved((int)(m_cursorPos), (int)((m_cursorPos + delta)));
m_cursorPos += delta;
m_cursorLine->setPos(m_cursorPos, 0);
- m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+ m_document->renderer()->seek(m_cursorPos);
}
void CustomTrackView::initCursorPos(int pos)
resetSelectionGroup(false);
m_operationMode = NONE;
} else if (m_operationMode == RUBBERSELECTION) {
- //kDebug() << "// END RUBBER SELECT";
resetSelectionGroup();
groupSelectedItems();
m_operationMode = NONE;
items.at(i)->parentItem()->setSelected(true);
}
}
+ resetSelectionGroup();
groupSelectedItems();
} else {
rebuildGroup((AbstractGroupItem *)group);
emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
return;
}
+ m_waitingThumbs.removeAll(item);
if (item->isSelected()) emit clipItemSelected(NULL);
item->baseClip()->removeReference();
m_document->updateClip(item->baseClip()->getId());
delete tr;
}
}*/
- m_waitingThumbs.removeAll(item);
+
if (m_dragItem == item) m_dragItem = NULL;
+
#if QT_VERSION >= 0x040600
// animate item deletion
item->closeAnimation();
void CustomTrackView::doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id)
{
- Q_UNUSED(id);
+ Q_UNUSED(id)
//DocClipBase *baseclip = m_document->clipManager()->getClipById(id);
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
clip->setSelected(true);
}
}
-
groupSelectedItems(false, true);
setDocumentModified();
}
if (clip->clipProducer() == clipId) {
ItemInfo info = clip->info();
info.track = m_document->tracksCount() - clip->track();
- if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer())) {
+ if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer(info.track))) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
}
- clip->refreshClip(true);
- clip->update();
+ clip->refreshClip(true, true);
}
}
}
}
/*
- TODO: cleanup the effect update process
+ * TODO: cleanup the effect update process
*/
ClipItem *clip = static_cast < ClipItem * >(item);
hasParentCommand = true;
} else {
command = new QUndoCommand();
- command->setText(i18n("Resize clip end"));
}
// do this here, too, because otherwise undo won't update the group
ItemInfo info = item->info();
if (item->type() == AVWIDGET) {
+ if (!hasParentCommand) command->setText(i18n("Resize clip end"));
ItemInfo resizeinfo = info;
resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
bool success = m_document->renderer()->mltResizeClipEnd(resizeinfo, resizeinfo.cropDuration);
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
} else if (item->type() == TRANSITIONWIDGET) {
+ if (!hasParentCommand) command->setText(i18n("Resize transition end"));
Transition *transition = static_cast <Transition *>(item);
if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - oldInfo.track), (int)(m_document->tracksCount() - oldInfo.track), transition->transitionEndTrack(), oldInfo.startPos, oldInfo.endPos, info.startPos, info.endPos)) {
// Cannot resize transition
KdenliveSettings::setSnaptopoints(true);
emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
} else {
- MoveTransitionCommand *moveCommand = new MoveTransitionCommand(this, oldInfo, info, false, command);
- if (command == NULL)
- m_commandStack->push(moveCommand);
+ // Check transition keyframes
+ QDomElement old = transition->toXML();
+ if (transition->updateKeyframes()) {
+ QDomElement xml = transition->toXML();
+ m_document->renderer()->mltUpdateTransition(xml.attribute("tag"), xml.attribute("tag"), xml.attribute("transition_btrack").toInt(), m_document->tracksCount() - xml.attribute("transition_atrack").toInt(), transition->startPos(), transition->endPos(), xml);
+ new EditTransitionCommand(this, transition->track(), transition->startPos(), old, xml, false, command);
+ }
+ new MoveTransitionCommand(this, oldInfo, info, false, command);
}
}
if (item->parentItem() && item->parentItem() != m_selectionGroup)
if (dialog) {
MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
if (d.exec() != QDialog::Accepted) return;
- marker.setComment(d.newMarker().comment());
+ marker = d.newMarker();
+
} else {
marker.setComment(m_document->timecode().getDisplayTimecodeFromFrames(m_cursorPos, false));
}
item->slotSetEndThumb(pix);
}
}
- item->refreshClip(false);
+ item->refreshClip(false, false);
}
}
}
if (selection.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast <ClipItem *>(selection.at(i));
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, false, true, deleteTrack);
+ m_waitingThumbs.removeAll(item);
m_scene->removeItem(item);
delete item;
item = NULL;
QDomNodeList children = groups.at(i).childNodes();
scene()->clearSelection();
for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
- QDomNode n = children.item(nodeindex);
- QDomElement elem = n.toElement();
+ QDomElement elem = children.item(nodeindex).toElement();
int pos = elem.attribute("position").toInt();
int track = elem.attribute("track").toInt();
if (elem.tagName() == "clipitem") {
m_document->clipManager()->removeGroup(grp);
m_scene->addItem(grp);
scene()->destroyItemGroup(grp);
+ scene()->clearSelection();
for (int j = 0; j < children.count(); j++) {
if (children.at(j)->type() == AVWIDGET || children.at(j)->type() == TRANSITIONWIDGET) {
//children.at(j)->setParentItem(0);
void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
{
- Q_UNUSED(command);
+ Q_UNUSED(command)
QList<int> tracks;
if (track >= 0) {
}
}
-
+void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
+{
+ QList<QGraphicsItem *> list = scene()->items();
+ ClipItem *clip = NULL;
+ for (int i = 0; i < list.size(); ++i) {
+ if (list.at(i)->type() == AVWIDGET) {
+ clip = static_cast <ClipItem *>(list.at(i));
+ if (clip->clipProducer() == id) {
+ clip->refreshClip(true, resetThumbs);
+ }
+ }
+ }
+}