Start disconnecting old timeline, start work on save/load project

parent 16056a23
......@@ -42,6 +42,7 @@
#include "mltcontroller/bincontroller.h"
#include "mltcontroller/effectscontroller.h"
#include "timeline/transitionhandler.h"
#include "profiles/profilemodel.hpp"
#include <KMessageBox>
#include <klocalizedstring.h>
......@@ -301,15 +302,20 @@ KdenliveDoc::~KdenliveDoc()
}
}
Mlt::Producer *KdenliveDoc::getProjectProducer()
{
return new Mlt::Producer(pCore->getCurrentProfile()->profile(), "xml-string", m_document.toString().toUtf8().constData());
}
int KdenliveDoc::setSceneList()
{
//m_render->resetProfile(m_profile);
pCore->bin()->isLoading = true;
pCore->producerQueue()->abortOperations();
if (m_render->setSceneList(m_document.toString(), m_documentProperties.value(QStringLiteral("position")).toInt()) == -1) {
/*if (m_render->setSceneList(m_document.toString(), m_documentProperties.value(QStringLiteral("position")).toInt()) == -1) {
// INVALID MLT Consumer, something is wrong
return -1;
}
}*/
pCore->bin()->isLoading = false;
bool ok = false;
......
......@@ -69,6 +69,8 @@ public:
KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QMap<QString, QString> &properties, const QMap<QString, QString> &metadata, const QPoint &tracks, Render *render, NotesPlugin *notes, bool *openBackup, MainWindow *parent = nullptr);
~KdenliveDoc();
/** @brief Get current document's producer. */
Mlt::Producer *getProjectProducer();
QDomNodeList producersList();
double fps() const;
int width() const;
......
......@@ -1951,13 +1951,15 @@ void MainWindow::slotUpdateDocumentState(bool modified)
void MainWindow::connectDocument()
{
KdenliveDoc *project = pCore->projectManager()->current();
Timeline *trackView = pCore->projectManager()->currentTimeline();
connect(project, &KdenliveDoc::startAutoSave, pCore->projectManager(), &ProjectManager::slotStartAutoSave);
connect(project, &KdenliveDoc::reloadEffects, this, &MainWindow::slotReloadEffects);
KdenliveSettings::setProject_fps(project->fps());
m_clipMonitorDock->raise();
m_effectStack->transitionConfig()->updateProjectFormat();
//TODO REFAC: reconnect to new timeline
/*
Timeline *trackView = pCore->projectManager()->currentTimeline();
connect(trackView, &Timeline::configTrack, this, &MainWindow::slotConfigTrack);
connect(trackView, &Timeline::updateTracksInfo, this, &MainWindow::slotUpdateTrackInfo);
connect(trackView, &Timeline::mousePosition, this, &MainWindow::slotUpdateMousePosition);
......@@ -1968,10 +1970,7 @@ void MainWindow::connectDocument()
connect(m_projectMonitor, &Monitor::multitrackView, trackView, &Timeline::slotMultitrackView);
connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), project, SLOT(setModified()));
connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), project, SLOT(setModified()));
connect(project, &KdenliveDoc::docModified, this, &MainWindow::slotUpdateDocumentState);
connect(trackView->projectView(), &CustomTrackView::guidesUpdated, this, &MainWindow::slotGuidesUpdated);
connect(trackView->projectView(), &CustomTrackView::loadMonitorScene, m_projectMonitor, &Monitor::slotShowEffectScene);
connect(trackView->projectView(), &CustomTrackView::setQmlProperty, m_projectMonitor, &Monitor::setQmlProperty);
......@@ -1994,11 +1993,11 @@ void MainWindow::connectDocument()
connect(trackView, SIGNAL(displayMessage(QString, MessageType)), m_messageLabel, SLOT(setMessage(QString, MessageType)));
connect(trackView->projectView(), SIGNAL(displayMessage(QString, MessageType)), m_messageLabel, SLOT(setMessage(QString, MessageType)));
connect(pCore->bin(), &Bin::clipNameChanged, trackView->projectView(), &CustomTrackView::clipNameChanged);
connect(pCore->bin(), SIGNAL(displayMessage(QString, int, MessageType)), m_messageLabel, SLOT(setProgressMessage(QString, int, MessageType)));
connect(trackView->projectView(), SIGNAL(showClipFrame(QString, int)), pCore->bin(), SLOT(selectClipById(QString, int)));
connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
connect(trackView->projectView(), &CustomTrackView::pauseMonitor, m_projectMonitor, &Monitor::pause, Qt::DirectConnection);
connect(m_projectMonitor, &Monitor::addEffect, trackView->projectView(), &CustomTrackView::slotAddEffectToCurrentItem);
connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition *, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition *)));
......@@ -2030,10 +2029,17 @@ void MainWindow::connectDocument()
connect(project, &KdenliveDoc::updateFps, trackView, &Timeline::updateProfile, Qt::DirectConnection);
connect(trackView, &Timeline::zoneMoved, this, &MainWindow::slotZoneMoved);
trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu *>(factory()->container(QStringLiteral("marker_menu"), this)));
*/
connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), project, SLOT(setModified()));
connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), project, SLOT(setModified()));
connect(project, &KdenliveDoc::docModified, this, &MainWindow::slotUpdateDocumentState);
connect(pCore->bin(), SIGNAL(displayMessage(QString, int, MessageType)), m_messageLabel, SLOT(setProgressMessage(QString, int, MessageType)));
if (m_renderWidget) {
slotCheckRenderStatus();
m_renderWidget->setProfile(project->mltProfile().path);
m_renderWidget->setGuides(pCore->projectManager()->currentTimeline()->projectView()->guidesData(), project->projectDuration());
//m_renderWidget->setGuides(pCore->projectManager()->currentTimeline()->projectView()->guidesData(), project->projectDuration());
m_renderWidget->setDocumentPath(project->projectDataFolder() + QDir::separator());
m_renderWidget->setRenderProfile(project->getRenderProperties());
}
......@@ -2047,18 +2053,19 @@ void MainWindow::connectDocument()
m_normalEditTool->setChecked(true);
connect(m_projectMonitor, &Monitor::durationChanged, this, &MainWindow::slotUpdateProjectDuration);
pCore->monitorManager()->setDocument(project);
trackView->updateProfile(1.0);
if (m_recMonitor) {
m_recMonitor->slotUpdateCaptureFolder(project->projectDataFolder() + QDir::separator());
}
// Init document zone
m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
//TOD REFAC: fix
//trackView->updateProfile(1.0);
// Init document zone
//m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
//Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
slotUpdateMousePosition(0);
//slotUpdateMousePosition(0);
// Update guides info in render widget
slotGuidesUpdated();
//slotGuidesUpdated();
// set tool to select tool
setTrimMode(QStringLiteral());
......
......@@ -187,7 +187,7 @@ QMap<double, QString> BinController::takeGuidesData()
}
return guidesData;
}
//TODO REFACTOR: DELETE
void BinController::createIfNeeded(Mlt::Profile *profile)
{
if (m_binPlaylist) {
......@@ -197,6 +197,30 @@ void BinController::createIfNeeded(Mlt::Profile *profile)
m_binPlaylist->set("id", kPlaylistTrackId);
}
void BinController::loadBinPlaylist(Mlt::Tractor &tractor)
{
destroyBin();
Mlt::Properties retainList((mlt_properties) tractor.get_data("xml_retain"));
if (retainList.is_valid() && retainList.get_data(binPlaylistId().toUtf8().constData())) {
Mlt::Playlist playlist((mlt_playlist) retainList.get_data(binPlaylistId().toUtf8().constData()));
if (playlist.is_valid() && playlist.type() == playlist_type) {
// Load bin clips
initializeBin(playlist);
}
}
// If no Playlist found, create new one
if (!m_binPlaylist) {
m_binPlaylist = new Mlt::Playlist(*tractor.profile());
m_binPlaylist->set("id", kPlaylistTrackId);
}
}
void BinController::setBinPlaylist(Mlt::Tractor *tractor)
{
QString retain = QStringLiteral("xml_retain %1").arg(binPlaylistId());
tractor->set(retain.toUtf8().constData(), m_binPlaylist->get_service(), 0);
}
void BinController::slotStoreFolder(const QString &folderId, const QString &parentId, const QString &oldParentId, const QString &folderName)
{
if (!oldParentId.isEmpty()) {
......
......@@ -81,11 +81,17 @@ public:
/** @brief Clear the bin's playlist */
void destroyBin();
/** @brief Load the Bin's main playlist from an existing tractor */
void loadBinPlaylist(Mlt::Tractor &tractor);
/** @brief Initialize the bin's playlist from MLT's data
* @param playlist The MLT playlist containing our bin's clips
*/
void initializeBin(Mlt::Playlist playlist);
/** @brief Pass the Bin's main playlist to the current project's tractor */
void setBinPlaylist(Mlt::Tractor *tractor);
/** @brief If our bin's playlist does not exist, create a new one */
void createIfNeeded(Mlt::Profile *profile);
......
......@@ -198,10 +198,10 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
doc->m_autosave = new KAutoSaveFile(startFile, doc);
bool ok;
pCore->bin()->setDocument(doc);
QList<QAction *> rulerActions;
//TODO REFAC: Delete this
/*QList<QAction *> rulerActions;
rulerActions << pCore->window()->actionCollection()->action(QStringLiteral("set_render_timeline_zone"));
rulerActions << pCore->window()->actionCollection()->action(QStringLiteral("unset_render_timeline_zone"));
//TODO Delete this
m_trackView = new Timeline(doc, pCore->window()->kdenliveCategoryMap.value(QStringLiteral("timeline"))->actions(), rulerActions, &ok, pCore->window());
// Set default target tracks to upper audio / lower video tracks
m_trackView->audioTarget = projectTracks.y() > 0 ? projectTracks.y() : -1;
......@@ -209,19 +209,20 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
connect(m_trackView->projectView(), SIGNAL(importPlaylistClips(ItemInfo, QString, QUndoCommand *)), pCore->bin(), SLOT(slotExpandUrl(ItemInfo, QString, QUndoCommand *)), Qt::DirectConnection);
m_trackView->loadTimeline();
pCore->window()->m_timelineArea->addTab(m_trackView, QIcon::fromTheme(QStringLiteral("kdenlive")), doc->description());
pCore->window()->m_timelineArea->addTab(m_trackView, QIcon::fromTheme(QStringLiteral("kdenlive")), doc->description());*/
//END of things to delete
m_project = doc;
Mlt::Service s(doc->renderer()->getProducer()->parent().get_service());
QScopedPointer<Mlt::Producer> prod(doc->getProjectProducer());
Mlt::Service s(*prod);
Mlt::Tractor t(s);
updateTimeline(t);
if (!ok) {
/*if (!ok) {
// MLT is broken
//pCore->window()->m_timelineArea->setEnabled(false);
//pCore->window()->m_projectList->setEnabled(false);
pCore->window()->slotPreferences(6);
return;
}
}*/
pCore->window()->connectDocument();
bool disabled = m_project->getDocumentProperty(QStringLiteral("disabletimelineeffects")) == QLatin1String("1");
QAction *disableEffects = pCore->window()->actionCollection()->action(QStringLiteral("disable_timeline_effects"));
......@@ -234,7 +235,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
}
emit docOpened(m_project);
//pCore->monitorManager()->activateMonitor(Kdenlive::ClipMonitor);
m_trackView->projectView()->setFocus();
//m_trackView->projectView()->setFocus();
m_lastSave.start();
}
......@@ -300,7 +301,7 @@ bool ProjectManager::saveFileAs(const QString &outputFileName)
}
QUrl url = QUrl::fromLocalFile(outputFileName);
// Save timeline thumbnails
m_trackView->projectView()->saveThumbnails();
//m_trackView->projectView()->saveThumbnails();
m_project->setUrl(url);
// setting up autosave file in ~/.kde/data/stalefiles/kdenlive/
// saved under file name
......@@ -559,15 +560,15 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
rulerActions << pCore->window()->actionCollection()->action(QStringLiteral("set_render_timeline_zone"));
rulerActions << pCore->window()->actionCollection()->action(QStringLiteral("unset_render_timeline_zone"));
rulerActions << pCore->window()->actionCollection()->action(QStringLiteral("clear_render_timeline_zone"));
bool ok;
/*bool ok;
m_trackView = new Timeline(doc, pCore->window()->kdenliveCategoryMap.value(QStringLiteral("timeline"))->actions(), rulerActions, &ok, pCore->window());
connect(m_trackView, &Timeline::startLoadingBin, m_progressDialog, &QProgressDialog::setMaximum, Qt::DirectConnection);
connect(m_trackView, &Timeline::resetUsageCount, pCore->bin(), &Bin::resetUsageCount, Qt::DirectConnection);
connect(m_trackView, &Timeline::loadingBin, m_progressDialog, &QProgressDialog::setValue, Qt::DirectConnection);
connect(m_trackView, &Timeline::loadingBin, m_progressDialog, &QProgressDialog::setValue, Qt::DirectConnection);*/
// Set default target tracks to upper audio / lower video tracks
m_project = doc;
m_trackView->audioTarget = doc->getDocumentProperty(QStringLiteral("audiotargettrack"), QStringLiteral("-1")).toInt();
/*m_trackView->audioTarget = doc->getDocumentProperty(QStringLiteral("audiotargettrack"), QStringLiteral("-1")).toInt();
m_trackView->videoTarget = doc->getDocumentProperty(QStringLiteral("videotargettrack"), QStringLiteral("-1")).toInt();
m_trackView->loadTimeline();
m_trackView->loadGuides(pCore->binController()->takeGuidesData());
......@@ -581,14 +582,14 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
disableEffects->setChecked(disabled);
disableEffects->blockSignals(false);
}
}
Mlt::Service s(doc->renderer()->getProducer()->parent().get_service());
}*/
Mlt::Service s(*doc->getProjectProducer());
Mlt::Tractor t(s);
updateTimeline(t);
emit docOpened(m_project);
pCore->window()->m_timelineArea->setCurrentIndex(pCore->window()->m_timelineArea->addTab(m_trackView, QIcon::fromTheme(QStringLiteral("kdenlive")), m_project->description()));
/*pCore->window()->m_timelineArea->setCurrentIndex(pCore->window()->m_timelineArea->addTab(m_trackView, QIcon::fromTheme(QStringLiteral("kdenlive")), m_project->description()));
if (!ok) {
pCore->window()->m_timelineArea->setEnabled(false);
KMessageBox::sorry(pCore->window(), i18n("Cannot open file %1.\nProject is corrupted.", url.toLocalFile()));
......@@ -596,7 +597,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
newFile(false, true);
return;
}
m_trackView->setDuration(m_trackView->duration());
m_trackView->setDuration(m_trackView->duration());*/
pCore->window()->slotGotProgressInfo(QString(), 100);
pCore->monitorManager()->projectMonitor()->adjustRulerSize(m_timelineWidget->duration() - 1);
......@@ -685,6 +686,8 @@ KRecentFilesAction *ProjectManager::recentFilesAction()
void ProjectManager::slotStartAutoSave()
{
//TODO REFAC: port to new timeline
return;
if (m_lastSave.elapsed() > 300000) {
// If the project was not saved in the last 5 minute, force save
m_autoSaveTimer.stop();
......@@ -733,7 +736,8 @@ QString ProjectManager::projectSceneList(const QString &outputFolder)
void ProjectManager::prepareSave()
{
pCore->binController()->saveDocumentProperties(m_trackView->documentProperties(), m_project->metadata(), m_trackView->projectView()->guidesData());
//TODO REFAC: save target tracks, preview chunks and guides
pCore->binController()->saveDocumentProperties(m_project->documentProperties(), m_project->metadata(), QMap<double, QString>()/*m_trackView->projectView()->guidesData()*/);
pCore->binController()->saveProperty(QStringLiteral("kdenlive:documentnotes"), m_project->documentNotes());
pCore->binController()->saveProperty(QStringLiteral("kdenlive:clipgroups"), m_project->groupsXml());
}
......@@ -853,6 +857,7 @@ void ProjectManager::updateTimeline(Mlt::Tractor tractor) {
if (!m_timelineWidgetLoaded) {
m_timelineWidgetLoaded = true;
qDebug() << "CONSTRUCTING TIMELINEWIDGET";
pCore->binController()->loadBinPlaylist(tractor);
m_timelineWidget = new TimelineWidget(pCore->window()->actionCollection(), pCore->binController(), m_project->commandStack(), pCore->window());
pCore->addTimeline(m_timelineWidget, m_project->url().fileName());
connect(pCore->monitorManager()->projectMonitor(), &Monitor::seekTimeline, m_timelineWidget, &TimelineWidget::seek, Qt::DirectConnection);
......@@ -866,5 +871,6 @@ void ProjectManager::updateTimeline(Mlt::Tractor tractor) {
}
qDebug() << "FILLING TIMELINEWIDGET";
m_timelineWidget->buildFromMelt(tractor);
pCore->binController()->setBinPlaylist(m_timelineWidget->tractor());
m_timelineWidget->setUndoStack(m_project->commandStack());
}
......@@ -128,8 +128,9 @@ void TransitionSettings::dropEvent(QDropEvent *event)
void TransitionSettings::updateProjectFormat()
{
m_tracks = pCore->projectManager()->currentTimeline()->getTracksInfo();
updateTrackList();
//TODO REFAC: get tracks list
//m_tracks = pCore->projectManager()->currentTimeline()->getTracksInfo();
//updateTrackList();
}
void TransitionSettings::updateTimecodeFormat()
......
......@@ -121,8 +121,6 @@ Item {
color: 'lightgray'
opacity: 0.7
anchors.top: parent.top
anchors.topMargin: parent.border.width
anchors.leftMargin: parent.border.width
// + ((isAudio || !settings.timelineShowThumbnails) ? 0 : inThumbnail.width)
width: label.width + 2
height: label.height
......@@ -133,8 +131,8 @@ Item {
anchors {
top: parent.top
left: parent.left
topMargin: parent.border.width + 1
leftMargin: parent.border.width
topMargin: 1
leftMargin: 1
}
color: 'black'
}
......
......@@ -301,6 +301,11 @@ void TimelineWidget::wheelEvent(QWheelEvent *event)
}
}
Mlt::Tractor *TimelineWidget::tractor()
{
return m_model->tractor();
}
bool TimelineWidget::showThumbnails() const
{
return KdenliveSettings::videothumbnails();
......
......@@ -156,6 +156,9 @@ public:
/* @brief Set current item's end point to cursor position
*/
void setOutPoint();
/* @brief Return the project's tractor
*/
Mlt::Tractor *tractor();
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment