]> git.sesse.net Git - kdenlive/commitdiff
* Fix undo of effect editing
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 14 Nov 2008 00:10:58 +0000 (00:10 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 14 Nov 2008 00:10:58 +0000 (00:10 +0000)
* Add widget to adjust position parameter in effects (fade, freeze)

svn path=/branches/KDE4/; revision=2703

14 files changed:
src/CMakeLists.txt
src/customtrackview.cpp
src/customtrackview.h
src/editeffectcommand.cpp
src/effectslist.cpp
src/effectslist.h
src/effectstackedit.cpp
src/effectstackedit.h
src/effectstackview.cpp
src/effectstackview.h
src/mainwindow.cpp
src/transitionsettings.cpp
src/transitionsettings.h
src/widgets/positionval_ui.ui [new file with mode: 0644]

index e9dc2a26be9d2f0fb28ae6997af9e9b7db81dcb9..67de7cd3012e10907546d1515d5919e76ef532ec 100644 (file)
@@ -43,6 +43,7 @@ kde4_add_ui_files(kdenlive_UI
   widgets/wipeval_ui.ui
   widgets/boolval_ui.ui
   widgets/colorval_ui.ui
+  widgets/positionval_ui.ui
   widgets/titlewidget_ui.ui
   widgets/timelinebuttons_ui.ui
   widgets/renderwidget_ui.ui
index 2d5cbe88c7fc0c5ee280d949b7ea67979f8e970e..6eb6a570042e9a33b918702381de7445e521a4fa 100644 (file)
@@ -921,7 +921,7 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, QDomElement effect) {
     m_document->setModified(true);
 }
 
-void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement effect, int ix) {
+void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement effect, int ix, bool triggeredByUser) {
     ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()) + 1, m_scene->m_tracksList.count() - track);
     if (clip) {
         QHash <QString, QString> effectParams = clip->getEffectArgs(effect);
@@ -937,8 +937,11 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement effect, i
             } else emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
         } else if (!m_document->renderer()->mltEditEffect(m_scene->m_tracksList.count() - clip->track(), clip->startPos(), effectParams))
             emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+
+        clip->setEffectAt(ix, effect);
         if (ix == clip->selectedEffectIndex()) {
             clip->setSelectedEffect(ix);
+            if (!triggeredByUser) emit clipItemSelected(clip, ix);
         }
         if (effect.attribute("tag") == "volume") {
             // A fade effect was modified, update the clip
@@ -1468,9 +1471,10 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
             } else {
                 end += start;
                 QDomElement effect = oldeffect.cloneNode().toElement();
-                EffectsList::setParameter(effect, "in", QString::number(start));
-                EffectsList::setParameter(effect, "out", QString::number(end));
-                slotUpdateClipEffect(item, oldeffect, effect, ix);
+                EffectsList::setParameter(oldeffect, "in", QString::number(start));
+                EffectsList::setParameter(oldeffect, "out", QString::number(end));
+                slotUpdateClipEffect(item, effect, oldeffect, ix);
+                emit clipItemSelected(item, ix);
             }
         } else if (item->fadeIn() != 0) {
             QDomElement effect = MainWindow::audioEffects.getEffectByTag("volume", "fadein").cloneNode().toElement();
@@ -1490,9 +1494,10 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
             } else {
                 start = end - start;
                 QDomElement effect = oldeffect.cloneNode().toElement();
-                EffectsList::setParameter(effect, "in", QString::number(start));
-                EffectsList::setParameter(effect, "out", QString::number(end));
-                slotUpdateClipEffect(item, oldeffect, effect, ix);
+                EffectsList::setParameter(oldeffect, "in", QString::number(start));
+                EffectsList::setParameter(oldeffect, "out", QString::number(end));
+                slotUpdateClipEffect(item, effect, oldeffect, ix);
+                emit clipItemSelected(item, ix);
             }
         } else if (item->fadeOut() != 0) {
             QDomElement effect = MainWindow::audioEffects.getEffectByTag("volume", "fadeout").cloneNode().toElement();
index 88229d62abfc39a6753796a9479441e63a8fb104..e1b901203e81f8c4ff4a3992202f4469de4f6fb4 100644 (file)
@@ -68,7 +68,7 @@ public:
     void slotAddEffect(QDomElement effect, GenTime pos, int track);
     void addEffect(int track, GenTime pos, QDomElement effect);
     void deleteEffect(int track, GenTime pos, QDomElement effect);
-    void updateEffect(int track, GenTime pos, QDomElement effect, int ix);
+    void updateEffect(int track, GenTime pos, QDomElement effect, int ix, bool triggeredByUser = true);
     void moveEffect(int track, GenTime pos, int oldPos, int newPos);
     void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params);
     void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params);
index 84a5d2269cfefe8856d5642ecc95afeef9cd90c0..903e8f45d74d51af443bf6b6ec74a3c7e86b156c 100644 (file)
@@ -49,12 +49,13 @@ bool EditEffectCommand::mergeWith(const QUndoCommand * other) {
 // virtual
 void EditEffectCommand::undo() {
     kDebug() << "----  undoing action";
-    m_view->updateEffect(m_track, m_pos, m_oldeffect, m_stackPos);
+    m_view->updateEffect(m_track, m_pos, m_oldeffect, m_stackPos, false);
 }
 // virtual
 void EditEffectCommand::redo() {
     kDebug() << "----  redoing action";
-    m_view->updateEffect(m_track, m_pos, m_effect, m_stackPos);
+    m_view->updateEffect(m_track, m_pos, m_effect, m_stackPos, m_doIt);
+    m_doIt = false;
 }
 
 
index b0ba57c76f18fd7712fd79574e0aa312f7613434..ade194e1e61f435976996b6224b796d266981ff1 100644 (file)
@@ -28,24 +28,6 @@ EffectsList::EffectsList():
 EffectsList::~EffectsList() {
 }
 
-QMap <QString, QString> EffectsList::effect(const QString & name) {
-    QMap <QString, QString> filter;
-    QString effectName;
-    QDomElement effect;
-    for (int i = 0; i < this->size(); ++i) {
-        effect =  this->at(i);
-        QDomNode namenode = effect.elementsByTagName("name").item(0);
-        if (!namenode.isNull()) {
-            effectName = i18n(namenode.toElement().text().toUtf8().data());
-            if (name == effectName) break;
-        }
-    }
-    filter.insert("mlt_service", effect.attribute("tag"));
-    filter.insert("name", name);
-    return filter;
-}
-
-
 QDomElement EffectsList::getEffectByName(const QString & name) const {
     QString effectName;
     for (int i = 0; i < this->size(); ++i) {
index ff417d58bd61bec206d28f989d010f4e12c98dc5..3f2d03141d4e927db36b738d484941b1d4a64fd7 100644 (file)
@@ -41,7 +41,6 @@ public:
     QStringList effectNames();
     QString getInfo(const QString & tag, const QString & id) const;
     QString getInfoFromIndex(const int ix) const;
-    QMap <QString, QString> effect(const QString & name);
     EffectsList clone() const;
     static bool hasKeyFrames(QDomElement effect);
     static void setParameter(QDomElement effect, const QString &name, const QString &value);
index 8f2452f7c41ab4d9659c4ec7599647b8c5c9b1e5..b5e5e214eee0050b0c7d33229ee8ed10baca2999 100644 (file)
 #include "ui_listval_ui.h"
 #include "ui_boolval_ui.h"
 #include "ui_colorval_ui.h"
+#include "ui_positionval_ui.h"
 #include "ui_wipeval_ui.h"
 #include "complexparameter.h"
 #include "effectstackedit.h"
 #include "geometryval.h"
 
+#include "kdenlivesettings.h"
+
 QMap<QString, QImage> EffectStackEdit::iconCache;
 
 EffectStackEdit::EffectStackEdit(QWidget *parent): QWidget(parent), m_in(0), m_out(0) {
@@ -63,8 +66,9 @@ EffectStackEdit::~EffectStackEdit() {
     iconCache.clear();
 }
 
-void EffectStackEdit::updateProjectFormat(MltVideoProfile profile) {
+void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t) {
     m_profile = profile;
+    m_timecode = t;
 }
 
 void EffectStackEdit::transferParamDesc(const QDomElement& d, int in, int out) {
@@ -183,6 +187,14 @@ void EffectStackEdit::transferParamDesc(const QDomElement& d, int in, int out) {
             cval->label->setText(paramName);
             valueItems[paramName] = cval;
             uiItems.append(cval);
+        } else if (type == "position") {
+            Ui::Positionval_UI *pval = new Ui::Positionval_UI;
+            pval->setupUi(toFillin);
+            pval->krestrictedline->setText(m_timecode.getTimecodeFromFrames(value.toInt()));
+            connect(pval->krestrictedline, SIGNAL(editingFinished()), this, SLOT(collectAllParameters()));
+            pval->label->setText(paramName);
+            valueItems[paramName + "position"] = pval;
+            uiItems.append(pval);
         } else if (type == "wipe") {
             Ui::Wipeval_UI *wpval = new Ui::Wipeval_UI;
             wpval->setupUi(toFillin);
@@ -344,14 +356,18 @@ void EffectStackEdit::collectAllParameters() {
             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
         } else if (type == "color") {
             KColorButton *color = ((Ui::Colorval_UI*)valueItems[paramName])->kcolorbutton;
-           setValue = color->color().name();
-           setValue.replace('#', "0x");
+            setValue = color->color().name();
+            setValue.replace('#', "0x");
         } else if (type == "complex") {
             ComplexParameter *complex = ((ComplexParameter*)valueItems[paramName+"complex"]);
             namenode.item(i) = complex->getParamDesc();
         } else if (type == "geometry") {
             Geometryval *geom = ((Geometryval*)valueItems[paramName+"geometry"]);
             namenode.item(i) = geom->getParamDesc();
+        } else if (type == "position") {
+            KRestrictedLine *line = ((Ui::Positionval_UI*)valueItems[paramName+"position"])->krestrictedline;
+            setValue = QString::number(m_timecode.getFrameCount(line->text(), KdenliveSettings::project_fps()));
+            kDebug() << "// NEW POSITION: " << setValue << "(" << line->text() << " PARAM: " << paramName + "position";
         } else if (type == "wipe") {
             Ui::Wipeval_UI *wp = (Ui::Wipeval_UI*)valueItems[paramName];
             wipeInfo info;
index 00274847abf56eeb67065ab26bbe8698b2dea77c..ed3f3dacdb69f729a9f204b154664b983e80d2f2 100644 (file)
@@ -25,6 +25,7 @@
 #include <QMap>
 
 #include "definitions.h"
+#include "timecode.h"
 
 enum WIPE_DIRECTON { UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3, CENTER = 4 };
 
@@ -42,7 +43,7 @@ class EffectStackEdit : public QWidget {
 public:
     EffectStackEdit(QWidget *parent);
     ~EffectStackEdit();
-    void updateProjectFormat(MltVideoProfile profile);
+    void updateProjectFormat(MltVideoProfile profile, Timecode t);
     static QMap<QString, QImage> iconCache;
 
 private:
@@ -56,6 +57,7 @@ private:
     wipeInfo getWipeInfo(QString value);
     QString getWipeString(wipeInfo info);
     MltVideoProfile m_profile;
+    Timecode m_timecode;
     int m_in;
     int m_out;
 
index 5a6a61fbddc3ffbf36856d09ce946302e71297bc..2b7626a2feecc80aef5e5370458ca4176421481a 100644 (file)
@@ -77,8 +77,8 @@ void EffectStackView::setMenu(QMenu *menu) {
     ui.buttonNew->setMenu(menu);
 }
 
-void EffectStackView::updateProjectFormat(MltVideoProfile profile) {
-    effectedit->updateProjectFormat(profile);
+void EffectStackView::updateProjectFormat(MltVideoProfile profile, Timecode t) {
+    effectedit->updateProjectFormat(profile, t);
 }
 
 void EffectStackView::slotSaveEffect() {
index 18f453fa0e2c006954d23a6aba7ea855ecf72d9d..5b11665606113b7fbaebaf9cc63478a724b62f6e 100644 (file)
@@ -33,7 +33,7 @@ public:
     void raiseWindow(QWidget*);
     void clear();
     void setMenu(QMenu *menu);
-    void updateProjectFormat(MltVideoProfile profile);
+    void updateProjectFormat(MltVideoProfile profile, Timecode t);
 
 private:
     Ui::EffectStack_UI ui;
index fd14b77fd994d4fac98da6383927b59f49c1c393..1273c558f8e0bed595f6fe8fff48e15e42efb18e 100644 (file)
@@ -1290,8 +1290,8 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     KdenliveSettings::setProject_fps(doc->fps());
     m_monitorManager->resetProfiles(doc->timecode());
     m_projectList->setDocument(doc);
-    transitionConfig->updateProjectFormat(doc->mltProfile());
-    effectStack->updateProjectFormat(doc->mltProfile());
+    transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode());
+    effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
     connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
     connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
     connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
index fc44e35c650fdea99c163894374395ffbfd9db68..ee0f599e6ed229a37d075a1fd8831ddc5d6d0345 100644 (file)
@@ -43,8 +43,8 @@ TransitionSettings::TransitionSettings(QWidget* parent): QWidget(parent) {
     ui.splitter->setStretchFactor(1, 10);
 }
 
-void TransitionSettings::updateProjectFormat(MltVideoProfile profile) {
-    effectEdit->updateProjectFormat(profile);
+void TransitionSettings::updateProjectFormat(MltVideoProfile profile, Timecode t) {
+    effectEdit->updateProjectFormat(profile, t);
 }
 
 
index a8404ef3922a079a4dd73ce82d0e962f5c886f64..a06e6197492b512dd36d86cc45ad6ea081dbdc53 100644 (file)
@@ -22,6 +22,7 @@
 #include "ui_transitionsettings_ui.h"
 #include "definitions.h"
 
+class Timecode;
 class Transition;
 class EffectsList;
 class EffectStackEdit;
@@ -31,7 +32,7 @@ class TransitionSettings : public QWidget  {
 public:
     TransitionSettings(QWidget* parent = 0);
     void raiseWindow(QWidget*);
-    void updateProjectFormat(MltVideoProfile profile);
+    void updateProjectFormat(MltVideoProfile profile, Timecode t);
 
 private:
     Ui::TransitionSettings_UI ui;
diff --git a/src/widgets/positionval_ui.ui b/src/widgets/positionval_ui.ui
new file mode 100644 (file)
index 0000000..2e3d9db
--- /dev/null
@@ -0,0 +1,47 @@
+<ui version="4.0" >
+ <class>Positionval_UI</class>
+ <widget class="QWidget" name="Positionval_UI" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>135</width>
+    <height>28</height>
+   </rect>
+  </property>
+  <layout class="QGridLayout" name="gridLayout" >
+   <property name="verticalSpacing" >
+    <number>0</number>
+   </property>
+   <property name="margin" >
+    <number>0</number>
+   </property>
+   <item row="0" column="0" >
+    <widget class="QLabel" name="label" >
+     <property name="text" >
+      <string>Position</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1" >
+    <widget class="KRestrictedLine" name="krestrictedline" >
+     <property name="inputMask" >
+      <string>99:99:99:99; </string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+  <zorder>checkBox</zorder>
+  <zorder>label</zorder>
+  <zorder>krestrictedline</zorder>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KRestrictedLine</class>
+   <extends>KLineEdit</extends>
+   <header>krestrictedline.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>