Set default target tracks to Audio1 and Video1 tracks, save value in document

Ref: T1961
parent 7b444a78
...@@ -1112,9 +1112,11 @@ void KdenliveDoc::setDocumentProperty(const QString &name, const QString &value) ...@@ -1112,9 +1112,11 @@ void KdenliveDoc::setDocumentProperty(const QString &name, const QString &value)
m_documentProperties[name] = value; m_documentProperties[name] = value;
} }
const QString KdenliveDoc::getDocumentProperty(const QString &name) const const QString KdenliveDoc::getDocumentProperty(const QString &name, const QString &defaultValue) const
{ {
return m_documentProperties.value(name); if (m_documentProperties.contains(name))
return m_documentProperties.value(name);
return defaultValue;
} }
QMap <QString, QString> KdenliveDoc::getRenderProperties() const QMap <QString, QString> KdenliveDoc::getRenderProperties() const
...@@ -1464,7 +1466,7 @@ void KdenliveDoc::slotProcessModifiedClips() ...@@ -1464,7 +1466,7 @@ void KdenliveDoc::slotProcessModifiedClips()
if (m_modifiedClips.isEmpty()) m_modifiedTimer.stop(); if (m_modifiedClips.isEmpty()) m_modifiedTimer.stop();
} }
const QMap <QString, QString> KdenliveDoc::documentProperties() QMap <QString, QString> KdenliveDoc::documentProperties()
{ {
m_documentProperties.insert(QStringLiteral("version"), QString::number(DOCUMENTVERSION)); m_documentProperties.insert(QStringLiteral("version"), QString::number(DOCUMENTVERSION));
m_documentProperties.insert(QStringLiteral("kdenliveversion"), QStringLiteral(KDENLIVE_VERSION)); m_documentProperties.insert(QStringLiteral("kdenliveversion"), QStringLiteral(KDENLIVE_VERSION));
......
...@@ -128,7 +128,7 @@ public: ...@@ -128,7 +128,7 @@ public:
QPoint zone() const; QPoint zone() const;
int setSceneList(); int setSceneList();
void setDocumentProperty(const QString &name, const QString &value); void setDocumentProperty(const QString &name, const QString &value);
const QString getDocumentProperty(const QString &name) const; const QString getDocumentProperty(const QString &name, const QString &defaultValue = QString()) const;
/** @brief Gets the list of renderer properties saved into the document. */ /** @brief Gets the list of renderer properties saved into the document. */
QMap <QString, QString> getRenderProperties() const; QMap <QString, QString> getRenderProperties() const;
...@@ -145,7 +145,7 @@ public: ...@@ -145,7 +145,7 @@ public:
/** @brief Add url to the file watcher so that we monitor changes */ /** @brief Add url to the file watcher so that we monitor changes */
void watchFile(const QUrl &url); void watchFile(const QUrl &url);
/** @brief Get all document properties that need to be saved */ /** @brief Get all document properties that need to be saved */
const QMap <QString, QString> documentProperties(); QMap <QString, QString> documentProperties();
bool useProxy() const; bool useProxy() const;
bool autoGenerateProxy(int width) const; bool autoGenerateProxy(int width) const;
bool autoGenerateImageProxy(int width) const; bool autoGenerateImageProxy(int width) const;
......
...@@ -3287,7 +3287,7 @@ void MainWindow::slotUpdateProxySettings() ...@@ -3287,7 +3287,7 @@ void MainWindow::slotUpdateProxySettings()
void MainWindow::slotArchiveProject() void MainWindow::slotArchiveProject()
{ {
QList <ClipController*> list = pCore->binController()->getControllerList(); QList <ClipController*> list = pCore->binController()->getControllerList();
pCore->binController()->saveDocumentProperties(pCore->projectManager()->current()->documentProperties(), pCore->projectManager()->current()->metadata(), pCore->projectManager()->currentTimeline()->projectView()->guidesData()); pCore->binController()->saveDocumentProperties(pCore->projectManager()->currentTimeline()->documentProperties(), pCore->projectManager()->current()->metadata(), pCore->projectManager()->currentTimeline()->projectView()->guidesData());
QDomDocument doc = pCore->projectManager()->current()->xmlSceneList(m_projectMonitor->sceneList()); QDomDocument doc = pCore->projectManager()->current()->xmlSceneList(m_projectMonitor->sceneList());
QPointer<ArchiveWidget> d = new ArchiveWidget(pCore->projectManager()->current()->url().fileName(), doc, list, pCore->projectManager()->currentTimeline()->projectView()->extractTransitionsLumas(), this); QPointer<ArchiveWidget> d = new ArchiveWidget(pCore->projectManager()->current()->url().fileName(), doc, list, pCore->projectManager()->currentTimeline()->projectView()->extractTransitionsLumas(), this);
if (d->exec()) { if (d->exec()) {
......
...@@ -167,6 +167,9 @@ void ProjectManager::newFile(bool showProjectSettings, bool force) ...@@ -167,6 +167,9 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
bool ok; bool ok;
pCore->bin()->setDocument(doc); pCore->bin()->setDocument(doc);
m_trackView = new Timeline(doc, pCore->window()->kdenliveCategoryMap.value(QStringLiteral("timeline"))->actions(), &ok, pCore->window()); m_trackView = new Timeline(doc, pCore->window()->kdenliveCategoryMap.value(QStringLiteral("timeline"))->actions(), &ok, pCore->window());
// Set default target tracks to upper audio / lower video tracks
m_trackView->audioTarget = projectTracks.y() > 0 ? projectTracks.y() : -1;
m_trackView->videoTarget = projectTracks.x() > 0 ? projectTracks.y() + 1 : -1;
connect(m_trackView->projectView(), SIGNAL(importPlaylistClips(ItemInfo, QUrl, QUndoCommand*)), pCore->bin(), SLOT(slotExpandUrl(ItemInfo, QUrl, QUndoCommand*)), Qt::DirectConnection); connect(m_trackView->projectView(), SIGNAL(importPlaylistClips(ItemInfo, QUrl, QUndoCommand*)), pCore->bin(), SLOT(slotExpandUrl(ItemInfo, QUrl, QUndoCommand*)), Qt::DirectConnection);
m_trackView->loadTimeline(); m_trackView->loadTimeline();
...@@ -503,10 +506,12 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale) ...@@ -503,10 +506,12 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
m_progressDialog->setLabelText(i18n("Loading clips")); m_progressDialog->setLabelText(i18n("Loading clips"));
m_trackView = new Timeline(doc, pCore->window()->kdenliveCategoryMap.value(QStringLiteral("timeline"))->actions(), &ok, pCore->window()); m_trackView = new Timeline(doc, pCore->window()->kdenliveCategoryMap.value(QStringLiteral("timeline"))->actions(), &ok, pCore->window());
connect(m_trackView, &Timeline::startLoadingBin, m_progressDialog, &QProgressDialog::setMaximum, Qt::DirectConnection); 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::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_trackView->audioTarget = doc->getDocumentProperty(QStringLiteral("audiotargettrack"), QStringLiteral("-1")).toInt();
m_trackView->videoTarget = doc->getDocumentProperty(QStringLiteral("videotargettrack"), QStringLiteral("-1")).toInt();
m_trackView->loadTimeline(); m_trackView->loadTimeline();
m_trackView->loadGuides(pCore->binController()->takeGuidesData()); m_trackView->loadGuides(pCore->binController()->takeGuidesData());
connect(m_trackView->projectView(), SIGNAL(importPlaylistClips(ItemInfo, QUrl, QUndoCommand*)), pCore->bin(), SLOT(slotExpandUrl(ItemInfo, QUrl, QUndoCommand*)), Qt::DirectConnection); connect(m_trackView->projectView(), SIGNAL(importPlaylistClips(ItemInfo, QUrl, QUndoCommand*)), pCore->bin(), SLOT(slotExpandUrl(ItemInfo, QUrl, QUndoCommand*)), Qt::DirectConnection);
...@@ -659,7 +664,7 @@ QString ProjectManager::projectSceneList() ...@@ -659,7 +664,7 @@ QString ProjectManager::projectSceneList()
void ProjectManager::prepareSave() void ProjectManager::prepareSave()
{ {
pCore->binController()->saveDocumentProperties(m_project->documentProperties(), m_project->metadata(), m_trackView->projectView()->guidesData()); pCore->binController()->saveDocumentProperties(m_trackView->documentProperties(), m_project->metadata(), m_trackView->projectView()->guidesData());
QString projectNotes = m_project->documentNotes(); QString projectNotes = m_project->documentNotes();
pCore->binController()->saveProperty(QStringLiteral("kdenlive:documentnotes"), projectNotes); pCore->binController()->saveProperty(QStringLiteral("kdenlive:documentnotes"), projectNotes);
QString groupsXml = m_project->groupsXml(); QString groupsXml = m_project->groupsXml();
......
...@@ -164,6 +164,14 @@ void Timeline::loadTimeline() ...@@ -164,6 +164,14 @@ void Timeline::loadTimeline()
slotSetZone(m_doc->zone(), false); slotSetZone(m_doc->zone(), false);
} }
QMap <QString, QString> Timeline::documentProperties()
{
QMap <QString, QString> props = m_doc->documentProperties();
props.insert(QStringLiteral("audiotargettrack"), QString::number(audioTarget));
props.insert(QStringLiteral("videotargettrack"), QString::number(videoTarget));
return props;
}
Track* Timeline::track(int i) Track* Timeline::track(int i)
{ {
if (i < 0 || i >= m_tracks.count()) return NULL; if (i < 0 || i >= m_tracks.count()) return NULL;
......
...@@ -159,6 +159,8 @@ public: ...@@ -159,6 +159,8 @@ public:
bool isLastClip(ItemInfo info); bool isLastClip(ItemInfo info);
/** @brief find lowest video track in timeline. */ /** @brief find lowest video track in timeline. */
int getLowestVideoTrack(); int getLowestVideoTrack();
/** @brief Returns the document properties with some added values from timeline. */
QMap <QString, QString> documentProperties();
protected: protected:
void keyPressEvent(QKeyEvent * event); void keyPressEvent(QKeyEvent * event);
......
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