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

Fix subtitle selection by keyboard shortcut

parent 5026ce2b
......@@ -788,7 +788,7 @@ int GroupsModel::fromJson(const QJsonObject &o, Fun &undo, Fun &redo)
} else if (leaf == QLatin1String("composition")) {
id = ptr->getCompositionByPosition(trackId, pos);
} else if (leaf == QLatin1String("subtitle")) {
id = ptr->getSubtitleByPosition(pos);
id = ptr->getSubtitleByStartPosition(pos);
} else {
qDebug() << " * * *UNKNOWN ITEM: " << leaf;
}
......
......@@ -356,7 +356,7 @@ int TimelineModel::getCompositionByPosition(int trackId, int position) const
return getTrackById_const(trackId)->getCompositionByPosition(position);
}
int TimelineModel::getSubtitleByPosition(int position) const
int TimelineModel::getSubtitleByStartPosition(int position) const
{
READ_LOCK();
GenTime startTime(position, pCore->getCurrentFps());
......@@ -369,6 +369,19 @@ int TimelineModel::getSubtitleByPosition(int position) const
return -1;
}
int TimelineModel::getSubtitleByPosition(int position) const
{
READ_LOCK();
GenTime startTime(position, pCore->getCurrentFps());
if (m_subtitleModel) {
std::unordered_set<int> sids = m_subtitleModel->getItemsInRange(position, position);
if (!sids.empty()) {
return *sids.begin();
}
}
return -1;
}
int TimelineModel::getTrackPosition(int trackId) const
{
READ_LOCK();
......
......@@ -639,6 +639,9 @@ public:
/* @brief Get a timeline composition id by its starting position or -1 if not found
*/
int getCompositionByPosition(int trackId, int position) const;
/* @brief Get a timeline subtitle id by its starting position or -1 if not found
*/
int getSubtitleByStartPosition(int position) const;
int getSubtitleByPosition(int position) const;
/* @brief Returns a list of all items that are intersect with a given range.
......
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