From 89a0939d4a987b534bc5de36b2233bcadf51462f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Fri, 14 Nov 2008 00:10:58 +0000 Subject: [PATCH] * Fix undo of effect editing * Add widget to adjust position parameter in effects (fade, freeze) svn path=/branches/KDE4/; revision=2703 --- src/CMakeLists.txt | 1 + src/customtrackview.cpp | 19 ++++++++------ src/customtrackview.h | 2 +- src/editeffectcommand.cpp | 5 ++-- src/effectslist.cpp | 18 -------------- src/effectslist.h | 1 - src/effectstackedit.cpp | 22 +++++++++++++--- src/effectstackedit.h | 4 ++- src/effectstackview.cpp | 4 +-- src/effectstackview.h | 2 +- src/mainwindow.cpp | 4 +-- src/transitionsettings.cpp | 4 +-- src/transitionsettings.h | 3 ++- src/widgets/positionval_ui.ui | 47 +++++++++++++++++++++++++++++++++++ 14 files changed, 95 insertions(+), 41 deletions(-) create mode 100644 src/widgets/positionval_ui.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e9dc2a26..67de7cd3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 2d5cbe88..6eb6a570 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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 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(); diff --git a/src/customtrackview.h b/src/customtrackview.h index 88229d62..e1b90120 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -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); diff --git a/src/editeffectcommand.cpp b/src/editeffectcommand.cpp index 84a5d226..903e8f45 100644 --- a/src/editeffectcommand.cpp +++ b/src/editeffectcommand.cpp @@ -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; } diff --git a/src/effectslist.cpp b/src/effectslist.cpp index b0ba57c7..ade194e1 100644 --- a/src/effectslist.cpp +++ b/src/effectslist.cpp @@ -28,24 +28,6 @@ EffectsList::EffectsList(): EffectsList::~EffectsList() { } -QMap EffectsList::effect(const QString & name) { - QMap 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) { diff --git a/src/effectslist.h b/src/effectslist.h index ff417d58..3f2d0314 100644 --- a/src/effectslist.h +++ b/src/effectslist.h @@ -41,7 +41,6 @@ public: QStringList effectNames(); QString getInfo(const QString & tag, const QString & id) const; QString getInfoFromIndex(const int ix) const; - QMap effect(const QString & name); EffectsList clone() const; static bool hasKeyFrames(QDomElement effect); static void setParameter(QDomElement effect, const QString &name, const QString &value); diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index 8f2452f7..b5e5e214 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -29,11 +29,14 @@ #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 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; diff --git a/src/effectstackedit.h b/src/effectstackedit.h index 00274847..ed3f3dac 100644 --- a/src/effectstackedit.h +++ b/src/effectstackedit.h @@ -25,6 +25,7 @@ #include #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 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; diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index 5a6a61fb..2b7626a2 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -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() { diff --git a/src/effectstackview.h b/src/effectstackview.h index 18f453fa..5b116656 100644 --- a/src/effectstackview.h +++ b/src/effectstackview.h @@ -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; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fd14b77f..1273c558 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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())); diff --git a/src/transitionsettings.cpp b/src/transitionsettings.cpp index fc44e35c..ee0f599e 100644 --- a/src/transitionsettings.cpp +++ b/src/transitionsettings.cpp @@ -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); } diff --git a/src/transitionsettings.h b/src/transitionsettings.h index a8404ef3..a06e6197 100644 --- a/src/transitionsettings.h +++ b/src/transitionsettings.h @@ -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 index 00000000..2e3d9dbb --- /dev/null +++ b/src/widgets/positionval_ui.ui @@ -0,0 +1,47 @@ + + Positionval_UI + + + + 0 + 0 + 135 + 28 + + + + + 0 + + + 0 + + + + + Position + + + + + + + 99:99:99:99; + + + + + checkBox + label + krestrictedline + + + + KRestrictedLine + KLineEdit +
krestrictedline.h
+
+
+ + +
-- 2.39.2