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
38ce0af8
Commit
38ce0af8
authored
Nov 08, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix subtitle resize undo
parent
12a4e8d6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
23 deletions
+73
-23
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+7
-4
src/bin/model/subtitlemodel.hpp
src/bin/model/subtitlemodel.hpp
+1
-1
src/timeline2/view/qml/SubTitle.qml
src/timeline2/view/qml/SubTitle.qml
+56
-11
src/timeline2/view/timelinecontroller.cpp
src/timeline2/view/timelinecontroller.cpp
+8
-6
src/timeline2/view/timelinecontroller.h
src/timeline2/view/timelinecontroller.h
+1
-1
No files found.
src/bin/model/subtitlemodel.cpp
View file @
38ce0af8
...
...
@@ -58,7 +58,6 @@ void SubtitleModel::setup()
connect
(
this
,
&
SubtitleModel
::
rowsRemoved
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
rowsInserted
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
modelReset
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
dataChanged
,
this
,
&
SubtitleModel
::
modelChanged
);
}
std
::
shared_ptr
<
SubtitleModel
>
SubtitleModel
::
getModel
()
...
...
@@ -365,7 +364,7 @@ void SubtitleModel::addSnapPoint(GenTime startpos)
std
::
swap
(
m_regSnaps
,
validSnapModels
);
}
void
SubtitleModel
::
editEndPos
(
GenTime
startPos
,
GenTime
newEndPos
)
void
SubtitleModel
::
editEndPos
(
GenTime
startPos
,
GenTime
newEndPos
,
bool
refreshModel
)
{
qDebug
()
<<
"Changing the sub end timings in model"
;
auto
model
=
getModel
();
...
...
@@ -375,9 +374,12 @@ void SubtitleModel::editEndPos(GenTime startPos, GenTime newEndPos)
}
int
row
=
static_cast
<
int
>
(
std
::
distance
(
model
->
m_subtitleList
.
begin
(),
model
->
m_subtitleList
.
find
(
startPos
)));
model
->
m_subtitleList
[
startPos
].
second
=
newEndPos
;
emit
model
->
dataChanged
(
model
->
index
(
row
),
model
->
index
(
row
),
QVector
<
int
>
()
<<
EndPosRole
);
// Trigger update of the qml view
emit
model
->
dataChanged
(
model
->
index
(
row
),
model
->
index
(
row
),
QVector
<
int
>
()
<<
EndFrameRole
);
if
(
refreshModel
)
{
emit
modelChanged
();
}
qDebug
()
<<
startPos
.
frames
(
pCore
->
getCurrentFps
())
<<
m_subtitleList
[
startPos
].
second
.
frames
(
pCore
->
getCurrentFps
());
return
;
}
void
SubtitleModel
::
editSubtitle
(
GenTime
startPos
,
QString
newSubtitleText
,
GenTime
endPos
)
...
...
@@ -397,6 +399,7 @@ void SubtitleModel::editSubtitle(GenTime startPos, QString newSubtitleText, GenT
model
->
m_subtitleList
[
startPos
].
second
=
endPos
;
qDebug
()
<<
startPos
.
frames
(
pCore
->
getCurrentFps
())
<<
m_subtitleList
[
startPos
].
first
<<
m_subtitleList
[
startPos
].
second
.
frames
(
pCore
->
getCurrentFps
());
emit
model
->
dataChanged
(
model
->
index
(
row
),
model
->
index
(
row
),
QVector
<
int
>
()
<<
SubtitleRole
);
emit
modelChanged
();
return
;
}
...
...
src/bin/model/subtitlemodel.hpp
View file @
38ce0af8
...
...
@@ -72,7 +72,7 @@ public:
@param oldPos is the old position of the end time
@param pos defines the new position of the end time
*/
void
editEndPos
(
GenTime
startPos
,
GenTime
newEndPos
);
void
editEndPos
(
GenTime
startPos
,
GenTime
newEndPos
,
bool
refreshModel
=
true
);
/** @brief Edit subtitle , i.e. text and/or end time
@param startPos is start timing position of subtitles
...
...
src/timeline2/view/qml/SubTitle.qml
View file @
38ce0af8
...
...
@@ -117,21 +117,20 @@ Item {
padding
:
0
}
}
Rectangle
{
Item
{
id
:
leftstart
width
:
2
width
:
root
.
baseUnit
/
2
height
:
subtitleBase
.
height
x
:
model
.
startframe
*
timeScale
;
anchors.top
:
subtitleBase
.
top
anchors.left
:
subtitleBase
.
left
color
:
'
green
'
visible
:
true
MouseArea
{
// Right resize handle to change end timing
id
:
startMouseArea
anchors.fill
:
parent
height
:
parent
.
height
width
:
2
width
:
root
.
baseUnit
/
2
hoverEnabled
:
true
enabled
:
true
property
bool
sizeChanged
:
false
...
...
@@ -155,6 +154,7 @@ Item {
//console.log(subtitleBase.x)
originalDuration
=
subtitleBase
.
width
/
timeScale
console
.
log
(
"
originalDuration
"
,
originalDuration
)
trimIn
.
opacity
=
0
}
onPositionChanged
:
{
if
(
pressed
)
{
...
...
@@ -191,17 +191,34 @@ Item {
timeline
.
moveSubtitle
(
oldStartFrame
/
timeline
.
scaleFactor
,
oldStartFrame
/
timeline
.
scaleFactor
+
delta
,
subtitleBase
.
duration
)
}
}
onEntered
:
{
if
(
!
pressed
)
{
trimIn
.
opacity
=
1
}
}
onExited
:
trimIn
.
opacity
=
0
Rectangle
{
id
:
trimIn
anchors.left
:
parent
.
left
width
:
2
height
:
parent
.
height
color
:
'
lawngreen
'
opacity
:
0
Drag.active
:
startMouseArea
.
drag
.
active
Drag.proposedAction
:
Qt
.
MoveAction
//visible: startMouseArea.pressed
}
}
}
Rectangle
{
Item
{
// end position resize handle
id
:
rightend
width
:
2
width
:
root
.
baseUnit
/
2
height
:
subtitleBase
.
height
x
:
model
.
endframe
*
timeScale
;
anchors.right
:
subtitleBase
.
right
anchors.top
:
subtitleBase
.
top
color
:
'
blue
'
// to distinguish the resize handle
//Drag.active: endMouseArea.drag.active
//Drag.proposedAction: Qt.MoveAction
visible
:
true
...
...
@@ -213,37 +230,65 @@ Item {
hoverEnabled
:
true
enabled
:
true
property
bool
sizeChanged
:
false
property
int
newEnd
:
-
1
property
int
oldMouseX
acceptedButtons
:
Qt
.
LeftButton
cursorShape
:
Qt
.
SizeHorCursor
property
int
newDuration
:
subtitleRoot
.
duration
property
int
originalDuration
drag.target
:
rightend
drag.axis
:
Drag
.
XAxis
//drag.smoothed: false
onPressed
:
{
root
.
autoScrolling
=
false
newDuration
=
subtitleRoot
.
duration
originalDuration
=
subtitleRoot
.
duration
//rightend.anchors.right = undefined
oldMouseX
=
mouseX
trimOut
.
opacity
=
0
}
onPositionChanged
:
{
if
(
pressed
)
{
newEnd
=
Math
.
round
((
mouseX
+
width
)
/
timeScale
)
if
((
mouseX
!=
oldMouseX
&&
duration
>
1
)
||
(
duration
<=
1
&&
mouseX
>
oldMouseX
))
{
sizeChanged
=
true
//duration = subtitleBase.width + (mouseX - oldMouseX)/ timeline.scaleFactor
duration
=
Math
.
round
((
subtitleBase
.
width
/
timeScale
+
(
mouseX
-
oldMouseX
)
/
timeScale
))
newDuration
=
Math
.
round
((
subtitleBase
.
width
/
timeScale
+
(
mouseX
-
oldMouseX
)
/
timeScale
))
// Perform resize without changing model
timeline
.
resizeSubtitle
(
subtitleBase
.
x
/
timeline
.
scaleFactor
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
newDuration
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
subtitleRoot
.
duration
,
false
)
}
}
}
onReleased
:
{
root
.
autoScrolling
=
timeline
.
autoScroll
rightend
.
anchors
.
right
=
subtitleBase
.
right
console
.
log
(
'
GOT RESIZE:
'
,
newDuration
,
'
>
'
,
originalDuration
)
if
(
mouseX
!=
oldMouseX
||
sizeChanged
)
{
timeline
.
resizeSubtitle
(
subtitleBase
.
x
/
timeline
.
scaleFactor
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
duration
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
subtitleBase
.
duration
)
// Restore original size
timeline
.
resizeSubtitle
(
subtitleBase
.
x
/
timeline
.
scaleFactor
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
subtitleRoot
.
duration
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
newDuration
,
false
)
// Perform real resize
timeline
.
resizeSubtitle
(
subtitleBase
.
x
/
timeline
.
scaleFactor
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
newDuration
,
subtitleBase
.
x
/
timeline
.
scaleFactor
+
originalDuration
,
true
)
sizeChanged
=
false
}
}
onEntered
:
{
console
.
log
(
'
ENTER MOUSE END AREA
'
)
if
(
!
pressed
)
{
trimOut
.
opacity
=
1
}
}
onExited
:
trimOut
.
opacity
=
0
Rectangle
{
id
:
trimOut
anchors.right
:
parent
.
right
width
:
2
height
:
parent
.
height
color
:
'
red
'
opacity
:
0
Drag.active
:
endMouseArea
.
drag
.
active
Drag.proposedAction
:
Qt
.
MoveAction
//visible: endMouseArea.pressed
}
}
}
}
src/timeline2/view/timelinecontroller.cpp
View file @
38ce0af8
...
...
@@ -3740,23 +3740,25 @@ void TimelineController::editSubtitle(int startFrame, int endFrame, QString newT
pCore
->
pushUndo
(
local_undo
,
local_redo
,
i18n
(
"Edit subtitle"
));
}
void
TimelineController
::
resizeSubtitle
(
int
startFrame
,
int
endFrame
,
int
oldEndFrame
)
void
TimelineController
::
resizeSubtitle
(
int
startFrame
,
int
endFrame
,
int
oldEndFrame
,
bool
refreshModel
)
{
qDebug
()
<<
"Editing existing subtitle in controller at:"
<<
startFrame
;
auto
subtitleModel
=
pCore
->
projectManager
()
->
current
()
->
getSubtitleModel
();
int
max
=
qMax
(
endFrame
,
oldEndFrame
);
Fun
local_redo
=
[
subtitleModel
,
startFrame
,
endFrame
,
max
]()
{
subtitleModel
->
editEndPos
(
GenTime
(
startFrame
,
pCore
->
getCurrentFps
()),
GenTime
(
endFrame
,
pCore
->
getCurrentFps
()));
Fun
local_redo
=
[
subtitleModel
,
startFrame
,
endFrame
,
max
,
refreshModel
]()
{
subtitleModel
->
editEndPos
(
GenTime
(
startFrame
,
pCore
->
getCurrentFps
()),
GenTime
(
endFrame
,
pCore
->
getCurrentFps
())
,
refreshModel
);
pCore
->
refreshProjectRange
({
startFrame
,
max
});
return
true
;
};
Fun
local_undo
=
[
subtitleModel
,
startFrame
,
oldEndFrame
,
max
]()
{
subtitleModel
->
editEndPos
(
GenTime
(
startFrame
,
pCore
->
getCurrentFps
()),
GenTime
(
oldEndFrame
,
pCore
->
getCurrentFps
()));
Fun
local_undo
=
[
subtitleModel
,
startFrame
,
oldEndFrame
,
max
,
refreshModel
]()
{
subtitleModel
->
editEndPos
(
GenTime
(
startFrame
,
pCore
->
getCurrentFps
()),
GenTime
(
oldEndFrame
,
pCore
->
getCurrentFps
())
,
refreshModel
);
pCore
->
refreshProjectRange
({
startFrame
,
max
});
return
true
;
};
local_redo
();
pCore
->
pushUndo
(
local_undo
,
local_redo
,
i18n
(
"Resize subtitle"
));
if
(
refreshModel
)
{
pCore
->
pushUndo
(
local_undo
,
local_redo
,
i18n
(
"Resize subtitle"
));
}
}
void
TimelineController
::
moveSubtitle
(
int
oldStartFrame
,
int
newStartFrame
,
int
duration
)
...
...
src/timeline2/view/timelinecontroller.h
View file @
38ce0af8
...
...
@@ -569,7 +569,7 @@ public:
/** @brief Edit the subtitle text*/
Q_INVOKABLE
void
editSubtitle
(
int
startFrame
,
int
endFrame
,
QString
newText
,
QString
oldText
);
/** @brief Edit the subtitle end */
Q_INVOKABLE
void
resizeSubtitle
(
int
startFrame
,
int
endFrame
,
int
oldEndFrame
);
Q_INVOKABLE
void
resizeSubtitle
(
int
startFrame
,
int
endFrame
,
int
oldEndFrame
,
bool
refreshModel
);
/** @brief Move position of subtitle start timing */
Q_INVOKABLE
void
moveSubtitle
(
int
oldStartFrame
,
int
newStartFrame
,
int
duration
);
/** @brief Shift subtitle clips without changing the clip duration */
...
...
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