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

Automatically highlight text for editing when adding a subtitle.

Fixes #938
parent 8e417866
......@@ -3577,6 +3577,11 @@ void TimelineModel::registerSubtitle(int id, GenTime startTime, bool temporary)
}
}
int TimelineModel::positionForIndex(int id)
{
return std::distance(m_allSubtitles.begin(),m_allSubtitles.find(id));
}
void TimelineModel::deregisterSubtitle(int id, bool temporary)
{
Q_ASSERT(m_allSubtitles.count(id) > 0);
......
......@@ -743,6 +743,9 @@ protected:
void registerSubtitle(int id, GenTime startTime, bool temporary = false);
void deregisterSubtitle(int id, bool temporary = false);
/* @brief Returns the index for a subtitle's id (it's position in the list
*/
int positionForIndex(int id);
/* @brief Register a new group. This is a call-back meant to be called from GroupsModel
*/
......
......@@ -15,6 +15,12 @@ Item {
property bool selected
property bool isGrabbed: false
height: subtitleTrack.height
function editText()
{
subtitleBase.textEditBegin = true
}
onStartFrameChanged: {
if (!subtitleClipArea.pressed) {
subtitleClipArea.x = startFrame * root.timeScale
......
......@@ -60,6 +60,11 @@ Rectangle {
}
}
function highlightSub(ix) {
var currentSub = subtitlesRepeater.itemAt(ix)
currentSub.editText()
}
function checkDeletion(itemId) {
if (dragProxy.draggedItem == itemId) {
endDrag()
......
......@@ -4031,6 +4031,10 @@ void TimelineController::addSubtitle(int startframe)
if (local_redo()) {
m_model->requestAddToSelection(id, true);
pCore->pushUndo(local_undo, local_redo, i18n("Add subtitle"));
int index = m_model->positionForIndex(id);
if (index > -1) {
QMetaObject::invokeMethod(m_root, "highlightSub", Qt::QueuedConnection, Q_ARG(QVariant, index));
}
}
}
......
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