Shift + collapse will collapse expand all audio or video tracks.

Related to #643
parent 0c9b6839
......@@ -32,7 +32,6 @@ Rectangle {
property bool isAudio
property bool showAudioRecord: false
property bool current: false
property int myTrackHeight
property int trackId : -42
property string trackTag
property int thumbsFormat: 0
......@@ -186,6 +185,7 @@ Rectangle {
ToolButton {
id: expandButton
focusPolicy: Qt.NoFocus
property var modifier: 0
contentItem: Item {
Image {
source: trackHeadRoot.collapsed ? "image://icon/go-next" : "image://icon/go-down"
......@@ -196,7 +196,27 @@ Rectangle {
}
}
onClicked: {
trackHeadRoot.myTrackHeight = trackHeadRoot.collapsed ? Math.max(root.collapsedHeight * 1.5, controller.getTrackProperty(trackId, "kdenlive:trackheight")) : root.collapsedHeight
if (modifier & Qt.ShiftModifier) {
// Collapse / expand all tracks
timeline.collapseAllTrackHeight(trackId, !trackHeadRoot.collapsed, root.collapsedHeight)
} else {
if (trackHeadRoot.collapsed) {
var newHeight = Math.max(root.collapsedHeight * 1.5, controller.getTrackProperty(trackId, "kdenlive:trackheight"))
controller.setTrackProperty(trackId, "kdenlive:trackheight", newHeight)
controller.setTrackProperty(trackId, "kdenlive:collapsed", "0")
} else {
controller.setTrackProperty(trackId, "kdenlive:collapsed", root.collapsedHeight)
}
}
}
MouseArea {
// Used to pass modifier state to expand button
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onPressed: {
expandButton.modifier = mouse.modifiers
mouse.accepted = false
}
}
anchors.left: parent.left
width: root.collapsedHeight
......@@ -548,7 +568,7 @@ Rectangle {
parent.opacity = 0
}
if (mouse.modifiers & Qt.ShiftModifier && dragStarted) {
timeline.adjustAllTrackHeight(trackHeadRoot.trackId, trackHeadRoot.myTrackHeight)
timeline.adjustAllTrackHeight(trackHeadRoot.trackId, trackHeadRoot.height)
}
}
onEntered: parent.opacity = 0.3
......@@ -564,7 +584,12 @@ Rectangle {
}
var newHeight = originalY + (mapToItem(null, x, y).y - startY)
newHeight = Math.max(root.collapsedHeight, newHeight)
trackHeadRoot.myTrackHeight = newHeight
if (newHeight == root.collapsedHeight) {
controller.setTrackProperty(trackId, "kdenlive:collapsed", root.collapsedHeight)
} else {
controller.setTrackProperty(trackId, "kdenlive:trackheight", newHeight)
controller.setTrackProperty(trackId, "kdenlive:collapsed", "0")
}
}
}
}
......
......@@ -698,16 +698,8 @@ Rectangle {
Component.onCompleted: {
root.collapsedHeight = collapsedHeight
}
onMyTrackHeightChanged: {
collapsed = myTrackHeight <= root.collapsedHeight
if (!collapsed) {
controller.setTrackProperty(trackId, "kdenlive:trackheight", myTrackHeight)
controller.setTrackProperty(trackId, "kdenlive:collapsed", "0")
} else {
controller.setTrackProperty(trackId, "kdenlive:collapsed", root.collapsedHeight)
}
// hack: change property to trigger transition adjustment
root.trackHeight = root.trackHeight === 1 ? 0 : 1
onHeightChanged: {
collapsed = height <= root.collapsedHeight
}
}
}
......
......@@ -1058,6 +1058,27 @@ void TimelineController::adjustAllTrackHeight(int trackId, int height)
m_model->dataChanged(modelStart, modelEnd, {TimelineModel::HeightRole});
}
void TimelineController::collapseAllTrackHeight(int trackId, bool collapse, int collapsedHeight)
{
bool isAudio = m_model->getTrackById_const(trackId)->isAudioTrack();
auto it = m_model->m_allTracks.cbegin();
while (it != m_model->m_allTracks.cend()) {
int target_track = (*it)->getId();
if (m_model->getTrackById_const(target_track)->isAudioTrack() == isAudio) {
if (collapse) {
m_model->setTrackProperty(target_track, "kdenlive:collapsed", QString::number(collapsedHeight));
} else {
m_model->setTrackProperty(target_track, "kdenlive:collapsed", QStringLiteral("0"));
}
}
++it;
}
int tracksCount = m_model->getTracksCount();
QModelIndex modelStart = m_model->makeTrackIndexFromID(m_model->getTrackIndexFromPosition(0));
QModelIndex modelEnd = m_model->makeTrackIndexFromID(m_model->getTrackIndexFromPosition(tracksCount - 1));
m_model->dataChanged(modelStart, modelEnd, {TimelineModel::HeightRole});
}
void TimelineController::defaultTrackHeight(int trackId)
{
if (trackId > -1) {
......
......@@ -294,6 +294,7 @@ public:
/* @brief Adjust height of all similar (audio or video) tracks
*/
Q_INVOKABLE void adjustAllTrackHeight(int trackId, int height);
Q_INVOKABLE void collapseAllTrackHeight(int trackId, bool collapse, int collapsedHeight);
/** @brief Reset track @trackId height to default track height. Adjusts all tracks if @trackId == -1
*/
......
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