Commit 3ed0dbf1 authored by Julius Künzel's avatar Julius Künzel
Browse files

Invalidate preview render on subtitle actions

BUG: 435692

Related to #973
parent 5511f780
Pipeline #61795 skipped
......@@ -329,12 +329,16 @@ bool SubtitleModel::addSubtitle(GenTime start, GenTime end, const QString str, F
int id = TimelineModel::getNextId();
Fun local_redo = [this, id, start, end, str, updateFilter]() {
addSubtitle(id, start, end, str, false, updateFilter);
pCore->refreshProjectRange({start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())});
QPair<int, int> range = {start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
};
Fun local_undo = [this, id, start, end, updateFilter]() {
removeSubtitle(id, false, updateFilter);
pCore->refreshProjectRange({start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())});
QPair<int, int> range = {start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
};
local_redo();
......@@ -464,12 +468,16 @@ bool SubtitleModel::setText(int id, const QString text)
m_subtitleList[start].first = text;
Fun local_redo = [this, start, end, text]() {
editSubtitle(start, text);
pCore->refreshProjectRange({start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())});
QPair<int, int> range = {start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
};
Fun local_undo = [this, start, end, oldText]() {
editSubtitle(start, oldText);
pCore->refreshProjectRange({start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())});
QPair<int, int> range = {start.frames(pCore->getCurrentFps()), end.frames(pCore->getCurrentFps())};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
};
local_redo();
......@@ -669,11 +677,14 @@ bool SubtitleModel::requestResize(int id, int size, bool right, Fun &undo, Fun &
emit dataChanged(index(row), index(row), {EndFrameRole});
if (logUndo) {
emit modelChanged();
QPair<int, int> range;
if (endPos > newEndPos) {
pCore->refreshProjectRange({newEndPos.frames(pCore->getCurrentFps()), endPos.frames(pCore->getCurrentFps())});
range = {newEndPos.frames(pCore->getCurrentFps()), endPos.frames(pCore->getCurrentFps())};
} else {
pCore->refreshProjectRange({endPos.frames(pCore->getCurrentFps()), newEndPos.frames(pCore->getCurrentFps())});
range = {endPos.frames(pCore->getCurrentFps()), newEndPos.frames(pCore->getCurrentFps())};
}
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
}
return true;
};
......@@ -686,11 +697,14 @@ bool SubtitleModel::requestResize(int id, int size, bool right, Fun &undo, Fun &
emit dataChanged(index(row), index(row), {EndFrameRole});
if (logUndo) {
emit modelChanged();
QPair<int, int> range;
if (endPos > newEndPos) {
pCore->refreshProjectRange({newEndPos.frames(pCore->getCurrentFps()), endPos.frames(pCore->getCurrentFps())});
range = {newEndPos.frames(pCore->getCurrentFps()), endPos.frames(pCore->getCurrentFps())};
} else {
pCore->refreshProjectRange({endPos.frames(pCore->getCurrentFps()), newEndPos.frames(pCore->getCurrentFps())});
range = {endPos.frames(pCore->getCurrentFps()), newEndPos.frames(pCore->getCurrentFps())};
}
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
}
return true;
};
......@@ -712,11 +726,14 @@ bool SubtitleModel::requestResize(int id, int size, bool right, Fun &undo, Fun &
emit dataChanged(index(row), index(row), {StartFrameRole});
if (logUndo) {
emit modelChanged();
QPair<int, int> range;
if (startPos > newStartPos) {
pCore->refreshProjectRange({newStartPos.frames(pCore->getCurrentFps()), startPos.frames(pCore->getCurrentFps())});
range = {newStartPos.frames(pCore->getCurrentFps()), startPos.frames(pCore->getCurrentFps())};
} else {
pCore->refreshProjectRange({startPos.frames(pCore->getCurrentFps()), newStartPos.frames(pCore->getCurrentFps())});
range = {startPos.frames(pCore->getCurrentFps()), newStartPos.frames(pCore->getCurrentFps())};
}
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
}
return true;
};
......@@ -731,11 +748,14 @@ bool SubtitleModel::requestResize(int id, int size, bool right, Fun &undo, Fun &
emit dataChanged(index(row), index(row), {StartFrameRole});
if (logUndo) {
emit modelChanged();
QPair<int, int> range;
if (startPos > newStartPos) {
pCore->refreshProjectRange({newStartPos.frames(pCore->getCurrentFps()), startPos.frames(pCore->getCurrentFps())});
range = {newStartPos.frames(pCore->getCurrentFps()), startPos.frames(pCore->getCurrentFps())};
} else {
pCore->refreshProjectRange({startPos.frames(pCore->getCurrentFps()), newStartPos.frames(pCore->getCurrentFps())});
range = {startPos.frames(pCore->getCurrentFps()), newStartPos.frames(pCore->getCurrentFps())};
}
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
}
return true;
};
......@@ -853,11 +873,14 @@ bool SubtitleModel::moveSubtitle(int subId, GenTime newPos, bool updateModel, bo
addSnapPoint(endPos);
if (updateView) {
updateSub(id, {StartFrameRole, EndFrameRole});
QPair<int, int> range;
if (oldPos < newPos) {
pCore->refreshProjectRange({oldPos.frames(pCore->getCurrentFps()), endPos.frames(pCore->getCurrentFps())});
range = {oldPos.frames(pCore->getCurrentFps()), endPos.frames(pCore->getCurrentFps())};
} else {
pCore->refreshProjectRange({newPos.frames(pCore->getCurrentFps()), (oldPos + duration).frames(pCore->getCurrentFps())});
range = {newPos.frames(pCore->getCurrentFps()), (oldPos + duration).frames(pCore->getCurrentFps())};
}
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
}
if (updateModel) {
// Trigger update of the subtitle file
......
......@@ -4080,12 +4080,16 @@ void TimelineController::editSubtitle(int startFrame, int endFrame, QString newT
auto subtitleModel = pCore->getSubtitleModel();
Fun local_redo = [subtitleModel, startFrame, endFrame, newText]() {
subtitleModel->editSubtitle(GenTime(startFrame, pCore->getCurrentFps()), newText);
pCore->refreshProjectRange({startFrame, endFrame});
QPair<int, int> range = {startFrame, endFrame};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
};
Fun local_undo = [subtitleModel, startFrame, endFrame, oldText]() {
subtitleModel->editSubtitle(GenTime(startFrame, pCore->getCurrentFps()), oldText);
pCore->refreshProjectRange({startFrame, endFrame});
QPair<int, int> range = {startFrame, endFrame};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
};
local_redo();
......@@ -4127,12 +4131,16 @@ void TimelineController::addSubtitle(int startframe, QString text)
}
Fun local_undo = [subtitleModel, id, startframe, endframe]() {
subtitleModel->removeSubtitle(id);
pCore->refreshProjectRange({startframe, endframe});
QPair<int, int> range = {startframe, endframe};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
};
Fun local_redo = [subtitleModel, id, startframe, endframe, text]() {
if (subtitleModel->addSubtitle(id, GenTime(startframe, pCore->getCurrentFps()), GenTime(endframe, pCore->getCurrentFps()), text)) {
pCore->refreshProjectRange({startframe, endframe});
QPair<int, int> range = {startframe, endframe};
pCore->invalidateRange(range);
pCore->refreshProjectRange(range);
return true;
}
return false;
......
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