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
b46a4739
Commit
b46a4739
authored
Apr 07, 2021
by
Jean-Baptiste Mardelle
Browse files
Automatically update subtitle text when changing focus.
Fixes #935
parent
efda2dc3
Changes
2
Show whitespace changes
Inline
Side-by-side
src/dialogs/subtitleedit.cpp
View file @
b46a4739
...
...
@@ -48,6 +48,11 @@ bool ShiftEnterFilter::eventFilter(QObject *obj, QEvent *event)
return
true
;
}
}
if
(
event
->
type
()
==
QEvent
::
FocusOut
)
{
emit
triggerUpdate
();
return
true
;
}
return
QObject
::
eventFilter
(
obj
,
event
);
}
...
...
@@ -69,10 +74,14 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
subText
->
installEventFilter
(
keyFilter
);
connect
(
keyFilter
,
&
ShiftEnterFilter
::
triggerUpdate
,
this
,
&
SubtitleEdit
::
updateSubtitle
);
connect
(
subText
,
&
KTextEdit
::
textChanged
,
[
this
]()
{
if
(
m_activeSub
>
-
1
)
{
buttonApply
->
setEnabled
(
true
);
}
});
connect
(
subText
,
&
KTextEdit
::
cursorPositionChanged
,
[
this
]()
{
if
(
m_activeSub
>
-
1
)
{
buttonCut
->
setEnabled
(
true
);
}
});
m_position
=
new
TimecodeDisplay
(
pCore
->
timecode
(),
this
);
...
...
@@ -91,9 +100,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
spacer
=
new
QSpacerItem
(
1
,
1
,
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
Maximum
);
duration_box
->
addSpacerItem
(
spacer
);
connect
(
m_position
,
&
TimecodeDisplay
::
timeCodeEditingFinished
,
[
this
]
(
int
value
)
{
if
(
buttonApply
->
isEnabled
())
{
updateSubtitle
();
}
if
(
buttonLock
->
isChecked
())
{
// Perform a move instead of a resize
m_model
->
requestSubtitleMove
(
m_activeSub
,
GenTime
(
value
,
pCore
->
getCurrentFps
()));
...
...
@@ -103,9 +110,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
}
});
connect
(
m_endPosition
,
&
TimecodeDisplay
::
timeCodeEditingFinished
,
[
this
]
(
int
value
)
{
if
(
buttonApply
->
isEnabled
())
{
updateSubtitle
();
}
if
(
buttonLock
->
isChecked
())
{
// Perform a move instead of a resize
m_model
->
requestSubtitleMove
(
m_activeSub
,
GenTime
(
value
,
pCore
->
getCurrentFps
())
-
(
m_endPos
-
m_startPos
));
...
...
@@ -115,9 +120,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
}
});
connect
(
m_duration
,
&
TimecodeDisplay
::
timeCodeEditingFinished
,
[
this
]
(
int
value
)
{
if
(
buttonApply
->
isEnabled
())
{
updateSubtitle
();
}
m_model
->
requestResize
(
m_activeSub
,
value
,
true
);
});
connect
(
buttonAdd
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
...
...
@@ -126,9 +129,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
connect
(
buttonCut
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
if
(
m_activeSub
>
-
1
&&
subText
->
hasFocus
())
{
int
pos
=
subText
->
textCursor
().
position
();
if
(
buttonApply
->
isEnabled
())
{
updateSubtitle
();
}
emit
cutSubtitle
(
m_activeSub
,
pos
);
}
});
...
...
@@ -174,6 +175,10 @@ void SubtitleEdit::setModel(std::shared_ptr<SubtitleModel> model)
void
SubtitleEdit
::
updateSubtitle
()
{
if
(
!
buttonApply
->
isEnabled
())
{
return
;
}
buttonApply
->
setEnabled
(
false
);
if
(
m_activeSub
>
-
1
&&
m_model
)
{
QString
txt
=
subText
->
toPlainText
().
trimmed
();
txt
.
replace
(
QLatin1String
(
"
\n\n
"
),
QStringLiteral
(
"
\n
"
));
...
...
src/timeline2/view/qml/SubTitle.qml
View file @
b46a4739
...
...
@@ -44,6 +44,10 @@ Item {
if
(
!
selected
&&
isGrabbed
)
{
//timeline.grabCurrent()
}
if
(
subtitleBase
.
textEditBegin
)
{
// End editing on focus change
subtitleBase
.
textEditBegin
=
false
}
}
function
grabItem
()
{
...
...
Write
Preview
Supports
Markdown
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