Refresh project monitor on bin effect change

CCBUG: 414366
parent 6070715e
......@@ -509,7 +509,11 @@ void Core::refreshProjectItem(const ObjectId &id)
}
break;
case ObjectType::BinClip:
m_monitorManager->activateMonitor(Kdenlive::ClipMonitor);
m_monitorManager->refreshClipMonitor();
if (m_monitorManager->projectMonitorVisible() && m_mainWindow->getCurrentTimeline()->controller()->refreshIfVisible(id.second)) {
m_monitorManager->refreshTimer.start();
}
break;
case ObjectType::Master:
requestMonitorRefresh();
......
......@@ -1231,6 +1231,12 @@ void Monitor::slotRefreshMonitor(bool visible)
}
}
void Monitor::forceMonitorRefresh()
{
slotActivateMonitor();
m_glMonitor->refresh();
}
void Monitor::refreshMonitorIfActive(bool directUpdate)
{
if (isActive()) {
......
......@@ -316,6 +316,7 @@ public slots:
/** @brief Check current position to show relevant infos in qml view (markers, zone in/out, etc). */
void checkOverlay(int pos = -1);
void refreshMonitorIfActive(bool directUpdate = false) override;
void forceMonitorRefresh();
/** @brief Clear read ahead cache, to ensure up to date audio */
void purgeCache();
......
......@@ -36,6 +36,9 @@ MonitorManager::MonitorManager(QObject *parent)
{
setupActions();
refreshTimer.setSingleShot(true);
refreshTimer.setInterval(200);
connect(&refreshTimer, &QTimer::timeout, this, &MonitorManager::forceProjectMonitorRefresh);
}
Timecode MonitorManager::timecode() const
......@@ -121,6 +124,16 @@ void MonitorManager::refreshClipMonitor()
m_clipMonitor->refreshMonitorIfActive();
}
void MonitorManager::forceProjectMonitorRefresh()
{
m_projectMonitor->forceMonitorRefresh();
}
bool MonitorManager::projectMonitorVisible() const
{
return (m_projectMonitor->isVisible() && !m_projectMonitor->visibleRegion().isEmpty());
}
bool MonitorManager::activateMonitor(Kdenlive::MonitorId name)
{
if ((m_activeMonitor != nullptr) && m_activeMonitor->id() == name) {
......
......@@ -25,6 +25,7 @@
#include "timecode.h"
#include <QDir>
#include <QMutex>
#include <QTimer>
class KdenliveDoc;
class KDualAction;
......@@ -67,6 +68,9 @@ public:
QDir getCacheFolder(CacheType type);
/** @brief Returns true if multitrack view is enabled in project monitor. */
bool isMultiTrack() const;
/** @brief Returns true if the project monitor is visible (and not tabbed under another dock. */
bool projectMonitorVisible() const;
QTimer refreshTimer;
public slots:
......@@ -122,6 +126,8 @@ private slots:
void slotZoomIn();
/** @brief Zoom out active monitor */
void slotZoomOut();
/** @brief Trigger refresh of both monitors */
void forceProjectMonitorRefresh();
private:
/** @brief Make sure 2 monitors cannot be activated simultaneously*/
......
......@@ -2699,3 +2699,22 @@ void TimelineController::showMasterEffects()
emit showItemEffectStack(i18n("Master effects"), m_model->getMasterEffectStackModel(), pCore->getCurrentFrameSize(), false);
}
bool TimelineController::refreshIfVisible(int cid)
{
auto it = m_model->m_allTracks.cbegin();
while (it != m_model->m_allTracks.cend()) {
int target_track = (*it)->getId();
if (m_model->getTrackById_const(target_track)->isAudioTrack() || m_model->getTrackById_const(target_track)->isHidden()) {
++it;
continue;
}
int child = m_model->getClipByPosition(target_track, timelinePosition());
if (child > 0) {
if (m_model->m_allClips[child]->binId().toInt() == cid) {
return true;
}
}
++it;
}
return false;
}
......@@ -477,6 +477,8 @@ public:
void updatePreviewConnection(bool enable);
/** @brief Display project master effects */
Q_INVOKABLE void showMasterEffects();
/** @brief Return true if an instance of this bin clip is currently undet timeline cursor */
bool refreshIfVisible(int cid);
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