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
299cd9e3
Commit
299cd9e3
authored
Nov 19, 2020
by
Jean-Baptiste Mardelle
Browse files
Fix various issues with subtitles (the filter was duplicated on project opening)
parent
87616c7f
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
299cd9e3
...
...
@@ -80,7 +80,7 @@ std::shared_ptr<SubtitleModel> SubtitleModel::getModel()
return
pCore
->
projectManager
()
->
getSubtitleModel
();
}
void
SubtitleModel
::
importSubtitle
(
const
QString
filePath
,
int
offset
)
void
SubtitleModel
::
importSubtitle
(
const
QString
filePath
,
int
offset
,
bool
externalImport
)
{
QString
start
,
end
,
comment
;
QString
timeLine
;
...
...
@@ -244,7 +244,9 @@ void SubtitleModel::importSubtitle(const QString filePath, int offset)
}
assFile
.
close
();
}
jsontoSubtitle
(
toJson
());
if
(
externalImport
)
{
jsontoSubtitle
(
toJson
());
}
}
void
SubtitleModel
::
parseSubtitle
(
const
QString
subPath
)
...
...
@@ -255,7 +257,7 @@ void SubtitleModel::parseSubtitle(const QString subPath)
}
QString
filePath
=
m_subtitleFilter
->
get
(
"av.filename"
);
m_subFilePath
=
filePath
;
importSubtitle
(
filePath
);
importSubtitle
(
filePath
,
0
,
false
);
//jsontoSubtitle(toJson());
}
...
...
src/bin/model/subtitlemodel.hpp
View file @
299cd9e3
...
...
@@ -105,7 +105,7 @@ public:
void
moveSubtitle
(
GenTime
oldPos
,
GenTime
newPos
,
bool
updateModel
,
bool
updateView
);
/** @brief Function that imports a subtitle file */
void
importSubtitle
(
const
QString
filePath
,
int
offset
=
0
);
void
importSubtitle
(
const
QString
filePath
,
int
offset
=
0
,
bool
externalImport
=
false
);
/** @brief Exports the subtitle model to json */
QString
toJson
();
...
...
src/dialogs/subtitleedit.cpp
View file @
299cd9e3
...
...
@@ -77,11 +77,16 @@ void SubtitleEdit::setModel(std::shared_ptr<SubtitleModel> model)
m_activeSub
=
-
1
;
subText
->
setEnabled
(
false
);
buttonApply
->
setEnabled
(
false
);
connect
(
m_model
.
get
(),
&
SubtitleModel
::
dataChanged
,
[
this
](
const
QModelIndex
&
start
,
const
QModelIndex
&
,
const
QVector
<
int
>&
roles
)
{
if
(
m_activeSub
>
-
1
&&
start
.
row
()
==
m_model
->
getRowForId
(
m_activeSub
&&
roles
.
contains
(
SubtitleModel
::
SubtitleRole
)))
{
setActiveSubtitle
(
m_activeSub
);
}
});
if
(
m_model
==
nullptr
)
{
QSignalBlocker
bk
(
subText
);
subText
->
clear
();
}
else
{
connect
(
m_model
.
get
(),
&
SubtitleModel
::
dataChanged
,
[
this
](
const
QModelIndex
&
start
,
const
QModelIndex
&
,
const
QVector
<
int
>&
roles
)
{
if
(
m_activeSub
>
-
1
&&
start
.
row
()
==
m_model
->
getRowForId
(
m_activeSub
)
&&
roles
.
contains
(
SubtitleModel
::
SubtitleRole
))
{
setActiveSubtitle
(
m_activeSub
);
}
});
}
}
void
SubtitleEdit
::
updateSubtitle
()
...
...
src/effects/effectstack/model/effectstackmodel.cpp
View file @
299cd9e3
...
...
@@ -919,13 +919,12 @@ void EffectStackModel::importEffects(const std::weak_ptr<Mlt::Service> &service,
std
::
unique_ptr
<
Mlt
::
Filter
>
filter
(
ptr
->
filter
(
i
));
if
(
filter
->
get_int
(
"internal_added"
)
>
0
&&
m_ownerId
.
first
!=
ObjectType
::
TimelineTrack
)
{
// Required to load master audio effects
if
(
auto
ms
=
m_masterService
.
lock
())
{
ms
->
attach
(
*
filter
.
get
());
}
if
(
m_ownerId
.
first
==
ObjectType
::
Master
&&
filter
->
get
(
"mlt_service"
)
==
QLatin1String
(
"avfilter.subtitles"
))
{
// A subtitle filter, update project
QString
subFile
(
filter
->
get
(
"av.filename"
));
pCore
->
window
()
->
slotEditSubtitle
(
subFile
);
}
else
if
(
auto
ms
=
m_masterService
.
lock
())
{
ms
->
attach
(
*
filter
.
get
());
}
continue
;
}
...
...
src/mainwindow.cpp
View file @
299cd9e3
...
...
@@ -4193,18 +4193,25 @@ void MainWindow::resetSubtitles()
// Hide subtitle track
m_buttonSubtitleEditTool
->
setChecked
(
false
);
getMainTimeline
()
->
showSubtitles
=
false
;
pCore
->
subtitleWidget
()
->
setModel
(
nullptr
);
}
void
MainWindow
::
slotEditSubtitle
(
const
QString
subPath
)
{
std
::
shared_ptr
<
SubtitleModel
>
subtitleModel
=
pCore
->
currentDoc
()
->
getSubtitleModel
();
if
(
subtitleModel
==
nullptr
)
{
// Starting a new subtitle for this project
subtitleModel
.
reset
(
new
SubtitleModel
(
getMainTimeline
()
->
controller
()
->
tractor
(),
getMainTimeline
()
->
controller
()
->
getModel
(),
this
));
getMainTimeline
()
->
controller
()
->
getModel
()
->
setSubModel
(
subtitleModel
);
pCore
->
currentDoc
()
->
initializeSubtitles
(
subtitleModel
,
subPath
);
pCore
->
subtitleWidget
()
->
setModel
(
subtitleModel
);
getMainTimeline
()
->
showSubtitles
=
true
;
m_buttonSubtitleEditTool
->
setChecked
(
true
);
getMainTimeline
()
->
connectSubtitleModel
(
true
);
}
else
{
getMainTimeline
()
->
showSubtitles
=
m_buttonSubtitleEditTool
->
isChecked
();
getMainTimeline
()
->
connectSubtitleModel
(
false
);
}
getMainTimeline
()
->
connectSubtitleModel
();
}
void
MainWindow
::
slotAddSubtitle
()
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
299cd9e3
...
...
@@ -3821,7 +3821,7 @@ void TimelineController::importSubtitle()
if
(
view
.
cursor_pos
->
isChecked
())
{
offset
=
pCore
->
getTimelinePosition
();
}
subtitleModel
->
importSubtitle
(
view
.
subtitle_url
->
url
().
toLocalFile
(),
offset
);
subtitleModel
->
importSubtitle
(
view
.
subtitle_url
->
url
().
toLocalFile
(),
offset
,
true
);
}
}
...
...
src/timeline2/view/timelinewidget.cpp
View file @
299cd9e3
...
...
@@ -487,7 +487,7 @@ bool TimelineWidget::eventFilter(QObject *object, QEvent *event)
return
QQuickWidget
::
eventFilter
(
object
,
event
);
}
void
TimelineWidget
::
connectSubtitleModel
()
void
TimelineWidget
::
connectSubtitleModel
(
bool
firstConnect
)
{
qDebug
()
<<
"root context get sub model new function"
;
if
(
pCore
->
projectManager
()
->
current
()
->
getSubtitleModel
().
get
()
==
nullptr
)
{
...
...
@@ -496,9 +496,10 @@ void TimelineWidget::connectSubtitleModel()
}
else
{
showSubtitles
=
!
showSubtitles
;
//qDebug()<<"null ptr NOT here at root context";
rootObject
()
->
setProperty
(
"showSubtitles"
,
showSubtitles
);
rootContext
()
->
setContextProperty
(
"subtitleModel"
,
pCore
->
projectManager
()
->
current
()
->
getSubtitleModel
().
get
());
if
(
firstConnect
)
{
rootContext
()
->
setContextProperty
(
"subtitleModel"
,
pCore
->
projectManager
()
->
current
()
->
getSubtitleModel
().
get
());
}
}
}
src/timeline2/view/timelinewidget.h
View file @
299cd9e3
...
...
@@ -56,7 +56,7 @@ public:
/** @brief Initiate timeline clip context menu */
void
setTimelineMenu
(
QMenu
*
clipMenu
,
QMenu
*
compositionMenu
,
QMenu
*
timelineMenu
,
QMenu
*
timelineRulerMenu
,
QMenu
*
guideMenu
,
QAction
*
editGuideAction
,
QMenu
*
headerMenu
,
QMenu
*
thumbsMenu
,
QMenu
*
subtitleClipMenu
);
bool
loading
;
void
connectSubtitleModel
();
void
connectSubtitleModel
(
bool
firstConnect
);
bool
showSubtitles
=
false
;
protected:
...
...
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