diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp index 85c4f8f664eef36e520caad132330d04c9b31bcd..07b0a1492c74367d6df0ffc8c5fdba9f557ff403 100644 --- a/src/monitor/monitor.cpp +++ b/src/monitor/monitor.cpp @@ -774,14 +774,60 @@ void Monitor::slotLoadClipZone(const QPoint &zone) void Monitor::slotSetZoneStart() { - m_glMonitor->getControllerProxy()->setZoneIn(m_glMonitor->getCurrentPos()); - checkOverlay(); + QPoint oldZone = m_glMonitor->getControllerProxy()->zone(); + int currentIn = m_glMonitor->getCurrentPos(); + int updatedZoneOut = -1; + if (currentIn > oldZone.y()) { + updatedZoneOut = qMin(m_glMonitor->duration(), currentIn + (oldZone.y() - oldZone.x())); + } + + Fun undo_zone = [this, oldZone, updatedZoneOut]() { + m_glMonitor->getControllerProxy()->setZoneIn(oldZone.x()); + if (updatedZoneOut > -1) { + m_glMonitor->getControllerProxy()->setZoneOut(oldZone.y()); + } + checkOverlay(); + return true; + }; + Fun redo_zone = [this, currentIn, updatedZoneOut]() { + if (updatedZoneOut > -1) { + m_glMonitor->getControllerProxy()->setZoneOut(updatedZoneOut); + } + m_glMonitor->getControllerProxy()->setZoneIn(currentIn); + checkOverlay(); + return true; + }; + redo_zone(); + pCore->pushUndo(undo_zone, redo_zone, i18n("Set Zone")); } void Monitor::slotSetZoneEnd() { - m_glMonitor->getControllerProxy()->setZoneOut(m_glMonitor->getCurrentPos() + 1); - checkOverlay(); + QPoint oldZone = m_glMonitor->getControllerProxy()->zone(); + int currentOut = m_glMonitor->getCurrentPos() + 1; + int updatedZoneIn = -1; + if (currentOut < oldZone.x()) { + updatedZoneIn = qMax(0, currentOut - (oldZone.y() - oldZone.x())); + } + Fun undo_zone = [this, oldZone, updatedZoneIn]() { + m_glMonitor->getControllerProxy()->setZoneOut(oldZone.y()); + if (updatedZoneIn > -1) { + m_glMonitor->getControllerProxy()->setZoneIn(oldZone.x()); + } + checkOverlay(); + return true; + }; + + Fun redo_zone = [this, currentOut, updatedZoneIn]() { + if (updatedZoneIn > -1) { + m_glMonitor->getControllerProxy()->setZoneIn(updatedZoneIn); + } + m_glMonitor->getControllerProxy()->setZoneOut(currentOut); + checkOverlay(); + return true; + }; + redo_zone(); + pCore->pushUndo(undo_zone, redo_zone, i18n("Set Zone")); } // virtual diff --git a/src/monitor/monitorproxy.cpp b/src/monitor/monitorproxy.cpp index 8075e1ab7f36d4793355c2cd501f8bbe6cf247d9..6e324f1ec3b3dd6cd93e2bf70c4bb68ac19e8204 100644 --- a/src/monitor/monitorproxy.cpp +++ b/src/monitor/monitorproxy.cpp @@ -140,13 +140,6 @@ void MonitorProxy::setZoneIn(int pos) if (m_zoneIn > 0) { emit removeSnap(m_zoneIn); } - if (pos > m_zoneOut) { - if (m_zoneOut > 0) { - emit removeSnap(m_zoneOut - 1); - } - m_zoneOut = qMin(q->duration(), pos + (m_zoneOut - m_zoneIn)); - emit addSnap(m_zoneOut - 1); - } m_zoneIn = pos; if (pos > 0) { emit addSnap(pos); @@ -160,13 +153,6 @@ void MonitorProxy::setZoneOut(int pos) if (m_zoneOut > 0) { emit removeSnap(m_zoneOut - 1); } - if (pos < m_zoneIn) { - if (m_zoneIn > 0) { - emit removeSnap(m_zoneIn); - } - m_zoneIn = qMax(0, pos - (m_zoneOut - m_zoneIn)); - emit addSnap(m_zoneIn); - } m_zoneOut = pos; if (pos > 0) { emit addSnap(m_zoneOut - 1); diff --git a/src/timeline2/view/timelinecontroller.cpp b/src/timeline2/view/timelinecontroller.cpp index 072b30b72aec6b5e9118f82cad5373ad26315b70..d02f35e7636ce372c87275d239d6dc670d48daa0 100644 --- a/src/timeline2/view/timelinecontroller.cpp +++ b/src/timeline2/view/timelinecontroller.cpp @@ -1338,8 +1338,6 @@ void TimelineController::updateZone(const QPoint oldZone, const QPoint newZone, emit zoneMoved(m_zone); return; } - std::function undo = []() { return true; }; - std::function redo = []() { return true; }; Fun undo_zone = [this, oldZone]() { setZone(oldZone, false); return true; @@ -1349,8 +1347,7 @@ void TimelineController::updateZone(const QPoint oldZone, const QPoint newZone, return true; }; redo_zone(); - UPDATE_UNDO_REDO_NOLOCK(redo_zone, undo_zone, undo, redo); - pCore->pushUndo(undo, redo, i18n("Set Zone")); + pCore->pushUndo(undo_zone, redo_zone, i18n("Set Zone")); } void TimelineController::setZoneIn(int inPoint)