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

Fix split effect compare broken

parent 029a0781
Pipeline #9871 passed with stage
in 13 minutes and 22 seconds
......@@ -883,10 +883,14 @@ void MainWindow::slotConnectMonitors()
connect(m_projectMonitor, &Monitor::removeSplitOverlay, this, &MainWindow::removeSplitOverlay, Qt::DirectConnection);
}
void MainWindow::createSplitOverlay(Mlt::Filter *filter)
{
getMainTimeline()->controller()->createSplitOverlay(filter);
m_projectMonitor->activateSplit();
void MainWindow::createSplitOverlay(std::shared_ptr<Mlt::Filter> filter)
{
if (m_assetPanel->effectStackOwner().first == ObjectType::TimelineClip) {
getMainTimeline()->controller()->createSplitOverlay(m_assetPanel->effectStackOwner().second, filter);
m_projectMonitor->activateSplit();
} else {
pCore->displayMessage(i18n("Select a clip to compare effect"), InformationMessage);
}
}
void MainWindow::removeSplitOverlay()
......
......@@ -442,7 +442,7 @@ private slots:
/** @brief Update widget style */
void slotChangeStyle(QAction *a);
/** @brief Create temporary top track to preview an effect */
void createSplitOverlay(Mlt::Filter *filter);
void createSplitOverlay(std::shared_ptr<Mlt::Filter> filter);
void removeSplitOverlay();
/** @brief Create a generator's setup dialog */
void buildGenerator(QAction *action);
......
......@@ -368,7 +368,6 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
Monitor::~Monitor()
{
delete m_splitEffect;
delete m_audioMeterWidget;
delete m_glMonitor;
delete m_videoWidget;
......@@ -1782,7 +1781,7 @@ void Monitor::slotSwitchCompare(bool enable)
// Split scene is already active
return;
}
m_splitEffect = new Mlt::Filter(pCore->getCurrentProfile()->profile(), "frei0r.alphagrad");
m_splitEffect.reset(new Mlt::Filter(pCore->getCurrentProfile()->profile(), "frei0r.alphagrad"));
if ((m_splitEffect != nullptr) && m_splitEffect->is_valid()) {
m_splitEffect->set("0", 0.5); // 0 is the Clip left parameter
m_splitEffect->set("1", 0); // 1 is gradient width
......@@ -1797,15 +1796,13 @@ void Monitor::slotSwitchCompare(bool enable)
}
// Delete temp track
emit removeSplitOverlay();
delete m_splitEffect;
m_splitEffect = nullptr;
m_splitEffect.reset();
loadQmlScene(MonitorSceneDefault);
if (isActive()) {
m_glMonitor->requestRefresh();
} else if (slotActivateMonitor()) {
start();
}
return;
}
if (m_controller == nullptr || !m_controller->hasEffects()) {
......@@ -1827,9 +1824,8 @@ void Monitor::slotSwitchCompare(bool enable)
} else if (m_splitEffect) {
// TODO
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), position());
delete m_splitEffect;
m_splitEffect.reset();
m_splitProducer.reset();
m_splitEffect = nullptr;
loadQmlScene(MonitorSceneDefault);
}
slotActivateMonitor();
......@@ -1837,7 +1833,7 @@ void Monitor::slotSwitchCompare(bool enable)
void Monitor::buildSplitEffect(Mlt::Producer *original)
{
m_splitEffect = new Mlt::Filter(pCore->getCurrentProfile()->profile(), "frei0r.alphagrad");
m_splitEffect.reset(new Mlt::Filter(pCore->getCurrentProfile()->profile(), "frei0r.alphagrad"));
if ((m_splitEffect != nullptr) && m_splitEffect->is_valid()) {
m_splitEffect->set("0", 0.5); // 0 is the Clip left parameter
m_splitEffect->set("1", 0); // 1 is gradient width
......@@ -1850,7 +1846,7 @@ void Monitor::buildSplitEffect(Mlt::Producer *original)
QString splitTransition = TransitionsRepository::get()->getCompositingTransition();
Mlt::Transition t(pCore->getCurrentProfile()->profile(), splitTransition.toUtf8().constData());
if (!t.is_valid()) {
delete m_splitEffect;
m_splitEffect.reset();
pCore->displayMessage(i18n("The cairoblend transition is required for that feature, please install frei0r and restart Kdenlive"), ErrorMessage);
return;
}
......@@ -1874,7 +1870,7 @@ void Monitor::buildSplitEffect(Mlt::Producer *original)
}
trac.set_track(*original, 0);
trac.set_track(*clone.get(), 1);
clone.get()->attach(*m_splitEffect);
clone.get()->attach(*m_splitEffect.get());
t.set("always_active", 1);
trac.plant_transition(t, 0, 1);
delete original;
......
......@@ -188,7 +188,7 @@ private:
QmlManager *m_qmlManager;
std::shared_ptr<SnapModel> m_snaps;
Mlt::Filter *m_splitEffect;
std::shared_ptr<Mlt::Filter> m_splitEffect;
std::shared_ptr<Mlt::Producer> m_splitProducer;
int m_length;
bool m_dragStarted;
......@@ -352,7 +352,7 @@ signals:
void deleteMarker(bool deleteGuide = true);
void seekToPreviousSnap();
void seekToNextSnap();
void createSplitOverlay(Mlt::Filter *);
void createSplitOverlay(std::shared_ptr<Mlt::Filter>);
void removeSplitOverlay();
void acceptRipple(bool);
void switchTrimMode(int);
......
......@@ -672,15 +672,22 @@ void ProjectManager::slotAutoSave()
QString ProjectManager::projectSceneList(const QString &outputFolder)
{
// Disable multitrack view
// Disable multitrack view and overlay
bool isMultiTrack = pCore->monitorManager()->isMultiTrack();
bool hasPreview = pCore->window()->getMainTimeline()->controller()->hasPreviewTrack();
if (isMultiTrack) {
pCore->window()->getMainTimeline()->controller()->slotMultitrackView(false, false);
}
if (hasPreview) {
pCore->window()->getMainTimeline()->controller()->updatePreviewConnection(false);
}
QString scene = pCore->monitorManager()->projectMonitor()->sceneList(outputFolder);
if (isMultiTrack) {
pCore->window()->getMainTimeline()->controller()->slotMultitrackView(true, false);
}
if (hasPreview) {
pCore->window()->getMainTimeline()->controller()->updatePreviewConnection(true);
}
return scene;
}
......
......@@ -157,17 +157,6 @@ Mlt::Tractor *TimelineController::tractor()
return m_model->tractor();
}
int TimelineController::getCurrentItem()
{
// TODO: if selection is empty, return topmost clip under timeline cursor
auto selection = m_model->getCurrentSelection();
if (selection.empty()) {
return -1;
}
// TODO: if selection contains more than 1 clip, return topmost clip under timeline cursor in selection
return *(selection.begin());
}
double TimelineController::scaleFactor() const
{
return m_scale;
......@@ -1275,12 +1264,11 @@ void TimelineController::setHeaderWidth(int width)
KdenliveSettings::setHeaderwidth(width);
}
bool TimelineController::createSplitOverlay(Mlt::Filter *filter)
bool TimelineController::createSplitOverlay(int clipId, std::shared_ptr<Mlt::Filter> filter)
{
if (m_timelinePreview && m_timelinePreview->hasOverlayTrack()) {
return true;
}
int clipId = getCurrentItem();
if (clipId == -1) {
pCore->displayMessage(i18n("Select a clip to compare effect"), InformationMessage, 500);
return false;
......@@ -1303,7 +1291,7 @@ bool TimelineController::createSplitOverlay(Mlt::Filter *filter)
play2.append(*binProd);
trac.set_track(play, 0);
trac.set_track(play2, 1);
play2.attach(*filter);
play2.attach(*filter.get());
QString splitTransition = TransitionsRepository::get()->getCompositingTransition();
Mlt::Transition t(*m_model->m_tractor->profile(), splitTransition.toUtf8().constData());
t.set("always_active", 1);
......@@ -1327,7 +1315,7 @@ bool TimelineController::createSplitOverlay(Mlt::Filter *filter)
void TimelineController::removeSplitOverlay()
{
if (m_timelinePreview && !m_timelinePreview->hasOverlayTrack()) {
if (!m_timelinePreview || !m_timelinePreview->hasOverlayTrack()) {
return;
}
// disconnect
......@@ -1413,6 +1401,22 @@ void TimelineController::initializePreview()
m_disablePreview->blockSignals(false);
}
bool TimelineController::hasPreviewTrack() const
{
return (m_timelinePreview && m_timelinePreview->hasOverlayTrack());
}
void TimelineController::updatePreviewConnection(bool enable)
{
if (m_timelinePreview) {
if (enable) {
m_timelinePreview->reconnectTrack();
} else {
m_timelinePreview->disconnectTrack();
}
}
}
void TimelineController::disablePreview(bool disable)
{
if (disable) {
......
......@@ -408,7 +408,7 @@ public:
void focusItem(int itemId);
/* @brief Create and display a split clip view to compare effect
*/
bool createSplitOverlay(Mlt::Filter *filter);
bool createSplitOverlay(int clipId, std::shared_ptr<Mlt::Filter> filter);
/* @brief Delete the split clip view to compare effect
*/
void removeSplitOverlay();
......@@ -472,6 +472,9 @@ public:
void prepareClose();
/** @brief Check that we don't keep a deleted track id */
void checkTrackDeletion(int selectedTrackIx);
/** @brief Return true if an overlay track is used */
bool hasPreviewTrack() const;
void updatePreviewConnection(bool enable);
public slots:
void resetView();
......@@ -531,7 +534,6 @@ private:
std::shared_ptr<AudioCorrelation> m_audioCorrelator;
QMutex m_metaMutex;
int getCurrentItem();
void initializePreview();
bool darkBackground() const;
......
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