]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
* Vectorscope added
[kdenlive] / src / customtrackview.cpp
index d16ea7fdb3e2ba73f38c3bb6b0f161d80ed061c6..17c3f0f45eccf348ebae08c7f971398ac9536832 100644 (file)
@@ -425,9 +425,8 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
             for (int i = 0; i < children.count(); i++) {
                 if (children.at(i)->type() == GROUPWIDGET) {
                     QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
-                    for (int j = 0; j < subchildren.count(); j++) {
+                    for (int j = 0; j < subchildren.count(); j++)
                         collidingItems.removeAll(subchildren.at(j));
-                    }
                 }
                 collidingItems.removeAll(children.at(i));
             }
@@ -452,9 +451,8 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
             for (int i = 0; i < children.count(); i++) {
                 if (children.at(i)->type() == GROUPWIDGET) {
                     QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
-                    for (int j = 0; j < subchildren.count(); j++) {
+                    for (int j = 0; j < subchildren.count(); j++)
                         collidingItems.removeAll(subchildren.at(j));
-                    }
                 }
                 collidingItems.removeAll(children.at(i));
             }
@@ -476,9 +474,8 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                 for (int i = 0; i < children.count(); i++) {
                     if (children.at(i)->type() == GROUPWIDGET) {
                         QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
-                        for (int j = 0; j < subchildren.count(); j++) {
+                        for (int j = 0; j < subchildren.count(); j++)
                             collidingItems.removeAll(subchildren.at(j));
-                        }
                     }
                     collidingItems.removeAll(children.at(i));
                 }
@@ -503,9 +500,8 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                 for (int i = 0; i < children.count(); i++) {
                     if (children.at(i)->type() == GROUPWIDGET) {
                         QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
-                        for (int j = 0; j < subchildren.count(); j++) {
+                        for (int j = 0; j < subchildren.count(); j++)
                             collidingItems.removeAll(subchildren.at(j));
-                        }
                     }
                     collidingItems.removeAll(children.at(i));
                 }
@@ -572,8 +568,16 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
             setCursor(KCursor("left_side", Qt::SizeHorCursor));
         else if (opMode == RESIZEEND)
             setCursor(KCursor("right_side", Qt::SizeHorCursor));
-        else if (opMode == FADEIN || opMode == FADEOUT || opMode == TRANSITIONSTART || opMode == TRANSITIONEND || opMode == KEYFRAME)
+        else if (opMode == FADEIN || opMode == FADEOUT) {
             setCursor(Qt::PointingHandCursor);
+            emit displayMessage(i18n("Drag to add or resize a fade effect."), InformationMessage);
+        } else if (opMode == TRANSITIONSTART || opMode == TRANSITIONEND) {
+            setCursor(Qt::PointingHandCursor);
+            emit displayMessage(i18n("Click to add a transition."), InformationMessage);
+        } 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);
+        }
     } // no clip under mouse
     else if (m_tool == RAZORTOOL) {
         event->accept();
@@ -696,7 +700,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
     }
 #if QT_VERSION >= 0x040600
     // Add shadow to dragged item, currently disabled because of painting artifacts
-    //TODO: re-enable when fixed
+    //TODO: re-enable when fixed
     /*QGraphicsDropShadowEffect *eff = new QGraphicsDropShadowEffect();
     eff->setBlurRadius(5);
     eff->setOffset(3, 3);
@@ -1119,7 +1123,7 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event)
     if (m_dragItem && m_dragItem->hasKeyFrames()) {
         /*if (m_moveOpMode == KEYFRAME) {
             // user double clicked on a keyframe, open edit dialog
-            //TODO: update for effects with several values per keyframe
+            //TODO: update for effects with several values per keyframe
             QDialog d(parentWidget());
             Ui::KeyFrameDialog_UI view;
             view.setupUi(&d);
@@ -1176,11 +1180,10 @@ void CustomTrackView::editItemDuration()
         if (m_scene->selectedItems().count() == 1) {
             item = static_cast <AbstractClipItem *>(m_scene->selectedItems().at(0));
         } else {
-            if (m_scene->selectedItems().empty()) {
+            if (m_scene->selectedItems().empty())
                 emit displayMessage(i18n("Cannot find clip to edit"), ErrorMessage);
-            } else {
+            else
                 emit displayMessage(i18n("Cannot edit the duration of multiple items"), ErrorMessage);
-            }
             return;
         }
     }
@@ -1205,39 +1208,34 @@ void CustomTrackView::editItemDuration()
         //kDebug()<<"// GOT MOVE POS: "<<minimum.frames(25)<<" - "<<maximum.frames(25);
         ClipDurationDialog d(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
-                ItemInfo startInfo;
-                startInfo.startPos = item->startPos();
-                startInfo.endPos = item->endPos();
-                startInfo.track = item->track();
-                ItemInfo endInfo;
-                endInfo.startPos = d.startPos();
-                endInfo.endPos = endInfo.startPos + d.duration();
-                endInfo.track = item->track();
-                MoveTransitionCommand *command = new MoveTransitionCommand(this, startInfo, endInfo, true);
+                clipInfo.startPos = d.startPos();
+                clipInfo.endPos = clipInfo.startPos + d.duration();
+                clipInfo.track = item->track();
+                MoveTransitionCommand *command = new MoveTransitionCommand(this, startInfo, clipInfo, true);
                 m_commandStack->push(command);
             } else {
                 // move and resize clip
                 QUndoCommand *moveCommand = new QUndoCommand();
                 moveCommand->setText(i18n("Edit clip"));
-                ItemInfo clipInfo = item->info();
                 if (d.duration() < item->cropDuration() || d.cropStart() != clipInfo.cropStart) {
                     // duration was reduced, so process it first
-                    ItemInfo startInfo = clipInfo;
                     clipInfo.endPos = clipInfo.startPos + d.duration();
                     clipInfo.cropStart = d.cropStart();
                     new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
                 }
                 if (d.startPos() != clipInfo.startPos) {
-                    ItemInfo startInfo = clipInfo;
+                    startInfo = clipInfo;
                     clipInfo.startPos = d.startPos();
                     clipInfo.endPos = item->endPos() + (clipInfo.startPos - startInfo.startPos);
                     new MoveClipCommand(this, startInfo, clipInfo, true, moveCommand);
                 }
                 if (d.duration() > item->cropDuration()) {
                     // duration was increased, so process it after move
-                    ItemInfo startInfo = clipInfo;
+                    startInfo = clipInfo;
                     clipInfo.endPos = clipInfo.startPos + d.duration();
                     clipInfo.cropStart = d.cropStart();
                     new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
@@ -2134,7 +2132,9 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             if (isLocked) item->setItemLocked(true);
             ItemInfo clipInfo = info;
             clipInfo.track = m_document->tracksCount() - item->track();
-            if (m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT) == -1) {
+
+            int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
+            if (worked == -1) {
                 emit displayMessage(i18n("Cannot insert clip in timeline"), ErrorMessage);
                 brokenClips.append(item);
                 continue;
@@ -2161,7 +2161,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
         setDocumentModified();
 
         /*
-        // debug info
+        // debug info
         QRectF rect(0, 1 * m_tracksHeight + m_tracksHeight / 2, sceneRect().width(), 2);
         QList<QGraphicsItem *> selection = m_scene->items(rect);
         QStringList timelineList;
@@ -3276,11 +3276,14 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
         val = (br.bottom() - val) * maxh;
         int start = item->cropStart().frames(m_document->fps());
         int end = (item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1;
+
         if ((val < -50 || val > 150) && item->editedKeyFramePos() != start && item->editedKeyFramePos() != end) {
             //delete keyframe
-            kDebug() << "// DELETE KFR: " << item->editedKeyFramePos();
             item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0);
-        } else item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue());
+        } else {
+            item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue());
+        }
+
         QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
         //item->updateKeyframeEffect();
         //QString next = item->keyframes(item->selectedEffectIndex());
@@ -4294,10 +4297,10 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
         QDomElement oldeffect = item->effectAt(effectPos);
         int start = item->cropStart().frames(m_document->fps());
         int max = start + item->cropDuration().frames(m_document->fps());
-       if (start < 0) {
-           max -= start;
-           start = 0;
-       }
+        if (start < 0) {
+            max -= start;
+            start = 0;
+        }
         oldeffect.setAttribute("in", start);
         oldeffect.setAttribute("out", max);
         if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), item->getEffectArgs(oldeffect)))
@@ -4636,8 +4639,10 @@ void CustomTrackView::setScale(double scaleFactor, double verticalScale)
 
     int diff = sceneRect().width() - m_projectDuration;
     if (diff * newmatrix.m11() < 50) {
-        if (newmatrix.m11() < 0.4) setSceneRect(0, 0, (m_projectDuration + 100 / newmatrix.m11()), sceneRect().height());
-        else setSceneRect(0, 0, (m_projectDuration + 300), sceneRect().height());
+        if (newmatrix.m11() < 0.4)
+            setSceneRect(0, 0, (m_projectDuration + 100 / newmatrix.m11()), sceneRect().height());
+        else
+            setSceneRect(0, 0, (m_projectDuration + 300), sceneRect().height());
     }
     centerOn(QPointF(cursorPos(), verticalPos));
 }
@@ -4645,9 +4650,8 @@ void CustomTrackView::setScale(double scaleFactor, double verticalScale)
 void CustomTrackView::slotRefreshGuides()
 {
     if (KdenliveSettings::showmarkers()) {
-        for (int i = 0; i < m_guides.count(); i++) {
+        for (int i = 0; i < m_guides.count(); i++)
             m_guides.at(i)->update();
-        }
     }
 }
 
@@ -4670,8 +4674,10 @@ void CustomTrackView::drawBackground(QPainter * painter, const QRectF &rect)
         TrackInfo info = m_document->trackInfoAt(maxTrack - i - 1);
         if (info.isLocked || info.type == AUDIOTRACK || i == m_selectedTrack) {
             const QRectF track(min, m_tracksHeight * i + 1, max - min, m_tracksHeight - 1);
-            if (i == m_selectedTrack) painter->fillRect(track, scheme.background(KColorScheme::ActiveBackground).color());
-            else painter->fillRect(track, info.isLocked ? lockedColor : audioColor);
+            if (i == m_selectedTrack)
+                painter->fillRect(track, scheme.background(KColorScheme::ActiveBackground).color());
+            else
+                painter->fillRect(track, info.isLocked ? lockedColor : audioColor);
         }
         painter->drawLine(QPointF(min, m_tracksHeight *(i + 1)), QPointF(max, m_tracksHeight *(i + 1)));
     }
@@ -4745,9 +4751,8 @@ void CustomTrackView::initSearchStrings()
     }
 
     // add guides
-    for (int i = 0; i < m_guides.count(); i++) {
+    for (int i = 0; i < m_guides.count(); i++)
         m_searchPoints.append(m_guides.at(i)->info());
-    }
 
     qSort(m_searchPoints);
 }
@@ -4765,9 +4770,8 @@ QList<ItemInfo> CustomTrackView::findId(const QString &clipId)
     for (int i = 0; i < itemList.count(); i++) {
         if (itemList.at(i)->type() == AVWIDGET) {
             ClipItem *item = (ClipItem *)itemList.at(i);
-            if (item->clipProducer() == clipId) {
+            if (item->clipProducer() == clipId)
                 matchingInfo << item->info();
-            }
         }
     }
     return matchingInfo;
@@ -5174,28 +5178,23 @@ void CustomTrackView::saveThumbnails()
 void CustomTrackView::slotInsertTrack(int ix)
 {
     TrackDialog d(m_document, parentWidget());
+    d.comboTracks->setCurrentIndex(ix);
     d.label->setText(i18n("Insert track"));
-    d.track_nb->setMaximum(m_document->tracksCount() - 1);
-    d.track_nb->setValue(ix);
     d.setWindowTitle(i18n("Insert New Track"));
-    d.slotUpdateName(ix);
 
     if (d.exec() == QDialog::Accepted) {
-        ix = d.track_nb->value();
-        if (d.before_select->currentIndex() == 1) {
+        ix = d.comboTracks->currentIndex();
+        if (d.before_select->currentIndex() == 1)
             ix++;
-        }
         TrackInfo info;
+        info.isMute = false;
+        info.isLocked = false;
         if (d.video_track->isChecked()) {
             info.type = VIDEOTRACK;
-            info.isMute = false;
             info.isBlind = false;
-            info.isLocked = false;
         } else {
             info.type = AUDIOTRACK;
-            info.isMute = false;
             info.isBlind = true;
-            info.isLocked = false;
         }
         AddTrackCommand *addTrack = new AddTrackCommand(this, ix, info, true);
         m_commandStack->push(addTrack);
@@ -5207,16 +5206,14 @@ 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.track_nb->setMaximum(m_document->tracksCount() - 1);
-    d.track_nb->setValue(ix);
-    d.slotUpdateName(ix);
     d.setWindowTitle(i18n("Delete Track"));
     d.video_track->setHidden(true);
     d.audio_track->setHidden(true);
     if (d.exec() == QDialog::Accepted) {
-        ix = d.track_nb->value();
+        ix = d.comboTracks->currentIndex();
         TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - ix - 1);
         deleteTimelineTrack(ix, info);
         setDocumentModified();