Commit 946c9e91 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

When editing a title clip, hide it from timeline so that it doesn't appear on background frame.

Fixes #805
parent 5ce4e575
Pipeline #37360 passed with stage
in 26 minutes and 20 seconds
......@@ -3656,6 +3656,9 @@ void Bin::showTitleWidget(const std::shared_ptr<ProjectClip> &clip)
QString path = clip->getProducerProperty(QStringLiteral("resource"));
QDir titleFolder(m_doc->projectDataFolder() + QStringLiteral("/titles"));
titleFolder.mkpath(QStringLiteral("."));
QList<int> clips = clip->timelineInstances();
// Temporarily hide this title clip in timeline so that it does not appear when requesting background frame
pCore->temporaryUnplug(clips, true);
TitleWidget dia_ui(QUrl(), m_doc->timecode(), titleFolder.absolutePath(), pCore->monitorManager()->projectMonitor(), pCore->window());
QDomDocument doc;
QString xmldata = clip->getProducerProperty(QStringLiteral("xmldata"));
......@@ -3666,8 +3669,9 @@ void Bin::showTitleWidget(const std::shared_ptr<ProjectClip> &clip)
} else {
doc.setContent(xmldata);
}
dia_ui.setXml(doc, clip->AbstractProjectItem::clipId());
dia_ui.setXml(doc, clip->clipId());
if (dia_ui.exec() == QDialog::Accepted) {
pCore->temporaryUnplug(clips, false);
QMap<QString, QString> newprops;
newprops.insert(QStringLiteral("xmldata"), dia_ui.xml().toString());
if (dia_ui.duration() != clip->duration().frames(pCore->getCurrentFps())) {
......@@ -3696,6 +3700,8 @@ void Bin::showTitleWidget(const std::shared_ptr<ProjectClip> &clip)
}
}
slotEditClipCommand(clip->AbstractProjectItem::clipId(), clip->currentProperties(newprops), newprops);
} else {
pCore->temporaryUnplug(clips, false);
}
}
......
......@@ -925,3 +925,8 @@ void Core::addGuides(QList <int> guides)
}
pCore->currentDoc()->getGuideModel()->addMarkers(markers);
}
void Core::temporaryUnplug(QList<int> clipIds, bool hide)
{
pCore->window()->getMainTimeline()->controller()->temporaryUnplug(clipIds, hide);
}
......@@ -227,6 +227,9 @@ public:
int audioChannels();
/** @brief Add guides in the project. */
void addGuides(QList <int> guides);
/** @brief Temporarily un/plug a list of clips in timeline. */
void temporaryUnplug(QList<int> clipIds, bool hide);
KSharedDataCache audioThumbCache;
private:
......
......@@ -266,6 +266,35 @@ bool TrackModel::requestClipInsertion(int clipId, int position, bool updateView,
return false;
}
void TrackModel::temporaryUnplugClip(int clipId)
{
QWriteLocker locker(&m_lock);
int clip_position = m_allClips[clipId]->getPosition();
auto clip_loc = getClipIndexAt(clip_position);
int target_track = clip_loc.first;
int target_clip = clip_loc.second;
// lock MLT playlist so that we don't end up with invalid frames in monitor
m_playlists[target_track].lock();
Q_ASSERT(target_clip < m_playlists[target_track].count());
Q_ASSERT(!m_playlists[target_track].is_blank(target_clip));
std::unique_ptr<Mlt::Producer> prod(m_playlists[target_track].replace_with_blank(target_clip));
m_playlists[target_track].unlock();
}
void TrackModel::temporaryReplugClip(int cid)
{
QWriteLocker locker(&m_lock);
int clip_position = m_allClips[cid]->getPosition();
int target_track = m_allClips[cid]->getSubPlaylistIndex();
m_playlists[target_track].lock();
if (auto ptr = m_parent.lock()) {
std::shared_ptr<ClipModel> clip = ptr->getClipPtr(cid);
m_playlists[target_track].insert_at(clip_position, *clip, 1);
}
m_playlists[target_track].unlock();
}
void TrackModel::replugClip(int clipId)
{
QWriteLocker locker(&m_lock);
......
......@@ -254,6 +254,8 @@ protected:
/* @brief This function removes the clip from the mlt object, and then insert it back in the same spot again.
* This is used when some properties of the clip have changed, and we need this to refresh it */
void replugClip(int clipId);
void temporaryReplugClip(int cid);
void temporaryUnplugClip(int clipId);
int trackDuration() const;
......
......@@ -3676,3 +3676,18 @@ void TimelineController::addTracks(int videoTracks, int audioTracks)
undo();
}
}
void TimelineController::temporaryUnplug(QList<int> clipIds, bool hide)
{
for (auto &cid : clipIds) {
int tid = m_model->getItemTrackId(cid);
if (tid == -1) {
continue;
}
if (hide) {
m_model->getTrackById_const(tid)->temporaryUnplugClip(cid);
} else {
m_model->getTrackById_const(tid)->temporaryReplugClip(cid);
}
}
}
......@@ -558,6 +558,8 @@ public:
void addTracks(int videoTracks, int audioTracks);
/** @brief Get in/out of currently selected items */
QPoint selectionInOut() const;
/** @brief Temporarily un/plug a list of clips in timeline. */
void temporaryUnplug(QList<int> clipIds, bool hide);
public slots:
void resetView();
......
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