Commit 824741bd authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Subtitle track: add expand button and track label

parent 046dd663
......@@ -101,7 +101,7 @@ Rectangle {
background: Rectangle {
color: trackTarget.bgColor
}
width: 2 * fontMetrics.boundingRect("M").width
width: 2 * root.trackTagWidth
height: trackHeadRoot.height
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignHCenter
......@@ -294,7 +294,7 @@ Rectangle {
background: Rectangle {
color: trackLed.bgColor
}
width: fontMetrics.boundingRect("M").width * trackHeadRoot.trackTag.length
width: root.trackTagWidth * trackHeadRoot.trackTag.length
height: root.collapsedHeight - 2
y: 1
verticalAlignment: Text.AlignVCenter
......
......@@ -309,6 +309,7 @@ Rectangle {
property bool paletteUnchanged: true
property int maxLabelWidth: 20 * root.baseUnit * Math.sqrt(root.timeScale)
property bool showSubtitles: false
property int trackTagWidth: fontMetrics.boundingRect("M").width
onSeekingFinishedChanged : {
playhead.opacity = seekingFinished ? 1 : 0.5
......@@ -715,6 +716,43 @@ Rectangle {
scrollView.contentY = Math.max(newScroll, 0)
}
}
Item {
id: subtitleTrackHeader
width: tracksContainerArea.width
height: subtitleTrack.height
property bool collapsed: subtitleTrack.height == root.collapsedHeight
ToolButton {
id: expandSubButton
focusPolicy: Qt.NoFocus
property var modifier: 0
anchors.left: parent.left
anchors.leftMargin: 2 * root.trackTagWidth
width: root.collapsedHeight
height: root.collapsedHeight
contentItem: Item {
Image {
source: subtitleTrackHeader.collapsed ? "image://icon/go-next" : "image://icon/go-down"
anchors.centerIn: parent
width: root.collapsedHeight - 4
height: root.collapsedHeight - 4
cache: root.paletteUnchanged
}
}
onClicked: {
if (subtitleTrack.height > root.collapsedHeight) {
subtitleTrack.height = root.collapsedHeight
} else {
subtitleTrack.height = 5 * root.baseUnit
}
}
}
Label {
anchors.left: expandSubButton.left
anchors.top: expandSubButton.bottom
font: miniFont
text: i18n("Subtitles")
}
}
Column {
id: trackHeaders
y: subtitleTrack.height
......@@ -906,7 +944,7 @@ Rectangle {
scim = false
}
onDoubleClicked: {
if (root.showSubtitles && root.activeTool === 0 && mouse.y > ruler.height && mouse.y < (ruler.height + subtitleTrack.height)) {
if (mouse.buttons === Qt.LeftButton && root.showSubtitles && root.activeTool === 0 && mouse.y > ruler.height && mouse.y < (ruler.height + subtitleTrack.height)) {
timeline.addSubtitle((scrollView.contentX + mouseX) / timeline.scaleFactor)
}
}
......@@ -1124,7 +1162,7 @@ Rectangle {
Item {
id: subtitleTrack
width: tracksContainerArea.width
height: showSubtitles? root.baseUnit * 4 : 0
height: showSubtitles? root.baseUnit * 5 : 0
Repeater { id: subtitlesRepeater; model: subtitleDelegateModel }
MouseArea {
anchors.fill: parent
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment