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
febe7173
Commit
febe7173
authored
Nov 12, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add subtitle import function, fix crash on add subtitle on new project
parent
eb909089
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
68 additions
and
13 deletions
+68
-13
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+14
-8
src/bin/model/subtitlemodel.hpp
src/bin/model/subtitlemodel.hpp
+3
-0
src/doc/kdenlivedoc.cpp
src/doc/kdenlivedoc.cpp
+2
-1
src/kdenliveui.rc
src/kdenliveui.rc
+2
-1
src/mainwindow.cpp
src/mainwindow.cpp
+19
-1
src/mainwindow.h
src/mainwindow.h
+6
-0
src/project/projectmanager.cpp
src/project/projectmanager.cpp
+1
-0
src/timeline2/view/timelinecontroller.cpp
src/timeline2/view/timelinecontroller.cpp
+17
-0
src/timeline2/view/timelinecontroller.h
src/timeline2/view/timelinecontroller.h
+2
-0
src/timeline2/view/timelinewidget.cpp
src/timeline2/view/timelinewidget.cpp
+2
-2
No files found.
src/bin/model/subtitlemodel.cpp
View file @
febe7173
...
...
@@ -66,14 +66,8 @@ std::shared_ptr<SubtitleModel> SubtitleModel::getModel()
return
pCore
->
projectManager
()
->
getSubtitleModel
();
}
void
SubtitleModel
::
parseSubtitle
(
const
QString
subPath
)
{
qDebug
()
<<
"Parsing started"
;
if
(
!
subPath
.
isEmpty
())
{
m_subtitleFilter
->
set
(
"av.filename"
,
subPath
.
toUtf8
().
constData
());
}
QString
filePath
=
m_subtitleFilter
->
get
(
"av.filename"
);
m_subFilePath
=
filePath
;
void
SubtitleModel
::
importSubtitle
(
const
QString
filePath
)
{
QString
start
,
end
,
comment
;
QString
timeLine
;
GenTime
startPos
,
endPos
;
...
...
@@ -230,6 +224,18 @@ void SubtitleModel::parseSubtitle(const QString subPath)
}
assFile
.
close
();
}
jsontoSubtitle
(
toJson
());
}
void
SubtitleModel
::
parseSubtitle
(
const
QString
subPath
)
{
qDebug
()
<<
"Parsing started"
;
if
(
!
subPath
.
isEmpty
())
{
m_subtitleFilter
->
set
(
"av.filename"
,
subPath
.
toUtf8
().
constData
());
}
QString
filePath
=
m_subtitleFilter
->
get
(
"av.filename"
);
m_subFilePath
=
filePath
;
importSubtitle
(
filePath
);
//jsontoSubtitle(toJson());
}
...
...
src/bin/model/subtitlemodel.hpp
View file @
febe7173
...
...
@@ -95,6 +95,9 @@ public:
@param newPos is new start position of subtitle
*/
void
moveSubtitle
(
GenTime
oldPos
,
GenTime
newPos
);
/** @brief Function that imports a subtitle file */
void
importSubtitle
(
const
QString
filePath
);
/** @brief Exports the subtitle model to json */
QString
toJson
();
...
...
src/doc/kdenlivedoc.cpp
View file @
febe7173
...
...
@@ -81,8 +81,9 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, QString projectFolder, QUndoGroup *und
,
m_modified
(
false
)
,
m_documentOpenStatus
(
CleanProject
)
,
m_projectFolder
(
std
::
move
(
projectFolder
))
,
m_guideModel
(
new
MarkerListModel
(
m_commandStack
,
this
))
,
m_subtitleModel
(
nullptr
)
{
m_guideModel
.
reset
(
new
MarkerListModel
(
m_commandStack
,
this
));
connect
(
m_guideModel
.
get
(),
&
MarkerListModel
::
modelChanged
,
this
,
&
KdenliveDoc
::
guidesChanged
);
connect
(
this
,
SIGNAL
(
updateCompositionMode
(
int
)),
parent
,
SLOT
(
slotUpdateCompositeAction
(
int
)));
bool
success
=
false
;
...
...
src/kdenliveui.rc
View file @
febe7173
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui
name=
"kdenlive"
version=
"19
5
"
translationDomain=
"kdenlive"
>
<kpartgui
name=
"kdenlive"
version=
"19
6
"
translationDomain=
"kdenlive"
>
<MenuBar>
<Menu
name=
"file"
>
<Action
name=
"file_save"
/>
...
...
@@ -30,6 +30,7 @@
<Menu
name=
"subtitles"
><text>
Subtitles
</text>
<Action
name=
"subtitle_tool"
/>
<Action
name=
"add_subtitle"
/>
<Action
name=
"import_subtitle"
/>
</Menu>
<Separator
/>
<Action
name=
"bin_view_mode"
/>
...
...
src/mainwindow.cpp
View file @
febe7173
...
...
@@ -1703,6 +1703,8 @@ void MainWindow::setupActions()
addAction
(
QStringLiteral
(
"delete_all_guides"
),
i18n
(
"Delete All Guides"
),
this
,
SLOT
(
slotDeleteAllGuides
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)));
addAction
(
QStringLiteral
(
"add_subtitle"
),
i18n
(
"Add Subtitle"
),
this
,
SLOT
(
slotAddSubtitle
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"list-add"
)),
Qt
::
SHIFT
+
Qt
::
Key_S
);
addAction
(
QStringLiteral
(
"import_subtitle"
),
i18n
(
"Import Subtitle File"
),
this
,
SLOT
(
slotImportSubtitle
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"list-add"
)));
m_saveAction
=
KStandardAction
::
save
(
pCore
->
projectManager
(),
SLOT
(
saveFile
()),
actionCollection
());
m_saveAction
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"document-save"
)));
...
...
@@ -4170,6 +4172,13 @@ void MainWindow::slotActivateTarget()
}
}
void
MainWindow
::
resetSubtitles
()
{
// Hide subtitle track
m_buttonSubtitleEditTool
->
setChecked
(
false
);
getMainTimeline
()
->
showSubtitles
=
false
;
}
void
MainWindow
::
slotEditSubtitle
(
const
QString
subPath
)
{
std
::
shared_ptr
<
SubtitleModel
>
subtitleModel
=
pCore
->
currentDoc
()
->
getSubtitleModel
();
...
...
@@ -4182,13 +4191,22 @@ void MainWindow::slotEditSubtitle(const QString subPath)
void
MainWindow
::
slotAddSubtitle
()
{
if
(
!
getMainTimeline
()
->
showSubtitles
)
{
if
(
pCore
->
currentDoc
()
->
getSubtitleModel
()
==
nullptr
||
!
getMainTimeline
()
->
showSubtitles
)
{
slotEditSubtitle
();
m_buttonSubtitleEditTool
->
setChecked
(
true
);
}
getCurrentTimeline
()
->
controller
()
->
addSubtitle
();
}
void
MainWindow
::
slotImportSubtitle
()
{
if
(
pCore
->
currentDoc
()
->
getSubtitleModel
()
==
nullptr
||
!
getMainTimeline
()
->
showSubtitles
)
{
slotEditSubtitle
();
m_buttonSubtitleEditTool
->
setChecked
(
true
);
}
getCurrentTimeline
()
->
controller
()
->
importSubtitle
();
}
#ifdef DEBUG_MAINW
#undef DEBUG_MAINW
#endif
src/mainwindow.h
View file @
febe7173
...
...
@@ -141,6 +141,9 @@ public:
/** @brief Raise (show) the project bin*/
void
raiseBin
();
/** @brief Hide subtitle track */
void
resetSubtitles
();
protected:
/** @brief Closes the window.
* @return false if the user presses "Cancel" on a confirmation dialog or
...
...
@@ -509,7 +512,10 @@ private slots:
void
slotActivateVideoTrackSequence
();
/** @brief Select target for current track */
void
slotActivateTarget
();
/** @brief Add a subtitle at current position */
void
slotAddSubtitle
();
/** @brief Import a subtitle file */
void
slotImportSubtitle
();
signals:
Q_SCRIPTABLE
void
abortRenderJob
(
const
QString
&
url
);
...
...
src/project/projectmanager.cpp
View file @
febe7173
...
...
@@ -271,6 +271,7 @@ bool ProjectManager::closeCurrentDocument(bool saveChanges, bool quit)
disconnect
(
pCore
->
window
()
->
getMainTimeline
()
->
controller
(),
&
TimelineController
::
durationChanged
,
this
,
&
ProjectManager
::
adjustProjectDuration
);
pCore
->
window
()
->
getMainTimeline
()
->
controller
()
->
clipActions
.
clear
();
pCore
->
window
()
->
getMainTimeline
()
->
controller
()
->
prepareClose
();
pCore
->
window
()
->
resetSubtitles
();
if
(
m_mainTimelineModel
)
{
m_mainTimelineModel
->
prepareClose
();
}
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
febe7173
...
...
@@ -52,6 +52,7 @@
#include "audiomixer/mixermanager.hpp"
#include <KColorScheme>
#include <KRecentDirs>
#include <QApplication>
#include <QClipboard>
#include <QQuickItem>
...
...
@@ -3851,6 +3852,22 @@ void TimelineController::addSubtitle(int startframe)
pCore
->
pushUndo
(
local_undo
,
local_redo
,
i18n
(
"Add subtitle"
));
}
void
TimelineController
::
importSubtitle
()
{
const
QString
dialogFilter
=
i18n
(
"Subtitle Files"
)
+
QStringLiteral
(
" (*.srt, *.ass)"
);
QString
clipFolder
=
KRecentDirs
::
dir
(
QStringLiteral
(
":KdenliveSubtitlesFolder"
));
if
(
clipFolder
.
isEmpty
())
{
clipFolder
=
QDir
::
homePath
();
}
QPointer
<
QFileDialog
>
d
=
new
QFileDialog
(
QApplication
::
activeWindow
(),
i18n
(
"Open Subtitle File"
),
clipFolder
,
dialogFilter
);
d
->
setFileMode
(
QFileDialog
::
ExistingFile
);
if
(
d
->
exec
()
==
QDialog
::
Accepted
&&
!
d
->
selectedUrls
().
isEmpty
())
{
KRecentDirs
::
add
(
QStringLiteral
(
":KdenliveSubtitlesFolder"
),
d
->
selectedUrls
().
first
().
adjusted
(
QUrl
::
RemoveFilename
).
toLocalFile
());
auto
subtitleModel
=
pCore
->
projectManager
()
->
current
()
->
getSubtitleModel
();
subtitleModel
->
importSubtitle
(
d
->
selectedUrls
().
first
().
toLocalFile
());
}
}
void
TimelineController
::
deleteSubtitle
(
int
startframe
,
int
endframe
,
QString
text
)
{
auto
subtitleModel
=
pCore
->
projectManager
()
->
current
()
->
getSubtitleModel
();
...
...
src/timeline2/view/timelinecontroller.h
View file @
febe7173
...
...
@@ -582,6 +582,8 @@ public:
Q_INVOKABLE
void
addSubtitle
(
int
startframe
=
-
1
);
/** @brief Delete subtitle clip with frame as start position*/
Q_INVOKABLE
void
deleteSubtitle
(
int
frameframe
,
int
endframe
,
QString
Ctext
);
/** @brief Import a subtitle file*/
void
importSubtitle
();
public
slots
:
void
resetView
();
...
...
src/timeline2/view/timelinewidget.cpp
View file @
febe7173
...
...
@@ -490,7 +490,7 @@ void TimelineWidget::connectSubtitleModel()
{
showSubtitles
=
!
showSubtitles
;
//qDebug()<<"null ptr NOT here at root context";
rootObject
()
->
setProperty
(
"showSubtitles"
,
showSubtitles
);
rootObject
()
->
setProperty
(
"showSubtitles"
,
showSubtitles
);
rootContext
()
->
setContextProperty
(
"subtitleModel"
,
pCore
->
projectManager
()
->
current
()
->
getSubtitleModel
().
get
());
}
}
\ No newline at end of file
}
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