Save/load active track state in project. Make first audio and video track active by default

parent af76fd92
Pipeline #9320 passed with stage
in 15 minutes
...@@ -346,10 +346,10 @@ QDomDocument KdenliveDoc::createEmptyDocument(int videotracks, int audiotracks) ...@@ -346,10 +346,10 @@ QDomDocument KdenliveDoc::createEmptyDocument(int videotracks, int audiotracks)
videoTrack.duration = 0; videoTrack.duration = 0;
tracks.append(videoTrack); tracks.append(videoTrack);
} }
return createEmptyDocument(tracks); return createEmptyDocument(tracks, audiotracks);
} }
QDomDocument KdenliveDoc::createEmptyDocument(const QList<TrackInfo> &tracks) QDomDocument KdenliveDoc::createEmptyDocument(const QList<TrackInfo> &tracks, int audiotracks)
{ {
// Creating new document // Creating new document
QDomDocument doc; QDomDocument doc;
...@@ -361,12 +361,21 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QList<TrackInfo> &tracks) ...@@ -361,12 +361,21 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QList<TrackInfo> &tracks)
Mlt::Tractor tractor(docProfile); Mlt::Tractor tractor(docProfile);
Mlt::Producer bk(docProfile, "color:black"); Mlt::Producer bk(docProfile, "color:black");
tractor.insert_track(bk, 0); tractor.insert_track(bk, 0);
bool firstVideoTrackFound = false;
for (int i = 0; i < tracks.count(); ++i) { for (int i = 0; i < tracks.count(); ++i) {
Mlt::Tractor track(docProfile); Mlt::Tractor track(docProfile);
track.set("kdenlive:track_name", tracks.at(i).trackName.toUtf8().constData()); track.set("kdenlive:track_name", tracks.at(i).trackName.toUtf8().constData());
track.set("kdenlive:trackheight", KdenliveSettings::trackheight()); track.set("kdenlive:trackheight", KdenliveSettings::trackheight());
if (tracks.at(i).type == AudioTrack) { if (tracks.at(i).type == AudioTrack) {
track.set("kdenlive:audio_track", 1); track.set("kdenlive:audio_track", 1);
if (i == audiotracks - 1) {
// top most audio track, make active by default
track.set("kdenlive:timeline_active", 1);
}
} else if (!firstVideoTrackFound) {
firstVideoTrackFound = true;
// bottom video track, make active by default
track.set("kdenlive:timeline_active", 1);
} }
if (tracks.at(i).isLocked) { if (tracks.at(i).isLocked) {
track.set("kdenlive:locked_track", 1); track.set("kdenlive:locked_track", 1);
......
...@@ -189,7 +189,7 @@ private: ...@@ -189,7 +189,7 @@ private:
/** @brief Creates a new project. */ /** @brief Creates a new project. */
QDomDocument createEmptyDocument(int videotracks, int audiotracks); QDomDocument createEmptyDocument(int videotracks, int audiotracks);
QDomDocument createEmptyDocument(const QList<TrackInfo> &tracks); QDomDocument createEmptyDocument(const QList<TrackInfo> &tracks, int audiotracks);
/** @brief Updates the project folder location entry in the kdenlive file dialogs to point to the current project folder. */ /** @brief Updates the project folder location entry in the kdenlive file dialogs to point to the current project folder. */
void updateProjectFolderPlacesEntry(); void updateProjectFolderPlacesEntry();
......
...@@ -63,7 +63,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin ...@@ -63,7 +63,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
QLatin1String("black_track")}; QLatin1String("black_track")};
bool ok = true; bool ok = true;
qDebug() << "//////////////////////\nTrying to construct" << tractor.count() << "tracks.\n////////////////////////////////"; qDebug() << "//////////////////////\nTrying to construct" << tractor.count() << "tracks.\n////////////////////////////////";
// Import master track effects // Import master track effects
for (int i = 0; i < tractor.filter_count(); i++) { for (int i = 0; i < tractor.filter_count(); i++) {
std::unique_ptr<Mlt::Filter> filter(tractor.filter(i)); std::unique_ptr<Mlt::Filter> filter(tractor.filter(i));
...@@ -71,7 +71,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin ...@@ -71,7 +71,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
timeline->tractor()->attach(*filter.get()); timeline->tractor()->attach(*filter.get());
} }
} }
QList <int> videoTracksIndexes; QList <int> videoTracksIndexes;
// Black track index // Black track index
videoTracksIndexes << 0; videoTracksIndexes << 0;
...@@ -99,6 +99,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin ...@@ -99,6 +99,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
ok = ok && constructTrackFromMelt(timeline, tid, local_tractor, binIdCorresp, undo, redo, audioTrack, progressDialog); ok = ok && constructTrackFromMelt(timeline, tid, local_tractor, binIdCorresp, undo, redo, audioTrack, progressDialog);
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:thumbs_format"), track->get("kdenlive:thumbs_format")); timeline->setTrackProperty(tid, QStringLiteral("kdenlive:thumbs_format"), track->get("kdenlive:thumbs_format"));
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:audio_rec"), track->get("kdenlive:audio_rec")); timeline->setTrackProperty(tid, QStringLiteral("kdenlive:audio_rec"), track->get("kdenlive:audio_rec"));
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:timeline_active"), track->get("kdenlive:timeline_active"));
if (lockState > 0) { if (lockState > 0) {
timeline->setTrackLockedState(tid, true); timeline->setTrackLockedState(tid, true);
} }
...@@ -123,6 +124,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin ...@@ -123,6 +124,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
ok = ok && constructTrackFromMelt(timeline, tid, local_playlist, binIdCorresp, undo, redo, audioTrack, progressDialog); ok = ok && constructTrackFromMelt(timeline, tid, local_playlist, binIdCorresp, undo, redo, audioTrack, progressDialog);
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:thumbs_format"), local_playlist.get("kdenlive:thumbs_format")); timeline->setTrackProperty(tid, QStringLiteral("kdenlive:thumbs_format"), local_playlist.get("kdenlive:thumbs_format"));
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:audio_rec"), track->get("kdenlive:audio_rec")); timeline->setTrackProperty(tid, QStringLiteral("kdenlive:audio_rec"), track->get("kdenlive:audio_rec"));
timeline->setTrackProperty(tid, QStringLiteral("kdenlive:timeline_active"), track->get("kdenlive:timeline_active"));
if (lockState > 0) { if (lockState > 0) {
timeline->setTrackLockedState(tid, true); timeline->setTrackLockedState(tid, true);
} }
......
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