Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Correctly load composition properties on project opening

parent 4d8f7a36
......@@ -117,8 +117,8 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
qDebug() << "// Warning, this should not happen, transition without id: " << t.get("id") << " = " << t.get("mlt_service");
id = t.get("mlt_service");
}
ok = timeline->requestCompositionInsertion(id, timeline->getTrackIndexFromPosition(t.get_b_track() - 1), t.get_a_track(), t.get_in(),
t.get_length(), compoId, undo, redo);
Mlt::Properties transProps(t.get_properties());
ok = timeline->requestCompositionInsertion(id, timeline->getTrackIndexFromPosition(t.get_b_track() - 1), t.get_a_track(), t.get_in(), t.get_length(), &transProps, compoId, undo, redo);
if (!ok) {
qDebug() << "ERROR : failed to insert composition in track " << t.get_b_track() << ", position" << t.get_in();
break;
......
......@@ -41,13 +41,17 @@ CompositionModel::CompositionModel(std::weak_ptr<TimelineModel> parent, Mlt::Tra
}
}
int CompositionModel::construct(const std::weak_ptr<TimelineModel> &parent, const QString &transitionId, int id)
int CompositionModel::construct(const std::weak_ptr<TimelineModel> &parent, const QString &transitionId, int id, Mlt::Properties *sourceProperties)
{
auto xml = TransitionsRepository::get()->getXml(transitionId);
Mlt::Transition *transition = TransitionsRepository::get()->getTransition(transitionId);
transition->set_in_and_out(0, 0);
std::shared_ptr<CompositionModel> composition(new CompositionModel(parent, transition, id, xml, transitionId));
id = composition->m_id;
if (sourceProperties != nullptr) {
Mlt::Properties transProps(composition->service()->get_properties());
transProps.inherit(*sourceProperties);
}
if (auto ptr = parent.lock()) {
ptr->registerComposition(composition);
} else {
......
......@@ -54,7 +54,7 @@ public:
@param transitionId is the id of the transition to be inserted
@param id Requested id of the clip. Automatic if -1
*/
static int construct(const std::weak_ptr<TimelineModel> &parent, const QString &transitionId, int id = -1);
static int construct(const std::weak_ptr<TimelineModel> &parent, const QString &transitionId, int id = -1, Mlt::Properties *sourceProperties = nullptr);
friend class TrackModel;
friend class TimelineModel;
......
......@@ -1246,7 +1246,7 @@ void TimelineModel::registerComposition(const std::shared_ptr<CompositionModel>
m_groups->createGroupItem(id);
}
bool TimelineModel::requestCompositionInsertion(const QString &transitionId, int trackId, int position, int length, int &id, bool logUndo)
bool TimelineModel::requestCompositionInsertion(const QString &transitionId, int trackId, int position, int length, Mlt::Properties *transProps, int &id, bool logUndo)
{
#ifdef LOGGING
m_logFile << "timeline->requestCompositionInsertion(\"composite\"," << trackId << " ," << position << "," << length << ", dummy_id );" << std::endl;
......@@ -1254,7 +1254,7 @@ bool TimelineModel::requestCompositionInsertion(const QString &transitionId, int
QWriteLocker locker(&m_lock);
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool result = requestCompositionInsertion(transitionId, trackId, -1, position, length, id, undo, redo);
bool result = requestCompositionInsertion(transitionId, trackId, -1, position, length, transProps, id, undo, redo);
if (result && logUndo) {
PUSH_UNDO(undo, redo, i18n("Insert Composition"));
}
......@@ -1262,14 +1262,14 @@ bool TimelineModel::requestCompositionInsertion(const QString &transitionId, int
return result;
}
bool TimelineModel::requestCompositionInsertion(const QString &transitionId, int trackId, int compositionTrack, int position, int length, int &id, Fun &undo,
bool TimelineModel::requestCompositionInsertion(const QString &transitionId, int trackId, int compositionTrack, int position, int length, Mlt::Properties *transProps, int &id, Fun &undo,
Fun &redo)
{
qDebug() << "Inserting compo track" << trackId << "pos" << position << "length" << length;
int compositionId = TimelineModel::getNextId();
id = compositionId;
Fun local_undo = deregisterComposition_lambda(compositionId);
CompositionModel::construct(shared_from_this(), transitionId, compositionId);
CompositionModel::construct(shared_from_this(), transitionId, compositionId, transProps);
auto composition = m_allCompositions[compositionId];
Fun local_redo = [composition, this]() {
// We capture a shared_ptr to the composition, which means that as long as this undo object lives, the composition object is not deleted. To insert it
......
......@@ -455,9 +455,9 @@ public:
@param id return parameter of the id of the inserted composition
@param logUndo if set to false, no undo object is stored
*/
bool requestCompositionInsertion(const QString &transitionId, int trackId, int position, int length, int &id, bool logUndo = true);
bool requestCompositionInsertion(const QString &transitionId, int trackId, int position, int length, Mlt::Properties *transProps, int &id, bool logUndo = true);
/* Same function, but accumulates undo and redo*/
bool requestCompositionInsertion(const QString &transitionId, int trackId, int compositionTrack, int position, int length, int &id, Fun &undo, Fun &redo);
bool requestCompositionInsertion(const QString &transitionId, int trackId, int compositionTrack, int position, int length, Mlt::Properties *transProps, int &id, Fun &undo, Fun &redo);
/* @brief This function change the global (timeline-wise) enabled state of the effects
It disables/enables track and clip effects (recursively)
......
......@@ -282,7 +282,7 @@ int TimelineController::insertClip(int tid, int position, const QString &data_st
int TimelineController::insertComposition(int tid, int position, const QString &transitionId, bool logUndo)
{
int id;
if (!m_model->requestCompositionInsertion(transitionId, tid, position, 100, id, logUndo)) {
if (!m_model->requestCompositionInsertion(transitionId, tid, position, 100, nullptr, id, logUndo)) {
id = -1;
}
return id;
......
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