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
bd13f3b8
Commit
bd13f3b8
authored
Dec 06, 2020
by
Jean-Baptiste Mardelle
Browse files
Add hide and lock (in progress) of subtitle track
parent
8d53e900
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
bd13f3b8
...
...
@@ -1032,3 +1032,24 @@ int SubtitleModel::trackDuration() const
}
return
m_subtitleList
.
rbegin
()
->
second
.
second
.
frames
(
pCore
->
getCurrentFps
());
}
void
SubtitleModel
::
switchDisabled
()
{
m_subtitleFilter
->
set
(
"disable"
,
1
-
m_subtitleFilter
->
get_int
(
"disable"
));
}
void
SubtitleModel
::
switchLocked
()
{
m_subtitleFilter
->
set
(
"kdenlive:locked"
,
1
-
m_subtitleFilter
->
get_int
(
"kdenlive:locked"
));
}
bool
SubtitleModel
::
isDisabled
()
const
{
return
m_subtitleFilter
->
get_int
(
"disable"
)
==
1
;
}
bool
SubtitleModel
::
isLocked
()
const
{
return
m_subtitleFilter
->
get_int
(
"kdenlive:locked"
)
==
1
;
}
src/bin/model/subtitlemodel.hpp
View file @
bd13f3b8
...
...
@@ -131,6 +131,10 @@ public:
/** @brief Copy subtitle file to a new path */
void
copySubtitle
(
const
QString
&
path
,
bool
checkOverwrite
);
int
trackDuration
()
const
;
void
switchDisabled
();
bool
isDisabled
()
const
;
void
switchLocked
();
bool
isLocked
()
const
;
public
slots
:
/** @brief Function that parses through a subtitle file */
...
...
src/kdenliveui.rc
View file @
bd13f3b8
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui
name=
"kdenlive"
version=
"19
7
"
translationDomain=
"kdenlive"
>
<kpartgui
name=
"kdenlive"
version=
"19
8
"
translationDomain=
"kdenlive"
>
<MenuBar>
<Menu
name=
"file"
>
<Action
name=
"file_save"
/>
...
...
@@ -30,6 +30,9 @@
<Menu
name=
"subtitles"
><text>
Subtitles
</text>
<Action
name=
"subtitle_tool"
/>
<Action
name=
"add_subtitle"
/>
<Action
name=
"disable_subtitle"
/>
<Action
name=
"lock_subtitle"
/>
<Separator
/>
<Action
name=
"import_subtitle"
/>
<Action
name=
"export_subtitle"
/>
</Menu>
...
...
src/mainwindow.cpp
View file @
bd13f3b8
...
...
@@ -1719,6 +1719,9 @@ 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
(
"disable_subtitle"
),
i18n
(
"Disable Subtitle"
),
this
,
SLOT
(
slotDisableSubtitle
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"view-hidden"
)));
addAction
(
QStringLiteral
(
"lock_subtitle"
),
i18n
(
"Lock Subtitle"
),
this
,
SLOT
(
slotLockSubtitle
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"kdenlive-lock"
)));
addAction
(
QStringLiteral
(
"import_subtitle"
),
i18n
(
"Import Subtitle File"
),
this
,
SLOT
(
slotImportSubtitle
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"document-import"
)));
addAction
(
QStringLiteral
(
"export_subtitle"
),
i18n
(
"Export Subtitle File"
),
this
,
SLOT
(
slotExportSubtitle
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"document-export"
)));
addAction
(
QStringLiteral
(
"delete_subtitle_clip"
),
i18n
(
"Delete Subtitle"
),
this
,
SLOT
(
slotDeleteItem
()),
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)));
...
...
@@ -4239,6 +4242,16 @@ void MainWindow::slotAddSubtitle()
getCurrentTimeline
()
->
controller
()
->
addSubtitle
();
}
void
MainWindow
::
slotDisableSubtitle
()
{
getCurrentTimeline
()
->
controller
()
->
switchSubtitleDisable
();
}
void
MainWindow
::
slotLockSubtitle
()
{
getCurrentTimeline
()
->
controller
()
->
switchSubtitleLock
();
}
void
MainWindow
::
slotImportSubtitle
()
{
if
(
pCore
->
getSubtitleModel
()
==
nullptr
||
!
getMainTimeline
()
->
showSubtitles
)
{
...
...
src/mainwindow.h
View file @
bd13f3b8
...
...
@@ -514,6 +514,10 @@ private slots:
void
slotActivateTarget
();
/** @brief Add subtitle clip to timeline */
void
slotAddSubtitle
();
/** @brief Enable/disable subtitle track */
void
slotDisableSubtitle
();
/** @brief Lock / unlock subtitle track */
void
slotLockSubtitle
();
/** @brief Import a subtitle file */
void
slotImportSubtitle
();
/** @brief Export a subtitle file */
...
...
src/timeline2/view/qml/timeline.qml
View file @
bd13f3b8
...
...
@@ -311,6 +311,8 @@ Rectangle {
property
bool
paletteUnchanged
:
true
property
int
maxLabelWidth
:
20
*
root
.
baseUnit
*
Math
.
sqrt
(
root
.
timeScale
)
property
bool
showSubtitles
:
false
property
bool
subtitlesLocked
:
timeline
.
subtitlesLocked
property
bool
subtitlesDisabled
:
timeline
.
subtitlesDisabled
property
int
trackTagWidth
:
fontMetrics
.
boundingRect
(
"
M
"
).
width
onSeekingFinishedChanged
:
{
...
...
@@ -751,6 +753,90 @@ Rectangle {
text
:
i18n
(
"
Subtitles
"
)
visible
:
(
subtitleTrackHeader
.
height
>
root
.
collapsedHeight
+
subLabel
.
height
)
}
Row
{
id
:
subButtonsRow
width
:
childrenRect
.
width
x
:
Math
.
max
(
2
*
root
.
collapsedHeight
+
2
,
parent
.
width
-
width
-
4
)
spacing
:
0
ToolButton
{
id
:
muteButton
focusPolicy
:
Qt
.
NoFocus
contentItem
:
Item
{
Image
{
source
:
root
.
subtitlesDisabled
?
"
image://icon/view-hidden
"
:
"
image://icon/view-visible
"
anchors.centerIn
:
parent
width
:
root
.
collapsedHeight
-
4
height
:
root
.
collapsedHeight
-
4
cache
:
root
.
paletteUnchanged
}
}
width
:
root
.
collapsedHeight
height
:
root
.
collapsedHeight
onClicked
:
timeline
.
triggerAction
(
'
disable_subtitle
'
)
ToolTip
{
visible
:
muteButton
.
hovered
font
:
miniFont
delay
:
1500
timeout
:
5000
background
:
Rectangle
{
color
:
activePalette
.
alternateBase
border.color
:
activePalette
.
light
}
contentItem
:
Label
{
color
:
activePalette
.
text
text
:
isDisabled
?
i18n
(
"
Show
"
)
:
i18n
(
"
Hide
"
)
}
}
}
ToolButton
{
id
:
lockButton
width
:
root
.
collapsedHeight
height
:
root
.
collapsedHeight
focusPolicy
:
Qt
.
NoFocus
contentItem
:
Item
{
Image
{
source
:
root
.
subtitlesLocked
?
"
image://icon/kdenlive-lock
"
:
"
image://icon/kdenlive-unlock
"
anchors.centerIn
:
parent
width
:
root
.
collapsedHeight
-
4
height
:
root
.
collapsedHeight
-
4
cache
:
root
.
paletteUnchanged
}
}
onClicked
:
timeline
.
triggerAction
(
'
lock_subtitle
'
)
ToolTip
{
visible
:
lockButton
.
hovered
font
:
miniFont
delay
:
1500
timeout
:
5000
background
:
Rectangle
{
color
:
activePalette
.
alternateBase
border.color
:
activePalette
.
light
}
contentItem
:
Label
{
color
:
activePalette
.
text
text
:
isLocked
?
i18n
(
"
Unlock track
"
)
:
i18n
(
"
Lock track
"
)
}
}
SequentialAnimation
{
id
:
flashLock
loops
:
1
ScaleAnimator
{
target
:
lockButton
from
:
1
to
:
1.6
duration
:
200
}
ScaleAnimator
{
target
:
lockButton
from
:
1.6
to
:
1
duration
:
200
}
}
}
}
}
Column
{
id
:
trackHeaders
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
bd13f3b8
...
...
@@ -3931,3 +3931,39 @@ void TimelineController::deleteSubtitle(int startframe, int endframe, QString te
local_redo
();
pCore
->
pushUndo
(
local_undo
,
local_redo
,
i18n
(
"Delete subtitle"
));
}
void
TimelineController
::
switchSubtitleDisable
()
{
auto
subtitleModel
=
pCore
->
getSubtitleModel
();
if
(
subtitleModel
)
{
subtitleModel
->
switchDisabled
();
emit
subtitlesDisabledChanged
();
pCore
->
requestMonitorRefresh
();
}
}
bool
TimelineController
::
subtitlesDisabled
()
const
{
auto
subtitleModel
=
pCore
->
getSubtitleModel
();
if
(
subtitleModel
)
{
return
subtitleModel
->
isDisabled
();
}
return
false
;
}
void
TimelineController
::
switchSubtitleLock
()
{
auto
subtitleModel
=
pCore
->
getSubtitleModel
();
if
(
subtitleModel
)
{
subtitleModel
->
switchLocked
();
emit
subtitlesLockedChanged
();
}
}
bool
TimelineController
::
subtitlesLocked
()
const
{
auto
subtitleModel
=
pCore
->
getSubtitleModel
();
if
(
subtitleModel
)
{
return
subtitleModel
->
isLocked
();
}
return
false
;
}
src/timeline2/view/timelinecontroller.h
View file @
bd13f3b8
...
...
@@ -85,6 +85,8 @@ class TimelineController : public QObject
Q_PROPERTY
(
QColor
lockedColor
READ
lockedColor
NOTIFY
colorsChanged
)
Q_PROPERTY
(
QColor
selectionColor
READ
selectionColor
NOTIFY
colorsChanged
)
Q_PROPERTY
(
QColor
groupColor
READ
groupColor
NOTIFY
colorsChanged
)
Q_PROPERTY
(
bool
subtitlesDisabled
READ
subtitlesDisabled
NOTIFY
subtitlesDisabledChanged
)
Q_PROPERTY
(
bool
subtitlesLocked
READ
subtitlesLocked
NOTIFY
subtitlesLockedChanged
)
public:
TimelineController
(
QObject
*
parent
);
...
...
@@ -176,6 +178,10 @@ public:
Q_INVOKABLE
QColor
lockedColor
()
const
;
Q_INVOKABLE
QColor
selectionColor
()
const
;
Q_INVOKABLE
QColor
groupColor
()
const
;
void
switchSubtitleDisable
();
bool
subtitlesDisabled
()
const
;
void
switchSubtitleLock
();
bool
subtitlesLocked
()
const
;
/* @brief Request a seek operation
@param position is the desired new timeline position
*/
...
...
@@ -689,6 +695,8 @@ signals:
void
dirtyChunksChanged
();
void
renderedChunksChanged
();
void
workingPreviewChanged
();
void
subtitlesDisabledChanged
();
void
subtitlesLockedChanged
();
void
useRulerChanged
();
void
updateZoom
(
double
);
/* @brief emitted when timeline selection changes, true if a clip is selected
...
...
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