#include "titlewidget.h"
#include "mainwindow.h"
-
-KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QPoint tracks, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_commandStack(new QUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(7), m_autosave(NULL) {
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QPoint tracks, Render *render, MainWindow *parent): QObject(parent), m_render(render), m_url(url), m_projectFolder(projectFolder), m_commandStack(new QUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(7), m_autosave(NULL) {
m_clipManager = new ClipManager(this);
m_autoSaveTimer = new QTimer(this);
m_autoSaveTimer->setSingleShot(true);
if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
else m_timecode.setFormat((int) m_fps);
+ m_render->setSceneList(m_document.toString(), m_startPos);
+ //kDebug() << "// SETTING SCENE LIST:\n\n" << m_document.toString();
+ checkProjectClips();
+
connect(m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(slotAutoSave()));
+
}
KdenliveDoc::~KdenliveDoc() {
return m_commandStack;
}
+/*
void KdenliveDoc::setRenderer(Render *render) {
if (m_render) return;
m_render = render;
checkProjectClips();
}
emit progressInfo(QString(), -1);
-}
+}*/
void KdenliveDoc::checkProjectClips() {
if (m_render == NULL) return;
int subtrack = clipId.section('_', 1, 1).toInt();
DocClipBase *clip = m_clipManager->getClipById(producerId);
if (clip == NULL) {
+ /*kDebug()<<"// CLIP "<<clipId<<" NOT OFUND in LIST, CREATING";
+ QDomDocument doc;
+ doc.appendChild(doc.importNode(elem, true));
+ kDebug() << "IMPORTED CLIP: \n" << doc.toString()<<"\n";*/
elem.setAttribute("id", producerId);
QString path = elem.attribute("resource");
QString extension;
clip = new DocClipBase(m_clipManager, elem, producerId);
m_clipManager->addClip(clip);
}
- if (createClipItem) emit addProjectClip(clip);
+ if (createClipItem) {
+ emit addProjectClip(clip);
+ qApp->processEvents();
+ m_render->getFileProperties(clip->toXML(), clip->getId());
+ }
}
+
void KdenliveDoc::setNewClipResource(const QString &id, const QString &path) {
QDomNodeList prods = m_document.elementsByTagName("producer");
int maxprod = prods.count();
void KdenliveDoc::addClipInfo(QDomElement elem, QString clipId) {
DocClipBase *clip = m_clipManager->getClipById(clipId);
if (clip == NULL) {
- addClip(elem, clipId);
+ addClip(elem, clipId, false);
} else {
QMap <QString, QString> properties;
QDomNamedNodeMap attributes = elem.attributes();
class KdenliveDoc: public QObject {
Q_OBJECT public:
- KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QPoint tracks, MainWindow *parent = 0);
+ KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QPoint tracks, Render *render, MainWindow *parent = 0);
~KdenliveDoc();
QDomNodeList producersList();
double fps() const;
void backupMltPlaylist();
Timecode timecode() const;
QDomDocument toXml();
- void setRenderer(Render *render);
+ //void setRenderer(Render *render);
QUndoStack *commandStack();
QString producerName(const QString &id);
void setProducerDuration(const QString &id, int duration);
void MainWindow::slotConnectMonitors() {
- m_projectList->setRenderer(m_clipMonitor->render);
+ m_projectList->setRenderer(m_projectMonitor->render);
connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
- connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
- connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
- connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
+ connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
+ connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
+ connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
- connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
+ connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
projectTracks = w->tracks();
delete w;
}
- KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
+ KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
TrackView *trackView = new TrackView(doc, this);
m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
void MainWindow::openLastFile() {
KSharedConfigPtr config = KGlobal::config();
KUrl::List urls = m_fileOpenRecent->urls();
+ //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
if (urls.isEmpty()) newFile(false);
else openFile(urls.last());
}
void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
KdenliveDoc *doc;
- doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
+ doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
if (stale == NULL) {
stale = new KAutoSaveFile(url, doc);
doc->m_autosave = stale;
TrackView *trackView = new TrackView(doc, this);
m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
+ trackView->setDuration(trackView->duration());
+ trackView->projectView()->setCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
slotGotProgressInfo(QString(), -1);
m_clipMonitor->refreshMonitor(true);
disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
effectStack->clear();
}
- m_activeDocument->setRenderer(NULL);
+ //m_activeDocument->setRenderer(NULL);
disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
m_clipMonitor->stop();
}
trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
m_activeTimeline = trackView;
if (m_renderWidget) m_renderWidget->setProfile(doc->mltProfile());
- doc->setRenderer(m_projectMonitor->render);
+ //doc->setRenderer(m_projectMonitor->render);
m_commandStack->setActiveStack(doc->commandStack());
KdenliveSettings::setProject_display_ratio(doc->dar());
m_projectList->updateAllClips();
}
void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) {
+ if (getProperties) listView->setEnabled(false);
const QString parent = clip->getProperty("groupid");
//kDebug() << "Adding clip with groupid: " << parent;
ProjectItem *item = NULL;
}
if (!annotation.isEmpty()) item->setText(2, annotation);
}
- if (getProperties) requestClipInfo(clip->toXML(), clip->getId());
}
void ProjectList::requestClipInfo(const QDomElement xml, const QString id) {
emit receivedClipDuration(clipId, item->clipMaxDuration());
} else kDebug() << "//////// COULD NOT FIND CLIP TO UPDATE PRPS...";
if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
+ else listView->setEnabled(true);
}
void ProjectList::slotReplyGetImage(const QString &clipId, int pos, const QPixmap &pix, int w, int h) {
char *tmp;
tmp = decodedString(KdenliveSettings::current_profile());
m_mltProfile = new Mlt::Profile(tmp);
+ setenv("MLT_PROFILE", tmp, 1);
delete[] tmp;
kDebug() << "reset to same profile, nothing to do";
return 1;
}
+ kDebug() << "// RESETTING PROFILE FROM: " << currentProfile << " TO: " << KdenliveSettings::current_profile();
if (m_isSplitView) slotSplitView(false);
if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
m_mltConsumer->purge();
delete m_mltConsumer;
m_mltConsumer = NULL;
QString scene = sceneList();
- if (m_mltProducer) delete m_mltProducer;
+ int pos = 0;
+ if (m_mltProducer) {
+ pos = m_mltProducer->position();
+ delete m_mltProducer;
+ }
m_mltProducer = NULL;
if (m_mltProfile) delete m_mltProfile;
m_mltProfile = NULL;
buildConsumer();
//kDebug() << "//RESET WITHSCENE: " << scene;
- setSceneList(scene);
+ setSceneList(scene, pos);
char *tmp = decodedString(scene);
Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", tmp);
}
m_isBlocked = false;
blockSignals(false);
- emit rendererPosition(position);
+ //kDebug()<<"// SETSCN LST, POS: "<<position;
+ //if (position != 0) emit rendererPosition(position);
}
/** Create the producer from the Westley QDomDocument */
/** MLT PLAYLIST DIRECT MANIPULATON **/
-void Render::mltCheckLength(bool reload) {
+void Render::mltCheckLength() {
//kDebug()<<"checking track length: "<<track<<"..........";
Mlt::Service service(m_mltProducer->get_service());
/** Sets the description of this renderer to desc. */
void closeMlt();
- void mltCheckLength(bool reload = true);
+ void mltCheckLength();
QMap<QString, QString> mltGetTransitionParamsFromXml(QDomElement xml);
QMap<QString, Mlt::Producer *> m_slowmotionProducers;
void buildConsumer();