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

Fix clip monitor sometimes incorrectly raised when editing subtitle style

parent b2082142
Pipeline #202645 passed with stage
in 10 minutes and 10 seconds
......@@ -4294,7 +4294,7 @@ void Bin::showTitleWidget(const std::shared_ptr<ProjectClip> &clip)
}
slotEditClipCommand(clip->AbstractProjectItem::clipId(), clip->currentProperties(newprops), newprops);
// when edit is triggered from the timeline, project monitor refresh is necessary after an edit is made
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
} else {
pCore->temporaryUnplug(clips, false);
if (res == QDialog::Accepted + 1) {
......
......@@ -67,13 +67,13 @@ void SubtitleModel::setStyle(const QString &style)
Fun redo = [this, style]() {
m_subtitleFilter->set("av.force_style", style.toUtf8().constData());
// Force refresh to show the new style
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
return true;
};
Fun undo = [this, oldStyle]() {
m_subtitleFilter->set("av.force_style", oldStyle.toUtf8().constData());
// Force refresh to show the new style
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
return true;
};
redo();
......
......@@ -527,7 +527,7 @@ QSize Core::getCurrentFrameSize() const
return {getCurrentProfile()->width(), getCurrentProfile()->height()};
}
void Core::requestMonitorRefresh()
void Core::refreshProjectMonitorOnce()
{
if (!m_guiConstructed) return;
m_monitorManager->refreshProjectMonitor();
......@@ -724,7 +724,7 @@ void Core::refreshProjectItem(const ObjectId &id)
break;
case ObjectType::TimelineTrack:
if (m_mainWindow->getCurrentTimeline()->model()->isTrack(id.second)) {
requestMonitorRefresh();
refreshProjectMonitorOnce();
}
break;
case ObjectType::BinClip:
......@@ -737,7 +737,7 @@ void Core::refreshProjectItem(const ObjectId &id)
}
break;
case ObjectType::Master:
requestMonitorRefresh();
refreshProjectMonitorOnce();
break;
default:
qWarning() << "unhandled object type";
......
......@@ -154,8 +154,8 @@ public:
QSize getCurrentFrameSize() const;
/** @brief Returns the frame display size (width x height) of current profile */
QSize getCurrentFrameDisplaySize() const;
/** @brief Request project monitor refresh */
void requestMonitorRefresh();
/** @brief Request project monitor refresh, and restore previously active monitor */
void refreshProjectMonitorOnce();
/** @brief Request project monitor refresh if current position is inside range*/
void refreshProjectRange(QPair<int, int> range);
/** @brief Request project monitor refresh if referenced item is under cursor */
......
......@@ -1473,13 +1473,15 @@ void Monitor::refreshMonitor(bool directUpdate)
m_glMonitor->requestRefresh();
}
} else if (monitorVisible()) {
// Monitor was not active. Check if the other one is visible to re-activate it afterwards
bool otherMonitorVisible = m_id == Kdenlive::ClipMonitor ? m_monitorManager->projectMonitorVisible() : m_monitorManager->clipMonitorVisible();
slotActivateMonitor();
if (isActive()) {
m_glMonitor->refresh();
// Monitor was not active, so we activate it, refresh and activate the other monitor once done
QObject::disconnect(m_switchConnection);
m_switchConnection = connect(m_glMonitor, &GLWidget::frameDisplayed, this, [=]() {
m_monitorManager->activateMonitor(m_id == Kdenlive::ClipMonitor ? Kdenlive::ProjectMonitor : Kdenlive::ClipMonitor);
m_monitorManager->activateMonitor(m_id == Kdenlive::ClipMonitor ? Kdenlive::ProjectMonitor : Kdenlive::ClipMonitor, otherMonitorVisible);
QObject::disconnect(m_switchConnection);
});
}
......
......@@ -157,7 +157,7 @@ void MonitorManager::refreshMonitors()
}
}
bool MonitorManager::activateMonitor(Kdenlive::MonitorId name)
bool MonitorManager::activateMonitor(Kdenlive::MonitorId name, bool raiseMonitor)
{
if ((m_activeMonitor != nullptr) && m_activeMonitor->id() == name) {
return true;
......@@ -177,7 +177,9 @@ bool MonitorManager::activateMonitor(Kdenlive::MonitorId name)
if (m_activeMonitor) {
if (name == Kdenlive::ClipMonitor) {
if (!m_clipMonitor->monitorIsFullScreen()) {
m_clipMonitor->parentWidget()->raise();
if (raiseMonitor) {
m_clipMonitor->parentWidget()->raise();
}
} else {
m_clipMonitor->fixFocus();
}
......@@ -192,7 +194,9 @@ bool MonitorManager::activateMonitor(Kdenlive::MonitorId name)
m_clipMonitor->displayAudioMonitor(true);
} else if (name == Kdenlive::ProjectMonitor) {
if (!m_projectMonitor->monitorIsFullScreen()) {
m_projectMonitor->parentWidget()->raise();
if (raiseMonitor) {
m_projectMonitor->parentWidget()->raise();
}
} else {
m_projectMonitor->fixFocus();
}
......
......@@ -70,8 +70,9 @@ public:
public slots:
/** @brief Activates a monitor.
* @param name name of the monitor to activate */
bool activateMonitor(Kdenlive::MonitorId name);
* @param name name of the monitor to activate
* @param name raiseMonitor, will raise (bring to front) the monitor if true */
bool activateMonitor(Kdenlive::MonitorId name, bool raiseMonitor = true);
void slotPlay();
void slotPause();
void slotPlayZone();
......
......@@ -371,7 +371,7 @@ bool ClipModel::requestSlip(int offset, Fun &undo, Fun &redo, bool logUndo)
if (auto ptr = m_parent.lock()) {
QModelIndex ix = ptr->makeClipIndexFromID(m_id);
ptr->notifyChange(ix, ix, roles);
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
// invalidate timeline preview
if (logUndo && !ptr->getTrackById_const(m_currentTrackId)->isAudioTrack()) {
emit ptr->invalidateZone(m_position, m_position + getPlaytime());
......@@ -395,7 +395,7 @@ bool ClipModel::requestSlip(int offset, Fun &undo, Fun &redo, bool logUndo)
if (auto ptr = m_parent.lock()) {
QModelIndex ix = ptr->makeClipIndexFromID(m_id);
ptr->notifyChange(ix, ix, roles);
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
if (logUndo && !ptr->getTrackById_const(m_currentTrackId)->isAudioTrack()) {
emit ptr->invalidateZone(m_position, m_position + getPlaytime());
}
......
......@@ -537,7 +537,7 @@ void TimelineItemModel::setTrackProperty(int trackId, const QString &name, const
roles.push_back(IsDisabledRole);
if (!track->isAudioTrack()) {
pCore->invalidateItem(ObjectId(ObjectType::TimelineTrack, trackId));
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
updateMultiTrack = true;
}
} else if (name == QLatin1String("kdenlive:timeline_active")) {
......
......@@ -123,7 +123,7 @@ void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
connect(this, &TimelineController::selectionChanged, this, &TimelineController::updateTrimmingMode);
connect(this, &TimelineController::videoTargetChanged, this, &TimelineController::updateVideoTarget);
connect(this, &TimelineController::audioTargetChanged, this, &TimelineController::updateAudioTarget);
connect(m_model.get(), &TimelineItemModel::requestMonitorRefresh, [&]() { pCore->requestMonitorRefresh(); });
connect(m_model.get(), &TimelineItemModel::requestMonitorRefresh, [&]() { pCore->refreshProjectMonitorOnce(); });
connect(m_model.get(), &TimelineModel::durationUpdated, this, &TimelineController::checkDuration);
connect(m_model.get(), &TimelineModel::selectionChanged, this, &TimelineController::selectionChanged);
connect(m_model.get(), &TimelineModel::selectedMixChanged, this, &TimelineController::showMixModel);
......@@ -1362,7 +1362,7 @@ void TimelineController::addAsset(const QVariantMap &data)
void TimelineController::requestRefresh()
{
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
}
void TimelineController::showAsset(int id)
......@@ -1870,7 +1870,7 @@ void TimelineController::refreshItem(int id)
return;
}
if (positionIsInItem(id)) {
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
}
}
......@@ -2780,7 +2780,7 @@ void TimelineController::switchCompositing(bool enable)
}
}
field->unlock();
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
}
void TimelineController::extractZone(QPoint zone, bool liftOnly)
......@@ -4974,7 +4974,7 @@ void TimelineController::switchSubtitleDisable()
Fun local_switch = [this, subtitleModel]() {
subtitleModel->switchDisabled();
emit subtitlesDisabledChanged();
pCore->requestMonitorRefresh();
pCore->refreshProjectMonitorOnce();
return true;
};
local_switch();
......
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