CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
QDomDocument doc;
QDomElement e = doc.documentElement();
- if (view) view->slotAddTransition(this, QDomElement() , t->startPos(), m_track);
+ if (view) view->slotAddTransition(this, t->toXML() , t->startPos(), track());
}
// virtual
/*
QRect(m_dragItem->startPos().frames(m_document->fps()) *m_scale , m_dragItem->rect().y() + m_dragItem->rect().height() / 2,
GenTime(2.5).frames(m_document->fps()) *m_scale , m_dragItem->rect().height()
),
- (ClipItem*)m_dragItem, LUMA_TRANSITION, m_dragItem->startPos(), m_dragItem->startPos() + GenTime(2.5), m_document->fps());
+ (ClipItem*)m_dragItem, "luma" , m_dragItem->startPos(), m_dragItem->startPos() + GenTime(2.5), m_document->fps());
tr->setTrack(m_dragItem->track());
scene()->addItem(tr);
//m_dragItem->addTransition(tra);
m_commandStack->push(command);
}
-void CustomTrackView::addTransition(int startTrack, GenTime startPos , QDomElement) {
+void CustomTrackView::addTransition(int startTrack, GenTime startPos , QDomElement e) {
QMap < QString, QString> map;
/*map["start"] = "0.0";
map["end"] = "1.0";*/
- m_document->renderer()->mltAddTransition("luma", startTrack+4, startTrack + 5 , startPos, startPos + GenTime(2.5), map);
+ QDomDocument d("tes");
+ d.appendChild(e);
+ kDebug() << d.toString();
+ QDomNamedNodeMap attribs = e.attributes();
+ for (int i = 0;i < attribs.count();i++) {
+ if (attribs.item(i).nodeName() != "type" &&
+ attribs.item(i).nodeName() != "start" &&
+ attribs.item(i).nodeName() != "end"
+ )
+ map[attribs.item(i).nodeName()] = attribs.item(i).nodeValue();
+ }
+ m_document->renderer()->mltAddTransition(e.attribute("type"), 4 - e.attribute("transition_track").toInt(), 5 - e.attribute("transition_track").toInt() ,
+ GenTime(e.attribute("start").toInt(), m_document->renderer()->fps()),
+ GenTime(e.attribute("end").toInt(), m_document->renderer()->fps()),
+ map);
+
m_document->setModified(true);
}
}
//static
-Mlt::Repository *initEffects::parseEffectFiles(EffectsList *audioEffectList, EffectsList *videoEffectList) {
+Mlt::Repository *initEffects::parseEffectFiles(EffectsList *audioEffectList, EffectsList *videoEffectList, EffectsList* transitionsList) {
QStringList::Iterator more;
QStringList::Iterator it;
QStringList fileList;
delete filters;
delete producers;
+ Mlt::Properties *transitions = repository->transitions();
+ QStringList transitionsItemList;
+ for (int i = 0 ; i < transitions->count() ; i++) {
+ transitionsItemList << transitions->get_name(i);
+ }
+ delete transitions;
+ fillTransitionsList(repository, transitionsList, transitionsItemList);
+
KGlobal::dirs()->addResourceType("ladspa_plugin", 0, "lib/ladspa");
KGlobal::dirs()->addResourceDir("ladspa_plugin", "/usr/lib/ladspa");
KGlobal::dirs()->addResourceDir("ladspa_plugin", "/usr/local/lib/ladspa");
return ret;
}
+void initEffects::fillTransitionsList(Mlt::Repository * repository, EffectsList* transitions, QStringList names) {
+ foreach(QString name, names) {
+ QDomDocument ret;
+ Mlt::Properties *metadata = repository->metadata(transition_type, name.toAscii().data());
+ //kDebug() << filtername;
+ if (metadata && metadata->is_valid()) {
+ QDomElement ktrans = ret.createElement("ktransition");
+ ret.appendChild(ktrans);
+ if (metadata->get("title") && metadata->get("identifier")) {
+ ktrans.setAttribute("tag", name);
+ QDomElement tname = ret.createElement("name");
+ tname.appendChild(ret.createTextNode(metadata->get("title")));
+ ktrans.appendChild(tname);
+ }
+ transitions->append(ret.documentElement());
+ kDebug() << ret.toString();
+ } else {
+ if (name == "luma") {
+ QDomDocument ret;
+ QDomElement ktrans = ret.createElement("ktransition");
+ ret.appendChild(ktrans);
+ ktrans.setAttribute("tag", name);
+ QDomElement tname = ret.createElement("name");
+ tname.appendChild(ret.createTextNode("Luma"));
+ ktrans.appendChild(tname);
+ transitions->append(ret.documentElement());
+
+ QDomDocument ret1;
+ QDomElement ktrans1 = ret1.createElement("ktransition");
+ ret1.appendChild(ktrans1);
+ ktrans1.setAttribute("tag", name);
+ QDomElement tname1 = ret.createElement("name");
+ tname1.appendChild(ret1.createTextNode("Lumafile"));
+ ktrans1.appendChild(tname1);
+ transitions->append(ret1.documentElement());
+ } else if (name == "composite") {
+ QDomDocument ret;
+ QDomElement ktrans = ret.createElement("ktransition");
+ ret.appendChild(ktrans);
+ ktrans.setAttribute("tag", name);
+ QDomElement tname = ret.createElement("name");
+ tname.appendChild(ret.createTextNode("Composite"));
+ ktrans.appendChild(tname);
+ transitions->append(ret.documentElement());
+
+ QDomDocument ret1;
+ QDomElement ktrans1 = ret1.createElement("ktransition");
+ ret1.appendChild(ktrans1);
+ ktrans1.setAttribute("tag", name);
+ QDomElement tname1 = ret.createElement("name");
+ tname1.appendChild(ret1.createTextNode("PIP"));
+ ktrans1.appendChild(tname1);
+ transitions->append(ret1.documentElement());
+ } else if (name == "mix") {
+ QDomDocument ret;
+ QDomElement ktrans = ret.createElement("ktransition");
+ ret.appendChild(ktrans);
+ ktrans.setAttribute("tag", name);
+ QDomElement tname = ret.createElement("name");
+ tname.appendChild(ret.createTextNode("Mix"));
+ ktrans.appendChild(tname);
+ transitions->append(ret.documentElement());
+ } else if (name == "affine") {
+ QDomDocument ret;
+ QDomElement ktrans = ret.createElement("ktransition");
+ ret.appendChild(ktrans);
+ ktrans.setAttribute("tag", name);
+ QDomElement tname = ret.createElement("name");
+ tname.appendChild(ret.createTextNode("Affine"));
+ ktrans.appendChild(tname);
+ transitions->append(ret.documentElement());
+ }
+ }
+
+ }
+}
initEffects();
~initEffects();
- static Mlt::Repository *parseEffectFiles(EffectsList *audioEffectList, EffectsList *videoEffectList);
+ static Mlt::Repository *parseEffectFiles(EffectsList *audioEffectList, EffectsList *videoEffectList, EffectsList *transitions);
static QDomDocument createDescriptionFromMlt(Mlt::Repository* repository, const QString& type, const QString& name);
+ static void fillTransitionsList(Mlt::Repository *, EffectsList* transitions, QStringList names);
static void parseEffectFile(EffectsList *audioEffectList, EffectsList *videoEffectList, QString name, QStringList filtersList, QStringList producersList);
static char* ladspaEffectString(int ladspaId, QStringList params);
static void ladspaEffectFile(const QString & fname, int ladspaId, QStringList params);
#include <KApplication>
#include <KAction>
#include <KLocale>
+#include <KGlobal>
#include <KActionCollection>
#include <KStandardAction>
#include <KFileDialog>
m_timelineArea->setCornerWidget(closeTabButton);
connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
- initEffects::parseEffectFiles(&m_audioEffects, &m_videoEffects);
+ initEffects::parseEffectFiles(&m_audioEffects, &m_videoEffects, &m_transitions);
m_monitorManager = new MonitorManager();
projectListDock = new QDockWidget(i18n("Project Tree"), this);
transitionConfigDock = new QDockWidget(i18n("Transition"), this);
transitionConfigDock->setObjectName("transition");
- transitionConfig = new TransitionSettings(this);
+ transitionConfig = new TransitionSettings(&m_transitions, this);
transitionConfigDock->setWidget(transitionConfig);
addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
EffectsList m_videoEffects;
EffectsList m_audioEffects;
EffectsList m_customEffects;
+ EffectsList m_transitions;
QMenu *m_timelineContextMenu;
QMenu *m_timelineContextClipMenu;
#include "kdenlivesettings.h"
-Transition::Transition(const QRectF& rect , ClipItem * clipa, const TRANSITIONTYPE & type, const GenTime &startTime, const GenTime &endTime, double fps, bool inverted) : AbstractClipItem(rect) {
+Transition::Transition(const QRectF& rect , ClipItem * clipa, const QString & type, const GenTime &startTime, const GenTime &endTime, double fps, bool inverted) : AbstractClipItem(rect) {
m_invertTransition = inverted;
m_singleClip = true;
m_transitionTrack = 0;
m_secondClip = NULL;
- m_transitionType = type;
- m_transitionName = getTransitionName(m_transitionType);
+ m_transitionName = type;
m_fps = fps;
m_cropDuration = endTime - startTime;
m_startPos = startTime;
GenTime defaultTransitionDuration = GenTime(2.5);
m_referenceClip = clipa;
- m_referenceClip->addTransition(this);
+
if (startTime < m_referenceClip->startPos()) m_transitionStart = GenTime(0.0);
else if (startTime > m_referenceClip->endPos()) m_transitionStart = m_referenceClip->duration() - defaultTransitionDuration;
else m_transitionStart = startTime - m_referenceClip->startPos();
m_secondClip = 0;
setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setZValue(2);
+ m_referenceClip->addTransition(this);
}
// create a transition from XML
m_transitionStart = m_transitionStart - offset;
m_invertTransition = transitionElement.attribute("inverted", "0").toInt();
- uint transType = transitionElement.attribute("type", "0").toInt();
- if (transType == LUMA_TRANSITION) m_transitionType = LUMA_TRANSITION;
- else if (transType == COMPOSITE_TRANSITION) m_transitionType = COMPOSITE_TRANSITION;
- else if (transType == PIP_TRANSITION) m_transitionType = PIP_TRANSITION;
- else if (transType == LUMAFILE_TRANSITION) m_transitionType = LUMAFILE_TRANSITION;
- else if (transType == MIX_TRANSITION) m_transitionType = MIX_TRANSITION;
+ m_transitionName = transitionElement.attribute("type" , "luma");
// load transition parameters
typedef QMap<QString, QString> ParamMap;
Transition::~Transition() {
}
-void Transition::setTransitionType(TRANSITIONTYPE newType) {
- m_transitionType = newType;
- m_transitionName = getTransitionName(m_transitionType);
-}
-
-TRANSITIONTYPE Transition::transitionType() const {
- return m_transitionType;
-}
-
-QString Transition::transitionTag()const {
- switch (m_transitionType) {
- case COMPOSITE_TRANSITION:
- return "composite";
- case PIP_TRANSITION:
- return "composite";
- case MIX_TRANSITION:
- return "mix";
- default:
- return "luma";
-
- }
-}
-
-QString Transition::getTransitionName(const TRANSITIONTYPE & type) {
- if (type == COMPOSITE_TRANSITION) return i18n("Push");
- else if (type == PIP_TRANSITION) return i18n("Pip");
- else if (type == LUMAFILE_TRANSITION) return i18n("Wipe");
- else if (type == MIX_TRANSITION) return i18n("Audio Fade");
- return i18n("Crossfade");
-}
-
-TRANSITIONTYPE Transition::getTransitionForName(const QString & type) {
- if (type == i18n("Push")) return COMPOSITE_TRANSITION;
- else if (type == i18n("Pip")) return PIP_TRANSITION;
- else if (type == i18n("Wipe")) return LUMAFILE_TRANSITION;
- return LUMA_TRANSITION;
-}
-
-
QString Transition::transitionName() const {
return m_transitionName;
}
QPixmap Transition::transitionPixmap() const {
KIcon icon;
- if (m_transitionType == LUMA_TRANSITION) {
- if (invertTransition()) icon = KIcon("kdenlive_trans_down");
- else icon = KIcon("kdenlive_trans_up");
- } else if (m_transitionType == COMPOSITE_TRANSITION) {
+ if (m_transitionName == "luma") {
+ if (invertTransition()) icon = KIcon("kdenlive_trans_up");
+ else icon = KIcon("kdenlive_trans_down");
+ } else if (m_transitionName == "composite") {
icon = KIcon("kdenlive_trans_wiper");
- } else if (m_transitionType == LUMAFILE_TRANSITION) {
+ } else if (m_transitionName == "lumafile") {
icon = KIcon("kdenlive_trans_luma");
} else icon = KIcon("kdenlive_trans_pip");
return icon.pixmap(QSize(15, 15));
QDomElement Transition::toXML() {
QDomDocument doc;
QDomElement effect = doc.createElement("ktransition");
- effect.setAttribute("type", transitionType());
+ effect.setAttribute("type", m_transitionName);
effect.setAttribute("inverted", invertTransition());
effect.setAttribute("transition_track", m_transitionTrack);
effect.setAttribute("start", transitionStartTime().frames(m_referenceClip->fps()));
Q_OBJECT
public:
- Transition(const QRectF&, ClipItem * clipa, const TRANSITIONTYPE & type, const GenTime &startTime, const GenTime &endTime, double fps, bool inverted = false);
+ Transition(const QRectF&, ClipItem * clipa, const QString& type, const GenTime &startTime, const GenTime &endTime, double fps, bool inverted = false);
Transition(const QRectF&, ClipItem * clip, QDomElement transitionElement, double fps, GenTime offset = GenTime());
virtual ~Transition();
virtual void paint(QPainter *painter,
void resizeTransitionStart(GenTime time);
void moveTransition(GenTime time);
bool invertTransition() const;
- TRANSITIONTYPE transitionType() const;
- OPERATIONTYPE operationMode(QPointF pos, double scale);
- QString transitionTag() const;
QString transitionName() const;
- void setTransitionType(TRANSITIONTYPE newType);
+ OPERATIONTYPE operationMode(QPointF pos, double scale);
+ void setTransitionType(QString newType);
const QMap < QString, QString > transitionParameters() const;
void setTransitionParameters(const QMap < QString, QString > parameters);
void setTransitionDirection(bool inv);
GenTime m_transitionDuration;
QMap < QString, QString > m_transitionParameters;
- /** The name of the transition used by mlt (composite, luma,...)*/
- TRANSITIONTYPE m_transitionType;
-
/** The name of the transition to be displayed to user */
QString m_transitionName;
#include "transitionsettings.h"
#include <KDebug>
-TransitionSettings::TransitionSettings(QWidget* parent): QWidget(parent) {
+TransitionSettings::TransitionSettings(EffectsList *transitions, QWidget* parent): QWidget(parent) {
ui.setupUi(this);
setEnabled(false);
+ m_transitions = transitions;
+ ui.listWidget->addItems(transitions->effectNames());
+ kDebug() << transitions->effectNames().size() << " -" << transitions->size();
}
void TransitionSettings::slotTransitionItemSelected(Transition* t) {
#ifndef TRANSITIONSETTINGS_H
#define TRANSITIONSETTINGS_H
#include "ui_transitionsettings_ui.h"
+#include "effectslist.h"
class Transition;
class TransitionSettings : public QWidget {
Q_OBJECT
public:
- TransitionSettings(QWidget* parent = 0);
+ TransitionSettings(EffectsList *, QWidget* parent = 0);
private:
Ui::TransitionSettings_UI ui;
+ EffectsList *m_transitions;
public slots:
void slotTransitionItemSelected(Transition*);
};