Commit 78aed6b7 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Double click track resizer resets to default height

parent cd277a3d
...@@ -516,9 +516,11 @@ Rectangle { ...@@ -516,9 +516,11 @@ Rectangle {
property double startY property double startY
property double originalY property double originalY
drag.smoothed: false drag.smoothed: false
property bool dragStarted: false
onPressed: { onPressed: {
root.autoScrolling = false root.autoScrolling = false
dragStarted = false
startY = mapToItem(null, x, y).y startY = mapToItem(null, x, y).y
originalY = trackHeadRoot.height // reusing originalX to accumulate delta for bubble help originalY = trackHeadRoot.height // reusing originalX to accumulate delta for bubble help
} }
...@@ -527,15 +529,21 @@ Rectangle { ...@@ -527,15 +529,21 @@ Rectangle {
if (!trimInMouseArea.containsMouse) { if (!trimInMouseArea.containsMouse) {
parent.opacity = 0 parent.opacity = 0
} }
if (mouse.modifiers & Qt.ShiftModifier) { if (mouse.modifiers & Qt.ShiftModifier && dragStarted) {
timeline.adjustAllTrackHeight(trackHeadRoot.trackId, trackHeadRoot.myTrackHeight) timeline.adjustAllTrackHeight(trackHeadRoot.trackId, trackHeadRoot.myTrackHeight)
} }
} }
onEntered: parent.opacity = 0.3 onEntered: parent.opacity = 0.3
onExited: parent.opacity = 0 onExited: parent.opacity = 0
onDoubleClicked: {
timeline.defaultTrackHeight(mouse.modifiers & Qt.ShiftModifier ? -1 : trackHeadRoot.trackId)
}
onPositionChanged: { onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) { if (mouse.buttons === Qt.LeftButton) {
parent.opacity = 0.5 parent.opacity = 0.5
if (!dragStarted && Math.abs(mapToItem(null, x, y).y - startY) > 2) {
dragStarted = true
}
var newHeight = originalY + (mapToItem(null, x, y).y - startY) var newHeight = originalY + (mapToItem(null, x, y).y - startY)
newHeight = Math.max(root.collapsedHeight, newHeight) newHeight = Math.max(root.collapsedHeight, newHeight)
trackHeadRoot.myTrackHeight = newHeight trackHeadRoot.myTrackHeight = newHeight
......
...@@ -1034,6 +1034,26 @@ void TimelineController::adjustAllTrackHeight(int trackId, int height) ...@@ -1034,6 +1034,26 @@ void TimelineController::adjustAllTrackHeight(int trackId, int height)
m_model->dataChanged(modelStart, modelEnd, {TimelineModel::HeightRole}); m_model->dataChanged(modelStart, modelEnd, {TimelineModel::HeightRole});
} }
void TimelineController::defaultTrackHeight(int trackId)
{
if (trackId > -1) {
m_model->getTrackById(trackId)->setProperty(QStringLiteral("kdenlive:trackheight"), QString::number(KdenliveSettings::trackheight()));
QModelIndex modelStart = m_model->makeTrackIndexFromID(trackId);
m_model->dataChanged(modelStart, modelStart, {TimelineModel::HeightRole});
return;
}
auto it = m_model->m_allTracks.cbegin();
while (it != m_model->m_allTracks.cend()) {
int target_track = (*it)->getId();
m_model->getTrackById(target_track)->setProperty(QStringLiteral("kdenlive:trackheight"), QString::number(KdenliveSettings::trackheight()));
++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::setPosition(int position) void TimelineController::setPosition(int position)
{ {
// Process seek request // Process seek request
......
...@@ -295,6 +295,10 @@ public: ...@@ -295,6 +295,10 @@ public:
*/ */
Q_INVOKABLE void adjustAllTrackHeight(int trackId, int height); Q_INVOKABLE void adjustAllTrackHeight(int trackId, int height);
/** @brief Reset track @trackId height to default track height. Adjusts all tracks if @trackId == -1
*/
Q_INVOKABLE void defaultTrackHeight(int trackId);
Q_INVOKABLE bool exists(int itemId); Q_INVOKABLE bool exists(int itemId);
Q_INVOKABLE int headerWidth() const; Q_INVOKABLE int headerWidth() const;
......
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