#include <KUrl>
#include <KIcon>
#include <KCursor>
+#include <KColorScheme>
#include <QMouseEvent>
#include <QStylePainter>
break;
}
}
+
+ m_timelineContextMenu->addSeparator();
+ m_deleteGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
+ connect(m_deleteGuide, SIGNAL(triggered()), this, SLOT(slotDeleteTimeLineGuide()));
+ m_timelineContextMenu->addAction(m_deleteGuide);
+
+ m_editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
+ connect(m_editGuide, SIGNAL(triggered()), this, SLOT(slotEditTimeLineGuide()));
+ m_timelineContextMenu->addAction(m_editGuide);
}
void CustomTrackView::checkAutoScroll()
{
// If mouse is at a border of the view, scroll
if (m_moveOpMode != SEEK) return;
- int pos = cursorPos();
- if (mapFromScene(pos, 0).x() < 7) {
+ if (mapFromScene(m_cursorPos, 0).x() < 3) {
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 2);
- setCursorPos(mapToScene(QPoint()).x() - 1);
QTimer::singleShot(200, this, SLOT(slotCheckPositionScrolling()));
-
- } else if (viewport()->width() - 5 < mapFromScene(pos + 1, 0).x()) {
+ setCursorPos(mapToScene(QPoint(-2, 0)).x());
+ } else if (viewport()->width() - 3 < mapFromScene(m_cursorPos + 1, 0).x()) {
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 2);
- setCursorPos(mapToScene(viewport()->width(), 0).x() + 1);
+ setCursorPos(mapToScene(QPoint(viewport()->width(), 0)).x() + 1);
QTimer::singleShot(200, this, SLOT(slotCheckPositionScrolling()));
}
}
m_moveOpMode = opMode;
setCursor(Qt::SplitHCursor);
} else {
- if (event->buttons() != Qt::NoButton && event->modifiers() == Qt::NoModifier) {
- m_moveOpMode = SEEK;
- setCursorPos(mappedXPos);
- slotCheckPositionScrolling();
- } else m_moveOpMode = NONE;
if (m_visualTip) {
delete m_animation;
m_animationTimer->stop();
}
setCursor(Qt::ArrowCursor);
+ if (event->buttons() != Qt::NoButton && event->modifiers() == Qt::NoModifier) {
+ QGraphicsView::mouseMoveEvent(event);
+ m_moveOpMode = SEEK;
+ setCursorPos(mappedXPos);
+ slotCheckPositionScrolling();
+ return;
+ } else m_moveOpMode = NONE;
}
QGraphicsView::mouseMoveEvent(event);
}
}
// check item under mouse
- QList<QGraphicsItem *> collisionList = items(event->pos());
+ QList<QGraphicsItem *> collisionList = items(m_clickEvent);
if (event->modifiers() == Qt::ControlModifier && m_tool != SPACERTOOL && collisionList.count() == 0) {
setDragMode(QGraphicsView::ScrollHandDrag);
return;
}
- if (collisionList.count() == 1 && collisionList.at(0)->type() == GUIDEITEM) {
+ if (event->button() == Qt::LeftButton && collisionList.count() == 1 && collisionList.at(0)->type() == GUIDEITEM) {
// a guide item was pressed
collisionList.at(0)->setFlag(QGraphicsItem::ItemIsMovable, true);
m_dragItem = NULL;
// context menu requested
if (event->button() == Qt::RightButton) {
+ m_dragGuide = NULL;
if (m_dragItem) {
if (dragGroup) dragGroup->setSelected(true);
else if (!m_dragItem->isSelected()) {
m_dragItem->setSelected(true);
}
}
+
+ // check if there is a guide close to mouse click
+ QList<QGraphicsItem *> guidesCollisionList = items(event->pos().x() - 5, event->pos().y(), 10, 1);
+ for (int i = 0; i < guidesCollisionList.count(); i++) {
+ if (guidesCollisionList.at(0)->type() != GUIDEITEM)
+ guidesCollisionList.removeAt(0);
+ }
+ if (!guidesCollisionList.isEmpty())
+ m_dragGuide = static_cast <Guide *>(guidesCollisionList.at(0));
m_operationMode = NONE;
displayContextMenu(event->globalPos(), m_dragItem, dragGroup);
m_menuPosition = m_clickEvent;
void CustomTrackView::displayContextMenu(QPoint pos, AbstractClipItem *clip, AbstractGroupItem *group)
{
+ m_deleteGuide->setEnabled(m_dragGuide != NULL);
+ m_editGuide->setEnabled(m_dragGuide != NULL);
if (clip == NULL) m_timelineContextMenu->popup(pos);
else if (group != NULL) {
m_changeSpeedAction->setEnabled(false);
int pos = effectParams.paramValue("out").toInt() - effectParams.paramValue("in").toInt();
clip->setFadeOut(pos);
}
-
}
}
m_document->setModified(true);
else newPos.cropStart = item->info().cropStart + (cutTime - info.startPos) * speed;
newPos.track = info.track;
ClipItem *dup = item->clone(newPos);
+ // remove unwanted effects (fade in) from 2nd part of cutted clip
+ int ix = dup->hasEffect(QString(), "fadein");
+ if (ix != -1) {
+ QDomElement oldeffect = item->effectAt(ix);
+ dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+ }
+ ix = dup->hasEffect(QString(), "fade_from_black");
+ if (ix != -1) {
+ QDomElement oldeffect = item->effectAt(ix);
+ dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+ }
item->resizeEnd(cutPos, false);
scene()->addItem(dup);
if (item->checkKeyFrames()) slotRefreshEffects(item);
const QPointF pos = mapToScene(event->pos());
if (m_selectionGroup && m_clipDrag) {
m_selectionGroup->setPos(pos.x(), pos.y());
+ emit mousePosition((int)(m_selectionGroup->scenePos().x() + 0.5));
event->setDropAction(Qt::MoveAction);
event->acceptProposedAction();
} else {
void CustomTrackView::addTrack(TrackInfo type, int ix)
{
- if (ix == -1) m_document->insertTrack(ix, type);
- else {
+ if (ix == -1 || ix == m_document->tracksCount()) {
+ m_document->insertTrack(ix, type);
+ m_document->renderer()->mltInsertTrack(1, type.type == VIDEOTRACK);
+ } else {
m_document->insertTrack(m_document->tracksCount() - ix, type);
// insert track in MLT playlist
m_document->renderer()->mltInsertTrack(m_document->tracksCount() - ix, type.type == VIDEOTRACK);
{
/*for (int i = 0; i < m_document->tracksCount(); i++)
kDebug() << "TRK " << i << " STATE: " << m_document->trackInfoAt(i).isMute << m_document->trackInfoAt(i).isBlind;*/
- int tracknumber = m_document->tracksCount() - ix;
- m_document->switchTrackAudio(tracknumber - 1, !m_document->trackInfoAt(tracknumber - 1).isMute);
- kDebug() << "NEXT TRK STATE: " << m_document->trackInfoAt(tracknumber - 1).isMute << m_document->trackInfoAt(tracknumber - 1).isBlind;
- m_document->renderer()->mltChangeTrackState(tracknumber, m_document->trackInfoAt(tracknumber - 1).isMute, m_document->trackInfoAt(tracknumber - 1).isBlind);
+ int tracknumber = m_document->tracksCount() - ix - 1;
+ m_document->switchTrackAudio(tracknumber, !m_document->trackInfoAt(tracknumber).isMute);
+ kDebug() << "NEXT TRK STATE: " << m_document->trackInfoAt(tracknumber).isMute << m_document->trackInfoAt(tracknumber).isBlind;
+ m_document->renderer()->mltChangeTrackState(tracknumber + 1, m_document->trackInfoAt(tracknumber).isMute, m_document->trackInfoAt(tracknumber).isBlind);
m_document->setModified(true);
}
int tracknumber = m_document->tracksCount() - ix - 1;
m_document->switchTrackLock(tracknumber, lock);
emit doTrackLock(ix, lock);
- QList<QGraphicsItem *> selection = items(0, ix * m_tracksHeight + m_tracksHeight / 2, mapFromScene(sceneRect().width(), 0).x(), m_tracksHeight / 2 - 2);
+ QList<QGraphicsItem *> selection = m_scene->items(0, ix * m_tracksHeight + m_tracksHeight / 2, sceneRect().width(), m_tracksHeight / 2 - 2);
for (int i = 0; i < selection.count(); i++) {
if (selection.at(i)->type() != AVWIDGET && selection.at(i)->type() != TRANSITIONWIDGET) continue;
void CustomTrackView::setCursorPos(int pos, bool seek)
{
+ if (pos == m_cursorPos) return;
emit cursorMoved((int)(m_cursorPos), (int)(pos));
m_cursorPos = pos;
- m_cursorLine->setPos(pos, 0);
- if (seek) m_document->renderer()->seek(GenTime(pos, m_document->fps()));
+ if (seek) m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
else if (m_autoScroll) checkScrolling();
+ m_cursorLine->setPos(m_cursorPos, 0);
}
void CustomTrackView::updateCursorPos()
void CustomTrackView::checkScrolling()
{
- int vert = verticalScrollBar()->value();
- int hor = cursorPos();
- ensureVisible(hor, vert + 10, 2, 2, 50, 0);
+ ensureVisible(m_cursorPos, verticalScrollBar()->value() + 10, 2, 2, 50, 0);
}
void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
setCursor(Qt::ArrowCursor);
m_operationMode = NONE;
m_dragGuide->setFlag(QGraphicsItem::ItemIsMovable, false);
- EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(m_dragGuide->pos().x(), m_document->fps()), m_dragGuide->label(), false);
- m_commandStack->push(command);
- m_dragGuide->updateGuide(GenTime(m_dragGuide->pos().x(), m_document->fps()));
+ GenTime newPos = GenTime(m_dragGuide->pos().x(), m_document->fps());
+ if (newPos != m_dragGuide->position()) {
+ EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), newPos, m_dragGuide->label(), false);
+ m_commandStack->push(command);
+ m_dragGuide->updateGuide(GenTime(m_dragGuide->pos().x(), m_document->fps()));
+ }
m_dragGuide = NULL;
m_dragItem = NULL;
return;
void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove)
{
// Group Items
- kDebug() << "//GRP MOVE, REVERS:" << reverseMove;
- kDebug() << "// GROUP MOV; OFFSET: " << offset.frames(25) << ", TK OFF: " << trackOffset;
+ /*kDebug() << "//GRP MOVE, REVERS:" << reverseMove;
+ kDebug() << "// GROUP MOV; OFFSET: " << offset.frames(25) << ", TK OFF: " << trackOffset;*/
resetSelectionGroup();
m_scene->clearSelection();
- QList<QGraphicsItem *> itemList = items();
- for (int i = 0; i < itemList.count(); i++) {
- if (itemList.at(i)->type() == AVWIDGET)
- kDebug() << "ITEM " << i << ": " << static_cast <AbstractClipItem *>(itemList.at(i))->startPos().frames(25) << ",REEL: " << itemList.at(i)->scenePos();
- }
for (int i = 0; i < startClip.count(); i++) {
if (reverseMove) {
}
KdenliveSettings::setSnaptopoints(snap);
} else kDebug() << "///////// WARNING; NO GROUP TO MOVE";
-
- kDebug() << "///////// DONE+++++++++++++";
- itemList = items();
- for (int i = 0; i < itemList.count(); i++) {
- if (itemList.at(i)->type() == AVWIDGET)
- kDebug() << "ITEM " << i << ": " << static_cast <AbstractClipItem *>(itemList.at(i))->startPos().frames(25) << ",REEL: " << itemList.at(i)->scenePos();
- }
}
void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end)
return (*g1).position() < (*g2).position();
}
+int CustomTrackView::hasGuide(int pos, int offset)
+{
+ for (int i = 0; i < m_guides.count(); i++) {
+ int guidePos = m_guides.at(i)->position().frames(m_document->fps());
+ if (qAbs(guidePos - pos) < offset) return guidePos;
+ else if (guidePos > pos) return -1;
+ }
+ return -1;
+}
+
void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const QString &comment)
{
if (oldPos > GenTime() && pos > GenTime()) {
}
}
-void CustomTrackView::slotEditGuide()
+void CustomTrackView::slotEditGuide(int guidePos)
{
- GenTime pos = GenTime(m_cursorPos, m_document->fps());
+ GenTime pos;
+ if (guidePos == -1) pos = GenTime(m_cursorPos, m_document->fps());
+ else pos = GenTime(guidePos, m_document->fps());
bool found = false;
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == pos) {
}
-void CustomTrackView::slotDeleteGuide()
+void CustomTrackView::slotEditTimeLineGuide()
{
- GenTime pos = GenTime(m_cursorPos, m_document->fps());
+ 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);
+ m_commandStack->push(command);
+ }
+}
+
+void CustomTrackView::slotDeleteGuide(int guidePos)
+{
+ GenTime pos;
+ if (guidePos == -1) pos = GenTime(m_cursorPos, m_document->fps());
+ else pos = GenTime(guidePos, m_document->fps());
bool found = false;
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == pos) {
if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
}
+
+void CustomTrackView::slotDeleteTimeLineGuide()
+{
+ if (m_dragGuide == NULL) return;
+ EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(), QString(), true);
+ m_commandStack->push(command);
+}
+
+
void CustomTrackView::slotDeleteAllGuides()
{
QUndoCommand *deleteAll = new QUndoCommand();
void CustomTrackView::drawBackground(QPainter * painter, const QRectF & rect)
{
- QColor base = palette().button().color();
QRectF r = rect;
r.setWidth(r.width() + 1);
painter->setClipRect(r);
painter->drawLine(r.left(), 0, r.right(), 0);
uint max = m_document->tracksCount();
+ KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window);
+ QColor lockedColor = scheme.background(KColorScheme::NegativeBackground).color();
+ QColor audioColor = palette().alternateBase().color();
+ QColor base = scheme.background(KColorScheme::NormalBackground).color();
for (uint i = 0; i < max;i++) {
- if (m_document->trackInfoAt(max - i - 1).isLocked == true) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(QColor(250, 250, 100)));
- else if (m_document->trackInfoAt(max - i - 1).type == AUDIOTRACK) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(QColor(240, 240, 255)));
+ if (m_document->trackInfoAt(max - i - 1).isLocked == true) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(lockedColor));
+ else if (m_document->trackInfoAt(max - i - 1).type == AUDIOTRACK) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(audioColor));
painter->drawLine(r.left(), m_tracksHeight * (i + 1), r.right(), m_tracksHeight * (i + 1));
}
int lowerLimit = m_tracksHeight * m_document->tracksCount() + 1;