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);
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
}
}
-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) {
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;
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());
QList<QGraphicsItem *> 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;
}
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++;
}
QList<QGraphicsItem *> 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));
} 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);
}
}
QList<QGraphicsItem *> 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));
if (pos < GenTime()) {
// editing a track effect
EffectsParameterList effectParams = getEffectArgs(effect);
- // Old LADSPA filter, deprecated
- /*if (effect.attribute("tag") == "ladspa") {
- // Update the ladspa affect file
- initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- }*/
// check if we are trying to reset a keyframe effect
/*if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
clip->initEffect(effect);
if (effect.attribute("disable") == "1") {
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
} else {
- double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
+ QLocale locale;
+ double speed = locale.toDouble(EffectsList::parameter(effect, "speed")) / 100.0;
int strobe = EffectsList::parameter(effect, "strobe").toInt();
if (strobe == 0) strobe = 1;
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, clip->speed(), strobe, clip->baseClip()->getId());
}
EffectsParameterList effectParams = getEffectArgs(effect);
- // Old LADSPA filter, deprecated
- /*if (effect.attribute("tag") == "ladspa") {
- // Update the ladspa affect file
- initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- }*/
// check if we are trying to reset a keyframe effect
if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
clip->initEffect(effect);
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);
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;
}
}
+ 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 <AbstractClipItem *>(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);
}
}
-void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> transToMove, int track, const GenTime duration, const GenTime offset)
+void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> transToMove, int track, const GenTime &duration, const GenTime &offset)
{
int diff = duration.frames(m_document->fps());
resetSelectionGroup();
void CustomTrackView::changeClipSpeed()
{
+ // TODO: remove after string freeze
QList<QGraphicsItem *> itemList = scene()->selectedItems();
if (itemList.count() == 0) {
emit displayMessage(i18n("Select clip to change speed"), ErrorMessage);
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);
if (refresh) m_document->renderer()->doRefresh();
}
-void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove)
+void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime &offset, const int trackOffset, bool reverseMove)
{
// Group Items
resetSelectionGroup();
} 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) {
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);
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);
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
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) {
setDocumentModified();
}
-
-QStringList CustomTrackView::getLadspaParams(QDomElement effect) const
-{
- QStringList result;
- QLocale locale;
- 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(locale.toString(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<QGraphicsItem *> list = scene()->items();
ClipItem *clip = NULL;
}
}
-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();
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);
}
-EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
+EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement &effect)
{
EffectsParameterList parameters;
QLocale locale;