]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
make slot names more kdenlive conform
[kdenlive] / src / customtrackview.cpp
index 6d6d548291807daf60ecf690ebcfffa59f5e8d7b..de183f879c83acb42a65431e0f46ad5d0a019762 100644 (file)
@@ -52,6 +52,7 @@
 #include "commands/changeeffectstatecommand.h"
 #include "commands/movegroupcommand.h"
 #include "ui_addtrack_ui.h"
+#include "ui_importkeyframesdialog_ui.h"
 #include "initeffects.h"
 #include "commands/locktrackcommand.h"
 #include "commands/groupclipscommand.h"
@@ -403,6 +404,15 @@ void CustomTrackView::slotCheckPositionScrolling()
     }
 }
 
+void CustomTrackView::slotAlignPlayheadToMousePos()
+{
+       /* get curser point ref in screen coord */
+       QPoint ps = QCursor::pos();
+       /* get xPos in scene coord */
+       int mappedXPos = qMax((int)(mapToScene(mapFromGlobal(ps)).x() + 0.5), 0);
+       /* move playhead to new xPos*/
+       seekCursorPos(mappedXPos);
+}
 
 // virtual
 void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
@@ -5269,15 +5279,31 @@ void CustomTrackView::slotAddClipExtraData(const QString &id, const QString &key
     if (!groupCommand) m_commandStack->push(command);
 }
 
-void CustomTrackView::slotAddClipMarker(const QString &id, CommentedTime newMarker, QUndoCommand *groupCommand)
+void CustomTrackView::slotAddClipMarker(const QString &id, QList <CommentedTime> newMarkers, QUndoCommand *groupCommand)
 {
-    CommentedTime oldMarker = m_document->clipManager()->getClipById(id)->markerAt(newMarker.time());
-    if (oldMarker == CommentedTime()) {
-       oldMarker = newMarker;
-       oldMarker.setMarkerType(-1);
+    QUndoCommand *subCommand = NULL;
+    if (newMarkers.count() > 1 && groupCommand == NULL) {
+       subCommand = new QUndoCommand;
+       subCommand->setText("Add markers");
     }
-    AddMarkerCommand *command = new AddMarkerCommand(this, oldMarker, newMarker, id, groupCommand);
-    if (!groupCommand) m_commandStack->push(command);
+    for (int i = 0; i < newMarkers.count(); i++) {
+       CommentedTime oldMarker = m_document->clipManager()->getClipById(id)->markerAt(newMarkers.at(i).time());
+       if (oldMarker == CommentedTime()) {
+           oldMarker = newMarkers.at(i);
+           oldMarker.setMarkerType(-1);
+       }
+       if (newMarkers.count() == 1 && !groupCommand) {
+           AddMarkerCommand *command = new AddMarkerCommand(this, oldMarker, newMarkers.at(i), id, groupCommand);
+           m_commandStack->push(command);
+       }
+       else if (groupCommand) {
+           (void) new AddMarkerCommand(this, oldMarker, newMarkers.at(i), id, groupCommand);
+       }
+       else {
+           (void) new AddMarkerCommand(this, oldMarker, newMarkers.at(i), id, subCommand);
+       }
+    }
+    if (subCommand) m_commandStack->push(subCommand);
 }
 
 void CustomTrackView::slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position)
@@ -5388,6 +5414,7 @@ void CustomTrackView::slotLoadClipMarkers(const QString &id)
     QUndoCommand *command = new QUndoCommand();
     command->setText("Load markers");
     QString markerText;
+    QList <CommentedTime> markersList;
     foreach(QString line, lines) {
        markerText.clear();
        values = line.split("\t", QString::SkipEmptyParts);
@@ -5418,13 +5445,14 @@ void CustomTrackView::slotLoadClipMarkers(const QString &id)
            // Marker found, add it
            //TODO: allow user to set a marker category
            CommentedTime marker1(GenTime(time1), markerText, category);
-           slotAddClipMarker(id, marker1, command);
+           markersList << marker1;
            if (time2 > 0 && time2 != time1) {
                CommentedTime marker2(GenTime(time2), markerText, category);
-               slotAddClipMarker(id, marker2, command);
+               markersList << marker2;
            }
        }
     }
+    if (!markersList.isEmpty()) slotAddClipMarker(id, markersList, command);
     if (command->childCount() > 0) m_commandStack->push(command);
     else delete command;
 }
@@ -7300,18 +7328,18 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement &effect)
            parameters.addParam(QString("filter%1.tag").arg(subeffectix), subeffect.attribute("tag"));
            parameters.addParam(QString("filter%1.kdenlive_info").arg(subeffectix), subeffect.attribute("kdenlive_info"));
            QDomNodeList subparams = subeffect.elementsByTagName("parameter");
-           adjustEffectParameters(parameters, subparams, QString("filter%1.").arg(subeffectix));
+           adjustEffectParameters(parameters, subparams, m_document->mltProfile(), QString("filter%1.").arg(subeffectix));
        }
     }
 
     QDomNodeList params = effect.elementsByTagName("parameter");
-    adjustEffectParameters(parameters, params);
+    adjustEffectParameters(parameters, params, m_document->mltProfile());
     
     return parameters;
 }
 
 
-void CustomTrackView::adjustEffectParameters(EffectsParameterList &parameters, QDomNodeList params, const QString &prefix)
+void CustomTrackView::adjustEffectParameters(EffectsParameterList &parameters, QDomNodeList params, MltVideoProfile profile, const QString &prefix)
 {
   QLocale locale;
   for (int i = 0; i < params.count(); i++) {
@@ -7362,7 +7390,7 @@ void CustomTrackView::adjustEffectParameters(EffectsParameterList &parameters, Q
             if (e.attribute("factor", "1") != "1" || e.attribute("offset", "0") != "0") {
                 double fact;
                 if (e.attribute("factor").contains('%')) {
-                    fact = ProfilesDialog::getStringEval(m_document->mltProfile(), e.attribute("factor"));
+                    fact = ProfilesDialog::getStringEval(profile, e.attribute("factor"));
                 } else {
                     fact = e.attribute("factor", "1").toDouble();
                 }
@@ -7472,7 +7500,7 @@ void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoComma
 }
 
 
-void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPos, int track, const QString &filter, stringMap filterParams)
+void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPos, int track, const QString &filter, stringMap filterParams, QStringList extra)
 {
     ClipItem *clip = getClipItemAt(GenTime(startPos, m_document->fps()), track);
     if (clip == NULL) {
@@ -7496,3 +7524,73 @@ void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPo
 }
 
 
+void CustomTrackView::slotImportClipKeyframes(GRAPHICSRECTITEM type)
+{
+    if (!m_selectionGroup) {
+       emit displayMessage(i18n("You need to select one clip and one transition"), ErrorMessage);
+       return;
+    }
+    // Make sure there is no collision
+    QList<QGraphicsItem *> children = m_selectionGroup->childItems();
+    ClipItem *item = NULL;
+    for (int i = 0; i < children.count(); i++) {
+       if (children.at(i)->type() == AVWIDGET) {
+            item = (ClipItem*) children.at(i);
+            break;
+        }
+    }
+    if (!item) {
+       emit displayMessage(i18n("No clip found"), ErrorMessage);
+       return;
+    }
+    QMap <QString, QString> data = item->baseClip()->analysisData();
+    if (data.isEmpty()) {
+       emit displayMessage(i18n("No keyframe data found in clip"), ErrorMessage);
+       return;
+    }
+    QPointer<QDialog> d = new QDialog(this);
+    Ui::ImportKeyframesDialog_UI ui;
+    ui.setupUi(d);
+
+    // Set  up data
+    int ix = 0;
+    QMap<QString, QString>::const_iterator i = data.constBegin();
+    while (i != data.constEnd()) {
+       ui.data_list->insertItem(ix, i.key());
+       ui.data_list->setItemData(ix, i.value(), Qt::UserRole);
+       ++i;
+       ix++;
+    }
+
+    if (d->exec() != QDialog::Accepted) {
+       delete d;
+       return;
+    }
+    QString keyframeData = ui.data_list->itemData(ui.data_list->currentIndex()).toString();
+    QStringList keyframeList = keyframeData.split(';', QString::SkipEmptyParts);
+    QString result;
+    if (ui.import_position->isChecked()) {
+       if (ui.import_size->isChecked()) {
+           foreach(QString key, keyframeList) {
+               if (key.count(':') > 1) result.append(key.section(':', 0, 1));
+               else result.append(key);
+               result.append(';');
+           }
+       }
+       else {
+           foreach(QString key, keyframeList) {
+               result.append(key.section(':', 0, 0));
+               result.append(';');
+           }
+       }
+    }
+    else if (ui.import_size->isChecked()) {
+       foreach(QString key, keyframeList) {
+           result.append(key.section(':', 1, 1));
+           result.append(';');
+       }
+    }
+    emit importKeyframes(type, result);
+    delete d;
+}
+