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

Fix various monitor refresh issues.

Related to #973 #983
parent d548ace2
Pipeline #55045 skipped
......@@ -1756,7 +1756,7 @@ void Bin::setDocument(KdenliveDoc *project)
// connect(m_itemModel, SIGNAL(updateCurrentItem()), this, SLOT(autoSelect()));
slotInitView(nullptr);
bool binEffectsDisabled = getDocumentProperty(QStringLiteral("disablebineffects")).toInt() == 1;
setBinEffectsEnabled(!binEffectsDisabled);
setBinEffectsEnabled(!binEffectsDisabled, false);
QMap <QString, QString> projectTags = m_doc->getProjectTags();
m_tagsWidget->rebuildTags(projectTags);
rebuildFilters(projectTags);
......@@ -1950,7 +1950,7 @@ void Bin::selectAll()
m_proxyModel->selectAll();
}
void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone)
void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone, bool activateMonitor)
{
if (m_monitor->activeClipId() == clipId) {
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(clipId);
......@@ -1972,14 +1972,16 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone)
}
selectClip(clip);
}
if (frame > -1) {
m_monitor->slotSeek(frame);
} else {
m_monitor->slotActivateMonitor();
}
if (!zone.isNull()) {
m_monitor->slotLoadClipZone(zone);
}
if (activateMonitor) {
if (frame > -1) {
m_monitor->slotSeek(frame);
} else {
m_monitor->slotActivateMonitor();
}
}
}
void Bin::selectProxyModel(const QModelIndex &id)
......@@ -3923,7 +3925,7 @@ void Bin::showSlideshowWidget(const std::shared_ptr<ProjectClip> &clip)
delete dia;
}
void Bin::setBinEffectsEnabled(bool enabled)
void Bin::setBinEffectsEnabled(bool enabled, bool refreshMonitor)
{
QAction *disableEffects = pCore->window()->actionCollection()->action(QStringLiteral("disable_bin_effects"));
if (disableEffects) {
......@@ -3935,7 +3937,7 @@ void Bin::setBinEffectsEnabled(bool enabled)
disableEffects->blockSignals(false);
}
m_itemModel->setBinEffectsEnabled(enabled);
pCore->projectManager()->disableBinEffects(!enabled);
pCore->projectManager()->disableBinEffects(!enabled, refreshMonitor);
}
void Bin::slotRenameItem()
......
......@@ -281,7 +281,7 @@ public:
/** @brief This function change the global enabled state of the bin effects
*/
void setBinEffectsEnabled(bool enabled);
void setBinEffectsEnabled(bool enabled, bool refreshMonitor = true);
void requestAudioThumbs(const QString &id, long duration);
/** @brief Proxy status for the project changed, update. */
......@@ -426,7 +426,7 @@ public slots:
/** @brief Reset all clip usage to 0 */
void resetUsageCount();
/** @brief Select a clip in the Bin from its id. */
void selectClipById(const QString &id, int frame = -1, const QPoint &zone = QPoint());
void selectClipById(const QString &id, int frame = -1, const QPoint &zone = QPoint(), bool activateMonitor = true);
const QString slotAddClipToProject(const QUrl &url);
void droppedUrls(const QList<QUrl> &urls, const QString &folderInfo = QString());
/** @brief Returns the effectstack of a given clip. */
......
......@@ -297,9 +297,9 @@ Bin *Core::bin()
return m_binWidget;
}
void Core::selectBinClip(const QString &clipId, int frame, const QPoint &zone)
void Core::selectBinClip(const QString &clipId, bool activateMonitor, int frame, const QPoint &zone)
{
m_binWidget->selectClipById(clipId, frame, zone);
m_binWidget->selectClipById(clipId, frame, zone, activateMonitor);
}
void Core::selectTimelineItem(int id)
......
......@@ -110,7 +110,7 @@ public:
/** @brief Returns a pointer to the view of the project bin. */
Bin *bin();
/** @brief Select a clip in the Bin from its id. */
void selectBinClip(const QString &id, int frame = -1, const QPoint &zone = QPoint());
void selectBinClip(const QString &id, bool activateMonitor = true, int frame = -1, const QPoint &zone = QPoint());
/** @brief Selects an item in the current timeline (clip, composition, subtitle). */
void selectTimelineItem(int id);
/** @brief Returns a pointer to the model of the project bin. */
......
......@@ -738,7 +738,7 @@ bool LoadJob::commitResult(Fun &undo, Fun &redo)
m_readyCallBack();
if (pCore->projectItemModel()->clipsCount() == 1) {
// Always select first added clip
pCore->selectBinClip(m_clipId);
pCore->selectBinClip(m_clipId, false);
}
UPDATE_UNDO_REDO_NOLOCK(operation, reverse, undo, redo);
}
......
......@@ -3234,7 +3234,7 @@ void MainWindow::slotClipInProjectTree()
} else {
pos = -1;
}
pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), pos, zone);
pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), true, pos, zone);
}
}
......
......@@ -926,6 +926,7 @@ int GLWidget::setProducer(const std::shared_ptr<Mlt::Producer> &producer, bool i
}
if (isActive) {
startConsumer();
m_proxy->resetPosition();
}
m_consumer->set("scrub_audio", 0);
m_proxy->setPosition(position > 0 ? position : m_producer->position());
......@@ -1820,7 +1821,7 @@ void GLWidget::setConsumerProperty(const QString &name, const QString &value)
}
}
void GLWidget::updateScaling()
bool GLWidget::updateScaling()
{
#if LIBMLT_VERSION_INT >= QT_VERSION_CHECK(6,20,0)
int previewHeight = pCore->getCurrentFrameSize().height();
......@@ -1844,7 +1845,11 @@ void GLWidget::updateScaling()
if (pWidth% 2 > 0) {
pWidth ++;
}
m_profileSize = QSize(pWidth, previewHeight);
QSize profileSize(pWidth, previewHeight);
if (profileSize == m_profileSize) {
return false;
}
m_profileSize = profileSize;
if (m_consumer) {
m_consumer->set("width", m_profileSize.width());
m_consumer->set("height", m_profileSize.height());
......@@ -1856,11 +1861,16 @@ void GLWidget::updateScaling()
if (pWidth% 2 > 0) {
pWidth ++;
}
m_profileSize = QSize(pWidth, previewHeight);
QSize profileSize(pWidth, previewHeight);
if (profileSize == m_profileSize) {
return false;
}
m_profileSize = profileSize;
if (m_consumer) {
resizeGL(width(), height());
}
#endif
return true;
}
void GLWidget::switchRuler(bool show)
......
......@@ -160,8 +160,10 @@ public slots:
void releaseAnalyse();
void switchPlay(bool play, double speed = 1.0);
void reloadProfile();
/** @brief Update MLT's consumer scaling */
void updateScaling();
/** @brief Update MLT's consumer scaling
* @returns true is scaling was changed
*/
bool updateScaling();
signals:
void frameDisplayed(const SharedFrame &frame);
......
......@@ -222,7 +222,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
});
connect(manager, &MonitorManager::updatePreviewScaling, this, [this, scalingAction]() {
m_glMonitor->updateScaling();
bool scalingChanged = m_glMonitor->updateScaling();
switch (KdenliveSettings::previewScaling()) {
case 2:
scalingAction->setCurrentIndex(1);
......@@ -240,7 +240,9 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
scalingAction->setCurrentIndex(0);
break;
}
refreshMonitorIfActive();
if (scalingChanged) {
refreshMonitorIfActive();
}
});
scalingAction->setFrame(false);
scalingAction->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
......@@ -1442,6 +1444,16 @@ void Monitor::refreshMonitorIfActive(bool directUpdate)
} else {
m_glMonitor->requestRefresh();
}
} else if (m_glWidget->isFullScreen() || !m_glWidget->visibleRegion().isEmpty()) {
slotActivateMonitor();
if (isActive()) {
m_glMonitor->refresh();
// Monitor was not active, so we activate it, refresh and activate the other monitor once done
m_switchConnection = connect(m_glMonitor, &GLWidget::frameDisplayed, this, [=]() {
m_monitorManager->activateMonitor(m_id == Kdenlive::ClipMonitor ? Kdenlive::ProjectMonitor : Kdenlive::ClipMonitor);
QObject::disconnect( m_switchConnection );
});
}
}
}
......@@ -1659,6 +1671,9 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
m_glMonitor->getControllerProxy()->setAudioThumb(streamIndexes, m_controller->activeStreamChannels());
}
}
if (m_glWidget->isFullScreen() || !m_glWidget->visibleRegion().isEmpty()) {
slotActivateMonitor();
}
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), in);
} else {
qDebug()<<"*************** CONTROLLER NOT READY";
......@@ -1672,8 +1687,11 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
m_glMonitor->getControllerProxy()->setClipProperties(-1, ClipType::Unknown, false, QString());
//m_audioChannels->menuAction()->setVisible(false);
m_streamAction->setVisible(false);
if (m_glWidget->isFullScreen() || !m_glWidget->visibleRegion().isEmpty()) {
slotActivateMonitor();
}
}
if (slotActivateMonitor()) {
if (isActive()) {
start();
}
checkOverlay();
......
......@@ -226,6 +226,7 @@ private:
double m_displayedFps;
QLabel *m_speedLabel;
int m_speedIndex;
QMetaObject::Connection m_switchConnection;
void adjustScrollBars(float horizontal, float vertical);
void loadQmlScene(MonitorSceneType type, QVariant sceneData = QVariant());
......
......@@ -35,7 +35,7 @@
MonitorProxy::MonitorProxy(GLWidget *parent)
: QObject(parent)
, q(parent)
, m_position(0)
, m_position(-1)
, m_zoneIn(0)
, m_zoneOut(-1)
, m_hasAV(false)
......@@ -51,6 +51,11 @@ int MonitorProxy::getPosition() const
return m_position;
}
void MonitorProxy::resetPosition()
{
m_position = -1;
}
int MonitorProxy::rulerHeight() const
{
return q->m_rulerHeight;
......
......@@ -113,6 +113,8 @@ public:
void setRulerHeight(int height);
/** @brief Store a reference to the timecode display */
void setTimeCode(TimecodeDisplay *td);
/** @brief When the producer changes, ensure we reset the stored position*/
void resetPosition();
signals:
void positionChanged(int);
......
......@@ -99,7 +99,7 @@ void NotesWidget::createMarker(QStringList anchors)
}
if (!clipMarkers.isEmpty()) {
const QString &binId = clipMarkers.firstKey();
pCore->selectBinClip(binId, clipMarkers.value(binId).constFirst(), QPoint());
pCore->selectBinClip(binId, true, clipMarkers.value(binId).constFirst(), QPoint());
}
if (!guides.isEmpty()) {
pCore->addGuides(guides);
......@@ -126,7 +126,7 @@ void NotesWidget::mousePressEvent(QMouseEvent *e)
}
if (anchor.contains(QLatin1Char('#'))) {
// That's a Bin Clip reference.
pCore->selectBinClip(anchor.section(QLatin1Char('#'), 0, 0), anchor.section(QLatin1Char('#'), 1).toInt(), QPoint());
pCore->selectBinClip(anchor.section(QLatin1Char('#'), 0, 0), true, anchor.section(QLatin1Char('#'), 1).toInt(), QPoint());
} else {
emit seekProject(anchor.toInt());
}
......
......@@ -773,7 +773,7 @@ void ProjectManager::slotResetConsumers(bool fullReset)
pCore->monitorManager()->resetConsumers(fullReset);
}
void ProjectManager::disableBinEffects(bool disable)
void ProjectManager::disableBinEffects(bool disable, bool refreshMonitor)
{
if (m_project) {
if (disable) {
......@@ -782,8 +782,10 @@ void ProjectManager::disableBinEffects(bool disable)
m_project->setDocumentProperty(QStringLiteral("disablebineffects"), QString());
}
}
pCore->monitorManager()->refreshProjectMonitor();
pCore->monitorManager()->refreshClipMonitor();
if (refreshMonitor) {
pCore->monitorManager()->refreshProjectMonitor();
pCore->monitorManager()->refreshClipMonitor();
}
}
void ProjectManager::slotDisableTimelineEffects(bool disable)
......
......@@ -62,8 +62,11 @@ public:
void doOpenFile(const QUrl &url, KAutoSaveFile *stale);
KRecentFilesAction *recentFilesAction();
void prepareSave();
/** @brief Disable all bin effects in current project */
void disableBinEffects(bool disable);
/** @brief Disable all bin effects in current project
* @param disable if true, all project bin effects will be disabled
* @param refreshMonitor if false, monitors will not be refreshed
*/
void disableBinEffects(bool disable, bool refreshMonitor = true);
/** @brief Returns current project's xml scene */
QString projectSceneList(const QString &outputFolder, const QString overlayData = QString());
/** @brief returns a default hd profile depending on timezone*/
......
......@@ -76,7 +76,7 @@ TimelineWidget *TimelineTabs::getCurrentTimeline() const
void TimelineTabs::connectTimeline(TimelineWidget *timeline)
{
connect(timeline, &TimelineWidget::focusProjectMonitor, pCore->monitorManager(), &MonitorManager::focusProjectMonitor);
connect(timeline, &TimelineWidget::focusProjectMonitor, pCore->monitorManager(), &MonitorManager::focusProjectMonitor, Qt::DirectConnection);
connect(this, &TimelineTabs::audioThumbFormatChanged, timeline->controller(), &TimelineController::audioThumbFormatChanged);
connect(this, &TimelineTabs::showThumbnailsChanged, timeline->controller(), &TimelineController::showThumbnailsChanged);
connect(this, &TimelineTabs::showAudioThumbnailsChanged, timeline->controller(), &TimelineController::showAudioThumbnailsChanged);
......
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