Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
1e93e1da
Commit
1e93e1da
authored
Dec 01, 2020
by
Jean-Baptiste Mardelle
Browse files
Update project duration accordingly when subtitles are added/moved
parent
f1aae681
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
1e93e1da
...
...
@@ -351,6 +351,9 @@ bool SubtitleModel::addSubtitle(int id, GenTime start, GenTime end, const QStrin
endInsertRows
();
addSnapPoint
(
start
);
addSnapPoint
(
end
);
if
(
!
temporary
&&
end
.
frames
(
pCore
->
getCurrentFps
())
>
m_timeline
->
duration
())
{
m_timeline
->
updateDuration
();
}
qDebug
()
<<
"Added to model"
;
if
(
updateFilter
)
{
emit
modelChanged
();
...
...
@@ -721,10 +724,18 @@ bool SubtitleModel::removeSubtitle(int id, bool temporary, bool updateFilter)
int
row
=
m_timeline
->
getSubtitleIndex
(
id
);
m_timeline
->
deregisterSubtitle
(
id
,
temporary
);
beginRemoveRows
(
QModelIndex
(),
row
,
row
);
bool
lastSub
=
false
;
if
(
start
==
m_subtitleList
.
rbegin
()
->
first
)
{
// Check if this is the last subtitle
lastSub
=
true
;
}
m_subtitleList
.
erase
(
start
);
endRemoveRows
();
removeSnapPoint
(
start
);
removeSnapPoint
(
end
);
if
(
lastSub
)
{
m_timeline
->
updateDuration
();
}
if
(
updateFilter
)
{
emit
modelChanged
();
}
...
...
@@ -789,6 +800,10 @@ bool SubtitleModel::moveSubtitle(int subId, GenTime newPos, bool updateModel, bo
if
(
updateModel
)
{
// Trigger update of the subtitle file
emit
modelChanged
();
if
(
newPos
==
m_subtitleList
.
rbegin
()
->
first
)
{
// Check if this is the last subtitle
m_timeline
->
updateDuration
();
}
}
return
true
;
}
...
...
@@ -1009,3 +1024,11 @@ bool SubtitleModel::isSelected(int id) const
{
return
m_selected
.
contains
(
id
);
}
int
SubtitleModel
::
trackDuration
()
const
{
if
(
m_subtitleList
.
empty
())
{
return
0
;
}
return
m_subtitleList
.
rbegin
()
->
second
.
second
.
frames
(
pCore
->
getCurrentFps
());
}
src/bin/model/subtitlemodel.hpp
View file @
1e93e1da
...
...
@@ -130,6 +130,7 @@ public:
int
getNextSub
(
int
id
)
const
;
/** @brief Copy subtitle file to a new path */
void
copySubtitle
(
const
QString
&
path
,
bool
checkOverwrite
);
int
trackDuration
()
const
;
public
slots
:
/** @brief Function that parses through a subtitle file */
...
...
src/timeline2/model/timelinemodel.cpp
View file @
1e93e1da
...
...
@@ -3777,6 +3777,9 @@ void TimelineModel::updateDuration()
auto
track
=
(
*
tck
.
second
);
duration
=
qMax
(
duration
,
track
->
trackDuration
());
}
if
(
m_subtitleModel
)
{
duration
=
qMax
(
duration
,
m_subtitleModel
->
trackDuration
());
}
if
(
duration
!=
current
)
{
// update black track length
m_blackClip
->
set
(
"out"
,
duration
+
TimelineModel
::
seekDuration
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment