refresh monitor on subtitle change

fix mouse wheel over subtitle track
parent 20e6804a
Pipeline #39780 canceled with stage
......@@ -394,7 +394,7 @@ void Core::requestMonitorRefresh()
m_monitorManager->refreshProjectMonitor();
}
void Core::refreshProjectRange(QSize range)
void Core::refreshProjectRange(QPair<int, int> range)
{
if (!m_guiConstructed) return;
m_monitorManager->refreshProjectRange(range);
......@@ -682,10 +682,10 @@ std::shared_ptr<ProjectItemModel> Core::projectItemModel()
return m_projectItemModel;
}
void Core::invalidateRange(QSize range)
void Core::invalidateRange(QPair<int, int> range)
{
if (!m_guiConstructed || m_mainWindow->getCurrentTimeline()->loading) return;
m_mainWindow->getCurrentTimeline()->controller()->invalidateZone(range.width(), range.height());
m_mainWindow->getCurrentTimeline()->controller()->invalidateZone(range.first, range.second);
}
void Core::invalidateItem(ObjectId itemId)
......
......@@ -142,7 +142,7 @@ public:
/** @brief Request project monitor refresh */
void requestMonitorRefresh();
/** @brief Request project monitor refresh if current position is inside range*/
void refreshProjectRange(QSize range);
void refreshProjectRange(QPair<int, int> range);
/** @brief Request project monitor refresh if referenced item is under cursor */
void refreshProjectItem(const ObjectId &id);
/** @brief Returns a reference to a monitor (clip or project monitor) */
......@@ -179,7 +179,7 @@ public:
double getClipSpeed(int id) const;
/** @brief Mark an item as invalid for timeline preview */
void invalidateItem(ObjectId itemId);
void invalidateRange(QSize range);
void invalidateRange(QPair<int, int>range);
void prepareShutdown();
/** the keyframe model changed (effect added, deleted, active effect changed), inform timeline */
void updateItemKeyframes(ObjectId id);
......
......@@ -676,7 +676,7 @@ bool EffectStackModel::adjustFadeLength(int duration, bool fromStart, bool audio
pCore->updateItemModel(m_ownerId, QStringLiteral("fadein"));
if (videoFade) {
int min = pCore->getItemPosition(m_ownerId);
QSize range(min, min + qMax(duration, oldDuration));
QPair<int, int> range = {min, min + qMax(duration, oldDuration)};
pCore->refreshProjectRange(range);
if (logUndo) {
pCore->invalidateRange(range);
......@@ -719,7 +719,7 @@ bool EffectStackModel::adjustFadeLength(int duration, bool fromStart, bool audio
pCore->updateItemModel(m_ownerId, QStringLiteral("fadeout"));
if (videoFade) {
int min = pCore->getItemPosition(m_ownerId);
QSize range(min + itemDuration - qMax(duration, oldDuration), min + itemDuration);
QPair<int, int> range = {min + itemDuration - qMax(duration, oldDuration), min + itemDuration};
pCore->refreshProjectRange(range);
if (logUndo) {
pCore->invalidateRange(range);
......
......@@ -3993,10 +3993,6 @@ void MainWindow::slotManageCache()
auto *lay = new QVBoxLayout;
TemporaryData tmp(pCore->currentDoc(), false, this);
connect(&tmp, &TemporaryData::disableProxies, this, &MainWindow::slotDisableProxies);
// TODO refac
/*
connect(&tmp, SIGNAL(disablePreview()), pCore->projectManager()->currentTimeline(), SLOT(invalidateRange()));
*/
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
connect(buttonBox, &QDialogButtonBox::rejected, &d, &QDialog::reject);
lay->addWidget(&tmp);
......
......@@ -104,9 +104,9 @@ void MonitorManager::focusProjectMonitor()
activateMonitor(Kdenlive::ProjectMonitor);
}
void MonitorManager::refreshProjectRange(QSize range)
void MonitorManager::refreshProjectRange(QPair<int, int> range)
{
if (m_projectMonitor->position() >= range.width() && m_projectMonitor->position() <= range.height()) {
if (m_projectMonitor->position() >= range.first && m_projectMonitor->position() <= range.second) {
m_projectMonitor->refreshMonitorIfActive();
}
}
......
......@@ -97,7 +97,7 @@ public slots:
void focusProjectMonitor();
void refreshProjectMonitor();
/** @brief Refresh project monitor if the timeline cursor is inside the range. */
void refreshProjectRange(QSize range);
void refreshProjectRange(QPair<int, int>range);
void refreshClipMonitor();
/** @brief Switch current monitor to fullscreen. */
......
......@@ -186,7 +186,7 @@ Item {
//rightend.anchors.right = subtitleBase.right
if (mouseX != oldStartX && oldStartFrame!= subtitleBase.x) {
console.log("old start frame",oldStartFrame/timeline.scaleFactor, "new frame",oldStartFrame/timeline.scaleFactor + delta)
timeline.moveSubtitle(oldStartFrame/timeline.scaleFactor , oldStartFrame/timeline.scaleFactor + delta)
timeline.moveSubtitle(oldStartFrame/timeline.scaleFactor , oldStartFrame/timeline.scaleFactor + delta, subtitleBase.duration)
}
}
}
......
......@@ -1076,6 +1076,12 @@ Rectangle {
width: tracksContainerArea.width
height: showSubtitles? root.baseUnit * 3 : 0
Repeater { id: subtitlesRepeater; model: subtitleDelegateModel }
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: zoomByWheel(wheel)
cursorShape: dragProxyArea.drag.active ? Qt.ClosedHandCursor : tracksArea.cursorShape
}
}
Item {
id: tracksContainerArea
......
......@@ -3728,16 +3728,20 @@ void TimelineController::editSubtitle(int startFrame, QString text, int endFrame
GenTime startPos(startFrame, pCore->getCurrentFps());
GenTime endPos(endFrame, pCore->getCurrentFps());
subtitleModel->editSubtitle(startPos, text, endPos);
pCore->refreshProjectRange({startFrame, endFrame});
return;
}
void TimelineController::moveSubtitle(int oldStartFrame, int newStartFrame)
void TimelineController::moveSubtitle(int oldStartFrame, int newStartFrame, int duration)
{
qDebug()<<"Moving existing subtitle start position in controller from"<<oldStartFrame<<" to "<<newStartFrame;
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
GenTime oldStartPos(oldStartFrame, pCore->getCurrentFps());
GenTime newStartPos(newStartFrame, pCore->getCurrentFps());
subtitleModel->moveSubtitle(oldStartPos, newStartPos);
int min = qMin(oldStartFrame, newStartFrame);
int max = qMax(oldStartFrame, newStartFrame);
pCore->refreshProjectRange({min, max + duration});
return;
}
......@@ -3752,6 +3756,7 @@ void TimelineController::shiftSubtitle(int oldStartFrame, int newStartFrame, int
subtitleModel->removeSubtitle(oldStartPos); //first delete subtitle at old start position
subtitleModel->addSubtitle(newStartPos, endPos, text); //next, add a new subtitle at new start position
pCore->refreshProjectRange({qMin(oldStartFrame, newStartFrame), endFrame});
}
void TimelineController::addSubtitle()
......@@ -3764,6 +3769,7 @@ void TimelineController::addSubtitle()
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
QString text = "Add Text";
subtitleModel->addSubtitle(start, end, text);
pCore->refreshProjectRange({startframe, endframe});
}
void TimelineController::deleteSubtitle(int frame)
......
......@@ -569,7 +569,7 @@ public:
/** @brief Edit the subtitle text and/or end timings */
Q_INVOKABLE void editSubtitle(int startFrame, QString text, int endFrame);
/** @brief Move position of subtitle start timing */
Q_INVOKABLE void moveSubtitle(int oldStartFrame, int newStartFrame);
Q_INVOKABLE void moveSubtitle(int oldStartFrame, int newStartFrame, int duration);
/** @brief Shift subtitle clips without changing the clip duration */
Q_INVOKABLE void shiftSubtitle(int oldStartFrame, int newStartFrame, int endFrame=0, QString text="");
/** @brief Add subtitle clip at cursor's position in timeline */
......
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