Commit 166a9dbd authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Add action to remove all preview zones

parent c3f0470c
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="145" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="146" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="dvd_wizard" />
......@@ -108,6 +108,7 @@
<Action name="stop_prerender_timeline" />
<Action name="set_render_timeline_zone" />
<Action name="unset_render_timeline_zone" />
<Action name="clear_render_timeline_zone"/>
</Menu>
<Action name="resize_timeline_clip_start" />
<Action name="resize_timeline_clip_end" />
......
......@@ -567,7 +567,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
tlMenu->addAction(stopPrevRender);
tlMenu->addAction(actionCollection()->action(QStringLiteral("set_render_timeline_zone")));
tlMenu->addAction(actionCollection()->action(QStringLiteral("unset_render_timeline_zone")));
tlMenu->addAction(actionCollection()->action(QStringLiteral("unset_render_timeline_zone")));
tlMenu->addAction(actionCollection()->action(QStringLiteral("clear_render_timeline_zone")));
// Automatic timeline preview action
QAction *autoRender = new QAction(KoIconUtils::themedIcon(QStringLiteral("view-refresh")), i18n("Automatic Preview"), this);
......@@ -1308,6 +1308,7 @@ void MainWindow::setupActions()
addAction(QStringLiteral("remove_lift"), i18n("Lift Timeline Zone"), this, SLOT(slotLiftZone()), KoIconUtils::themedIcon(QStringLiteral("timeline-lift")), Qt::Key_Z);
addAction(QStringLiteral("set_render_timeline_zone"), i18n("Add Preview Zone"), this, SLOT(slotDefinePreviewRender()), KoIconUtils::themedIcon(QStringLiteral("preview-add-zone")));
addAction(QStringLiteral("unset_render_timeline_zone"), i18n("Unset Preview Zone"), this, SLOT(slotRemovePreviewRender()), KoIconUtils::themedIcon(QStringLiteral("preview-remove-zone")));
addAction(QStringLiteral("clear_render_timeline_zone"), i18n("Clear Preview Zones"), this, SLOT(slotClearPreviewRender()), KoIconUtils::themedIcon(QStringLiteral("preview-remove-zone")));
addAction(QStringLiteral("prerender_timeline_zone"), i18n("Start Preview Render"), this, SLOT(slotPreviewRender()), KoIconUtils::themedIcon(QStringLiteral("preview-render-on")), QKeySequence(Qt::SHIFT + Qt::Key_Return));
addAction(QStringLiteral("stop_prerender_timeline"), i18n("Stop Preview Render"), this, SLOT(slotStopPreviewRender()), KoIconUtils::themedIcon(QStringLiteral("preview-render-off")));
......@@ -2426,6 +2427,13 @@ void MainWindow::slotRemovePreviewRender()
}
}
void MainWindow::slotClearPreviewRender()
{
if (pCore->projectManager()->current()) {
pCore->projectManager()->currentTimeline()->clearPreviewRange();
}
}
void MainWindow::slotSelectTimelineClip()
{
if (pCore->projectManager()->currentTimeline())
......
......@@ -332,6 +332,7 @@ private slots:
void slotStopPreviewRender();
void slotDefinePreviewRender();
void slotRemovePreviewRender();
void slotClearPreviewRender();
void slotSelectTimelineClip();
void slotSelectTimelineTransition();
void slotDeselectTimelineClip();
......
......@@ -533,6 +533,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
QList <QAction*> rulerActions;
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;
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);
......
......@@ -604,6 +604,11 @@ const QPair <QStringList, QStringList> CustomRuler::previewChunks() const
return resultChunks;
}
const QList <int> CustomRuler::getProcessedChunks() const
{
return m_renderingPreviews;
}
const QList <int> CustomRuler::getDirtyChunks() const
{
return m_dirtyRenderingPreviews;
......@@ -614,6 +619,13 @@ bool CustomRuler::hasPreviewRange() const
return (!m_dirtyRenderingPreviews.isEmpty() || !m_renderingPreviews.isEmpty());
}
void CustomRuler::clearChunks()
{
m_renderingPreviews.clear();
m_dirtyRenderingPreviews.clear();
update();
}
QList <int> CustomRuler::addChunks(QList <int> chunks, bool add)
{
qSort(chunks);
......
......@@ -54,8 +54,11 @@ public:
bool updatePreview(int frame, bool rendered = true, bool refresh = false);
/** @brief Returns a list of rendered timeline preview chunks */
const QPair <QStringList, QStringList> previewChunks() const;
/** @brief Returns a list of clean timeline preview chunks (that have been created) */
const QList <int> getProcessedChunks() const;
/** @brief Returns a list of dirty timeline preview chunks (that need to be generated) */
const QList <int> getDirtyChunks() const;
void clearChunks();
QList <int> addChunks(QList <int> chunks, bool add);
/** @brief Returns true if a timeline preview zone has already be defined */
bool hasPreviewRange() const;
......
......@@ -306,6 +306,29 @@ void PreviewManager::doCleanupOldPreviews()
}
}
void PreviewManager::clearPreviewRange()
{
m_previewGatherTimer.stop();
abortPreview();
QList <int> toProcess = m_ruler->getProcessedChunks();
m_tractor->lock();
bool hasPreview = m_previewTrack != NULL;
foreach(int ix, toProcess) {
m_cacheDir.remove(QString("%1.%2").arg(ix).arg(m_extension));
if (!hasPreview)
continue;
int trackIx = m_previewTrack->get_clip_index_at(ix);
if (!m_previewTrack->is_blank(trackIx)) {
Mlt::Producer *prod = m_previewTrack->replace_with_blank(trackIx);
delete prod;
}
}
if (hasPreview)
m_previewTrack->consolidate_blanks();
m_tractor->unlock();
m_ruler->clearChunks();
}
void PreviewManager::addPreviewRange(bool add)
{
QPoint p = m_doc->zone();
......
......@@ -60,6 +60,8 @@ public:
void invalidatePreviews(QList <int> chunks);
/** @brief: user adds current timeline zone to the preview zone. */
void addPreviewRange(bool add);
/** @brief: Remove all existing previews. */
void clearPreviewRange();
/** @brief: stops current rendering process. */
void abortRendering();
/** @brief: rendering parameters have changed, reload them. */
......
......@@ -1974,6 +1974,12 @@ void Timeline::addPreviewRange(bool add)
m_timelinePreview->addPreviewRange(add);
}
void Timeline::clearPreviewRange()
{
if (m_timelinePreview)
m_timelinePreview->clearPreviewRange();
}
void Timeline::storeHeaderSize(int , int )
{
KdenliveSettings::setTimelineheaderwidth(splitter->saveState().toBase64());
......
......@@ -178,6 +178,8 @@ public:
void reloadTrack(ItemInfo info, bool includeLastFrame);
/** @brief Add or remove current timeline zone to preview render zone. */
void addPreviewRange(bool add);
/** @brief Resets all preview render zones. */
void clearPreviewRange();
/** @brief Check if timeline preview profile changed and remove preview files if necessary. */
void updatePreviewSettings(const QString &profile);
/** @brief invalidate timeline preview for visible clips in a track */
......
Supports Markdown
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