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

Allow resizing unselected subtitles.

FIxes #936
parent da71637d
Pipeline #49388 passed with stage
in 10 minutes and 47 seconds
......@@ -1035,6 +1035,12 @@ int SubtitleModel::getSubtitlePlaytime(int id) const
return m_subtitleList.at(startPos).second.frames(pCore->getCurrentFps()) - startPos.frames(pCore->getCurrentFps());
}
int SubtitleModel::getSubtitleEnd(int id) const
{
GenTime startPos = m_timeline->m_allSubtitles.at(id);
return m_subtitleList.at(startPos).second.frames(pCore->getCurrentFps());
}
void SubtitleModel::setSelected(int id, bool select)
{
if (isLocked()) {
......
......@@ -117,6 +117,7 @@ public:
int getIdForStartPos(GenTime startTime) const;
/** @brief Get the duration of a subtitle by id*/
int getSubtitlePlaytime(int id) const;
int getSubtitleEnd(int id) const;
/** @brief Mark the subtitle item as selected or not*/
void setSelected(int id, bool select);
bool isSelected(int id) const;
......
......@@ -886,8 +886,37 @@ void TimelineController::setInPoint()
if (start != cursorPos) {
int size = start + m_model->getItemPlaytime(cid) - cursorPos;
m_model->requestItemResize(cid, size, false, true, 0, false);
selectionFound = true;
}
}
} else if (m_activeTrack == -2) {
// Subtitle track
auto subtitleModel = pCore->getSubtitleModel();
if (subtitleModel) {
int sid = -1;
std::unordered_set<int> sids = subtitleModel->getItemsInRange(cursorPos, cursorPos);
if (sids.empty()) {
sids = subtitleModel->getItemsInRange(cursorPos, -1);
for (int s : sids) {
if (sid == -1 || subtitleModel->getStartPosForId(s) < subtitleModel->getStartPosForId(sid)) {
sid = s;
}
}
} else {
sid = *sids.begin();
}
if (sid > -1) {
int start = m_model->getItemPosition(sid);
if (start != cursorPos) {
int size = start + m_model->getItemPlaytime(sid) - cursorPos;
m_model->requestItemResize(sid, size, false, true, 0, false);
selectionFound = true;
}
}
}
}
if (!selectionFound) {
pCore->displayMessage(i18n("No clip selected"), ErrorMessage, 500);
}
}
}
......@@ -927,8 +956,37 @@ void TimelineController::setOutPoint()
if (start + m_model->getItemPlaytime(cid) != cursorPos) {
int size = cursorPos - start;
m_model->requestItemResize(cid, size, true, true, 0, false);
selectionFound = true;
}
}
} else if (m_activeTrack == -2) {
// Subtitle track
auto subtitleModel = pCore->getSubtitleModel();
if (subtitleModel) {
int sid = -1;
std::unordered_set<int> sids = subtitleModel->getItemsInRange(cursorPos, cursorPos);
if (sids.empty()) {
sids = subtitleModel->getItemsInRange(0, cursorPos);
for (int s : sids) {
if (sid == -1 || subtitleModel->getSubtitleEnd(s) > subtitleModel->getSubtitleEnd(sid)) {
sid = s;
}
}
} else {
sid = *sids.begin();
}
if (sid > -1) {
int start = m_model->getItemPosition(sid);
if (start + m_model->getItemPlaytime(sid) != cursorPos) {
int size = cursorPos - start;
m_model->requestItemResize(sid, size, true, true, 0, false);
selectionFound = true;
}
}
}
}
if (!selectionFound) {
pCore->displayMessage(i18n("No clip selected"), ErrorMessage, 500);
}
}
}
......
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