#include <QInputDialog>
TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
- QWidget(parent),
- m_scale(1.0),
- m_projectTracks(0),
- m_doc(doc),
- m_verticalZoom(1)
+ QWidget(parent),
+ m_scale(1.0),
+ m_projectTracks(0),
+ m_doc(doc),
+ m_verticalZoom(1)
{
setupUi(this);
m_trackview = new CustomTrackView(doc, m_scene, parent);
m_trackview->scale(1, 1);
m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
- //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
m_ruler = new CustomRuler(doc->timecode(), m_trackview);
connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
connect(m_trackview, SIGNAL(tracksChanged()), this, SLOT(slotReloadTracks()));
connect(m_trackview, SIGNAL(updateTrackHeaders()), this, SLOT(slotRepaintTracks()));
connect(m_trackview, SIGNAL(showTrackEffects(int, TrackInfo)), this, SIGNAL(showTrackEffects(int, TrackInfo)));
+ connect(m_trackview, SIGNAL(updateTrackEffectState(int)), this, SLOT(slotUpdateTrackEffectState(int)));
+
parseDocument(m_doc->toXml());
if (m_doc->setSceneList() == -1) *ok = false;
connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
- slotSetZone(m_doc->zone());
+ slotSetZone(m_doc->zone(), false);
}
TrackView::~TrackView()
return m_ruler->outPoint();
}
-void TrackView::slotSetZone(QPoint p)
+void TrackView::slotSetZone(QPoint p, bool updateDocumentProperties)
{
m_ruler->setZone(p);
+ if (updateDocumentProperties) m_doc->setZone(p.x(), p.y());
}
void TrackView::setDuration(int dur)
}*/
// parse project tracks
- QDomElement tractor = doc.elementsByTagName("tractor").item(0).toElement();
- QDomNodeList tracks = doc.elementsByTagName("track");
+ QDomElement mlt = doc.firstChildElement("mlt");
+ QDomElement tractor = mlt.firstChildElement("tractor");
+ QDomNodeList tracks = tractor.elementsByTagName("track");
QDomNodeList playlists = doc.elementsByTagName("playlist");
int duration = 300;
m_projectTracks = tracks.count();
if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
int in = e.attribute("in").toInt();
int out = e.attribute("out").toInt();
- if (in > out || in == out) {
+ if (in >= out) {
// invalid producer, remove it
QString id = e.attribute("id");
m_invalidProducers.append(id);
p = playlists.item(j).toElement();
if (p.attribute("id") == playlist_name) {
// playlist found, check track effects
- QDomNodeList trackEffects = p.elementsByTagName("filter");
- kDebug() << "<< PLAYLIST: " << playlist_name << ", effects: " << trackEffects.count() << ", TK IX: " << trackIndex;
+ QDomNodeList trackEffects = p.childNodes();
slotAddProjectEffects(trackEffects, p, NULL, trackIndex++);
break;
}
}
// parse transitions
- QDomNodeList transitions = doc.elementsByTagName("transition");
+ QDomNodeList transitions = tractor.elementsByTagName("transition");
//kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
for (int i = 0; i < transitions.count(); i++) {
}
}
+
+ QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
+
// Add guides
- QDomNodeList guides = doc.elementsByTagName("guide");
+ QDomNodeList guides = infoXml.elementsByTagName("guide");
for (int i = 0; i < guides.count(); i++) {
e = guides.item(i).toElement();
const QString comment = e.attribute("comment");
}
// Rebuild groups
- QDomNodeList groups = doc.elementsByTagName("group");
+ QDomNodeList groups = infoXml.elementsByTagName("group");
m_trackview->loadGroups(groups);
m_trackview->setDuration(duration);
kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
// Remove Kdenlive extra info from xml doc before sending it to MLT
- QDomElement mlt = doc.firstChildElement("mlt");
- QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
mlt.removeChild(infoXml);
slotRebuildTrackHeaders();
void TrackView::slotRepaintTracks()
{
- QLayoutItem *child;
- for (int i = 0; i < headers_container->layout()->count(); i++) {
- child = headers_container->layout()->itemAt(i);
- if (child->widget() && child->widget()->height() > 5) {
- HeaderTrack *head = static_cast <HeaderTrack *>(child->widget());
- if (head) head->setSelectedIndex(m_trackview->selectedTrack());
- }
+ QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
+ for (int i = 0; i < widgets.count(); i++) {
+ if (widgets.at(i)) widgets.at(i)->setSelectedIndex(m_trackview->selectedTrack());
}
}
QFrame *frame = NULL;
for (int i = 0; i < max; i++) {
frame = new QFrame(headers_container);
+ frame->setFrameStyle(QFrame::HLine);
frame->setFixedHeight(1);
- frame->setFrameStyle(QFrame::Plain);
- frame->setFrameShape(QFrame::Box);
- frame->setLineWidth(1);
headers_container->layout()->addWidget(frame);
TrackInfo info = list.at(max - i - 1);
header = new HeaderTrack(i, info, height, headers_container);
headers_container->layout()->addWidget(header);
}
frame = new QFrame(this);
+ frame->setFrameStyle(QFrame::HLine);
frame->setFixedHeight(1);
- frame->setFrameStyle(QFrame::Plain);
- frame->setFrameShape(QFrame::Box);
- frame->setLineWidth(1);
headers_container->layout()->addWidget(frame);
}
void TrackView::adjustTrackHeaders()
{
int height = KdenliveSettings::trackheight() * m_scene->scale().y() - 1;
- QLayoutItem *child;
- for (int i = 0; i < headers_container->layout()->count(); i++) {
- child = headers_container->layout()->itemAt(i);
- if (child->widget() && child->widget()->height() > 5)(static_cast <HeaderTrack *>(child->widget()))->adjustSize(height);
+ QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
+ for (int i = 0; i < widgets.count(); i++) {
+ if (widgets.at(i)) widgets.at(i)->adjustSize(height);
}
}
return position;
}
-void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parent, ClipItem *clip, int trackIndex)
+void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex)
{
+ int effectNb = 0;
for (int ix = 0; ix < effects.count(); ix++) {
bool disableeffect = false;
QDomElement effect = effects.at(ix).toElement();
-
+ if (effect.tagName() != "filter") continue;
+ effectNb++;
// add effect to clip
QString effecttag;
QString effectid;
- QString effectindex = QString::number(ix + 1);
+ QString effectindex = QString::number(effectNb);
QString ladspaEffectFile;
// Get effect tag & index
for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
//kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
// get effect standard tags
QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
- if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
- if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
+ if (clipeffect.isNull()) {
+ clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
+ }
+ if (clipeffect.isNull()) {
+ clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
+ }
if (clipeffect.isNull()) {
kDebug() << "/// WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
- parent.removeChild(effects.at(ix));
+ if (parentNode.removeChild(effects.at(ix)).isNull()) kDebug() << "/// PROBLEM REMOVING EFFECT: " << effecttag;
ix--;
} else {
QDomElement currenteffect = clipeffect.cloneNode().toElement();
endvalue = effectparam.text().toDouble() * fact;
}
// add first keyframe
- keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
+ if (effectout <= effectin) {
+ // there is only one keyframe
+ keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';');
+ } else keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
QDomNode lastParsedEffect;
ix++;
QDomNode n2 = effects.at(ix);
for (int k = 0; k < clipeffectparams.count(); k++) {
e = clipeffectparams.item(k).toElement();
if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
- if (e.attribute("factor", "1") != "1") {
- QString factor = e.attribute("factor", "1");
- double fact;
- if (factor.startsWith('%')) {
- fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
- } else fact = factor.toDouble();
- if (e.attribute("type") == "simplekeyframe") {
- QStringList kfrs = paramvalue.split(";");
- for (int l = 0; l < kfrs.count(); l++) {
- QString fr = kfrs.at(l).section("=", 0, 0);
- double val = kfrs.at(l).section("=", 1, 1).toDouble();
- kfrs[l] = fr + ":" + QString::number((int)(val * fact));
- }
- e.setAttribute("keyframes", kfrs.join(";"));
- } else e.setAttribute("value", paramvalue.toDouble() * fact);
- } else e.setAttribute("value", paramvalue);
+ QString factor = e.attribute("factor", "1");
+ double fact;
+ if (factor.startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
+ } else {
+ fact = factor.toDouble();
+ }
+ if (e.attribute("type") == "simplekeyframe") {
+ QStringList kfrs = paramvalue.split(";");
+ for (int l = 0; l < kfrs.count(); l++) {
+ QString fr = kfrs.at(l).section('=', 0, 0);
+ double val = kfrs.at(l).section('=', 1, 1).toDouble();
+ kfrs[l] = fr + ":" + QString::number((int)(val * fact));
+ }
+ e.setAttribute("keyframes", kfrs.join(";"));
+ } else {
+ bool ok;
+ e.setAttribute("value", paramvalue.toDouble(&ok) * fact);
+ if (!ok)
+ e.setAttribute("value", paramvalue);
+ }
break;
}
}
currenteffect.setAttribute("src", ladspaEffectFile);
}
if (disableeffect) currenteffect.setAttribute("disable", "1");
- if (clip) clip->addEffect(currenteffect, false);
- else {
- kDebug() << "<< TRACK: " << trackIndex << ", adding effect";;
+ if (clip)
+ clip->addEffect(currenteffect, false);
+ else
m_doc->addTrackEffect(trackIndex, currenteffect);
- }
}
}
}
void TrackView::slotShowTrackEffects(int ix)
{
+ m_trackview->clearSelection();
emit showTrackEffects(m_doc->tracksCount() - ix, m_doc->trackInfoAt(m_doc->tracksCount() - ix - 1));
}
+void TrackView::slotUpdateTrackEffectState(int ix)
+{
+ QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
+ if (ix < 0 || ix >= widgets.count()) {
+ kDebug() << "ERROR, Trying to access a non existant track: " << ix;
+ return;
+ }
+ widgets.at(m_doc->tracksCount() - ix - 1)->updateEffectLabel(m_doc->trackInfoAt(ix).effectsList.effectNames());
+}
+
#include "trackview.moc"