Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
c8440acf
Commit
c8440acf
authored
Nov 22, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow moving subtitle through subtitle widget
parent
69ca3d75
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
25 deletions
+54
-25
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+16
-0
src/bin/model/subtitlemodel.hpp
src/bin/model/subtitlemodel.hpp
+1
-0
src/dialogs/subtitleedit.cpp
src/dialogs/subtitleedit.cpp
+18
-6
src/timeline2/model/timelinemodel.cpp
src/timeline2/model/timelinemodel.cpp
+3
-16
src/ui/editsub_ui.ui
src/ui/editsub_ui.ui
+16
-3
No files found.
src/bin/model/subtitlemodel.cpp
View file @
c8440acf
...
...
@@ -688,6 +688,22 @@ void SubtitleModel::removeAllSubtitles()
}
}
void
SubtitleModel
::
requestSubtitleMove
(
int
clipId
,
GenTime
position
)
{
GenTime
oldPos
=
getStartPosForId
(
clipId
);
Fun
local_redo
=
[
this
,
clipId
,
position
]()
{
return
moveSubtitle
(
clipId
,
position
,
true
,
true
);
};
Fun
local_undo
=
[
this
,
clipId
,
oldPos
]()
{
return
moveSubtitle
(
clipId
,
oldPos
,
true
,
true
);
};
bool
res
=
local_redo
();
if
(
res
)
{
pCore
->
pushUndo
(
local_undo
,
local_redo
,
i18n
(
"Move subtitle"
));
}
}
bool
SubtitleModel
::
moveSubtitle
(
int
subId
,
GenTime
newPos
,
bool
updateModel
,
bool
updateView
)
{
qDebug
()
<<
"Moving Subtitle"
;
...
...
src/bin/model/subtitlemodel.hpp
View file @
c8440acf
...
...
@@ -103,6 +103,7 @@ public:
@param newPos is new start position of subtitle
*/
bool
moveSubtitle
(
int
subId
,
GenTime
newPos
,
bool
updateModel
,
bool
updateView
);
void
requestSubtitleMove
(
int
clipId
,
GenTime
position
);
/** @brief Function that imports a subtitle file */
void
importSubtitle
(
const
QString
filePath
,
int
offset
=
0
,
bool
externalImport
=
false
);
...
...
src/dialogs/subtitleedit.cpp
View file @
c8440acf
...
...
@@ -65,6 +65,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
buttonIn
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"zone-in"
)));
buttonOut
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"zone-out"
)));
buttonDelete
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)));
buttonLock
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"kdenlive-lock"
)));
auto
*
keyFilter
=
new
ShiftEnterFilter
(
this
);
subText
->
installEventFilter
(
keyFilter
);
connect
(
keyFilter
,
&
ShiftEnterFilter
::
triggerUpdate
,
this
,
&
SubtitleEdit
::
updateSubtitle
);
...
...
@@ -95,15 +96,25 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
if
(
buttonApply
->
isEnabled
())
{
updateSubtitle
();
}
GenTime
duration
=
m_endPos
-
GenTime
(
value
,
pCore
->
getCurrentFps
());
m_model
->
requestResize
(
m_activeSub
,
duration
.
frames
(
pCore
->
getCurrentFps
()),
false
);
if
(
buttonLock
->
isChecked
())
{
// Perform a move instead of a resize
m_model
->
requestSubtitleMove
(
m_activeSub
,
GenTime
(
value
,
pCore
->
getCurrentFps
()));
}
else
{
GenTime
duration
=
m_endPos
-
GenTime
(
value
,
pCore
->
getCurrentFps
());
m_model
->
requestResize
(
m_activeSub
,
duration
.
frames
(
pCore
->
getCurrentFps
()),
false
);
}
});
connect
(
m_endPosition
,
&
TimecodeDisplay
::
timeCodeEditingFinished
,
[
this
]
(
int
value
)
{
if
(
buttonApply
->
isEnabled
())
{
updateSubtitle
();
}
GenTime
duration
=
GenTime
(
value
,
pCore
->
getCurrentFps
())
-
m_startPos
;
m_model
->
requestResize
(
m_activeSub
,
duration
.
frames
(
pCore
->
getCurrentFps
()),
true
);
if
(
buttonLock
->
isChecked
())
{
// Perform a move instead of a resize
m_model
->
requestSubtitleMove
(
m_activeSub
,
GenTime
(
value
,
pCore
->
getCurrentFps
())
-
(
m_endPos
-
m_startPos
));
}
else
{
GenTime
duration
=
GenTime
(
value
,
pCore
->
getCurrentFps
())
-
m_startPos
;
m_model
->
requestResize
(
m_activeSub
,
duration
.
frames
(
pCore
->
getCurrentFps
()),
true
);
}
});
connect
(
m_duration
,
&
TimecodeDisplay
::
timeCodeEditingFinished
,
[
this
]
(
int
value
)
{
if
(
buttonApply
->
isEnabled
())
{
...
...
@@ -113,10 +124,11 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
});
connect
(
buttonAdd
,
&
QToolButton
::
clicked
,
this
,
&
SubtitleEdit
::
addSubtitle
);
connect
(
buttonCut
,
&
QToolButton
::
clicked
,
[
this
]()
{
qDebug
()
<<
"=== READY TO CUT SUB"
;
if
(
m_activeSub
>
-
1
&&
subText
->
hasFocus
())
{
int
pos
=
subText
->
textCursor
().
position
();
qDebug
()
<<
"=== READY TO CUT SUB AT : "
<<
pos
;
if
(
buttonApply
->
isEnabled
())
{
updateSubtitle
();
}
emit
cutSubtitle
(
m_activeSub
,
pos
);
}
});
...
...
src/timeline2/model/timelinemodel.cpp
View file @
c8440acf
...
...
@@ -2236,22 +2236,9 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
Fun
undo_subs
=
[]()
{
return
true
;
};
// Move subtitles
if
(
!
sorted_subtitles
.
empty
())
{
GenTime
deltaTime
(
delta_pos
,
pCore
->
getCurrentFps
());
redo_subs
=
[
this
,
deltaTime
,
sorted_subtitles
,
finalMove
,
updateView
]()
{
for
(
auto
&
item
:
sorted_subtitles
)
{
m_subtitleModel
->
moveSubtitle
(
item
.
first
,
item
.
second
+
deltaTime
,
finalMove
,
updateView
);
}
return
true
;
};
undo_subs
=
[
this
,
sorted_subtitles
,
finalMove
,
updateView
]()
{
for
(
auto
&
item
:
sorted_subtitles
)
{
m_subtitleModel
->
moveSubtitle
(
item
.
first
,
item
.
second
,
finalMove
,
updateView
);
}
return
true
;
};
redo_subs
();
PUSH_LAMBDA
(
redo_subs
,
local_redo
);
PUSH_LAMBDA
(
undo_subs
,
local_undo
);
for
(
auto
&
item
:
sorted_subtitles
)
{
requestSubtitleMove
(
item
.
first
,
item
.
second
.
frames
(
pCore
->
getCurrentFps
())
+
delta_pos
,
updateView
,
finalMove
,
finalMove
,
local_undo
,
local_redo
);
}
}
// Check if there is a track move
...
...
src/ui/editsub_ui.ui
View file @
c8440acf
...
...
@@ -80,9 +80,6 @@
</property>
</widget>
</item>
<item
row=
"3"
column=
"2"
colspan=
"3"
>
<layout
class=
"QHBoxLayout"
name=
"duration_box"
/>
</item>
<item
row=
"4"
column=
"3"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
...
...
@@ -133,6 +130,22 @@
</property>
</widget>
</item>
<item
row=
"3"
column=
"1"
>
<widget
class=
"QToolButton"
name=
"buttonLock"
>
<property
name=
"text"
>
<string>
...
</string>
</property>
<property
name=
"checkable"
>
<bool>
true
</bool>
</property>
<property
name=
"autoRaise"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item
row=
"3"
column=
"2"
colspan=
"3"
>
<layout
class=
"QHBoxLayout"
name=
"duration_box"
/>
</item>
</layout>
</widget>
<resources/>
...
...
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