Resizable track header

parent d4425057
......@@ -183,9 +183,9 @@
</group>
<group name="timeline">
<entry name="timelineheaderwidth" type="String">
<entry name="headerwidth" type="Int">
<label>Default width for timeline track headers.</label>
<default></default>
<default>140</default>
</entry>
<entry name="defaultkeyframeinterp" type="Int">
<label>Default interpolation for keyframes.</label>
......
......@@ -176,7 +176,7 @@ Timeline::Timeline(KdenliveDoc *doc, const QList<QAction *> &actions, const QLis
connect(m_disablePreview, &QAction::triggered, this, &Timeline::disablePreview);
m_disablePreview->setEnabled(false);
m_trackview->initTools();
splitter->restoreState(QByteArray::fromBase64(KdenliveSettings::timelineheaderwidth().toUtf8()));
//splitter->restoreState(QByteArray::fromBase64(KdenliveSettings::timelineheaderwidth().toUtf8()));
QAction *previewRender = m_doc->getAction(QStringLiteral("prerender_timeline_zone"));
previewRender->setEnabled(true);
}
......@@ -2130,7 +2130,7 @@ void Timeline::clearPreviewRange()
void Timeline::storeHeaderSize(int, int)
{
KdenliveSettings::setTimelineheaderwidth(splitter->saveState().toBase64());
//KdenliveSettings::setTimelineheaderwidth(splitter->saveState().toBase64());
}
void Timeline::switchComposite(int mode)
......
......@@ -280,7 +280,7 @@ Rectangle {
Rectangle {
id: resizer
Layout.fillWidth: true
height: 5
height: 4
color: 'red'
opacity: 0
Drag.active: trimInMouseArea.drag.active
......@@ -312,7 +312,7 @@ Rectangle {
if (mouse.buttons === Qt.LeftButton) {
parent.opacity = 0.5
var newHeight = originalY + (mapToItem(null, x, y).y - startY)
newHeight = Math.max(trackLabel.height + resizer.height + 4, newHeight)
newHeight = Math.max(trackLabel.height + resizer.height + 3, newHeight)
trackHeadRoot.collapsed = newHeight < nameEdit.height * 2
trackHeadRoot.myTrackHeight = newHeight
}
......
......@@ -93,7 +93,7 @@ Rectangle {
return col
}
property int headerWidth: 140
property int headerWidth: timeline.headerWidth
property int activeTool: 0
property real baseUnit: fontMetrics.font.pointSize
property int currentTrack: 0
......@@ -380,9 +380,53 @@ Rectangle {
console.log('track name: ',index, ' = ', model.name)
//timeline.selectTrackHead(currentTrack)
}
}
}
}
Column {
id: trackHeadersResizer
spacing: 0
width: 5
Rectangle {
id: resizer
height: trackHeaders.height
width: 3
x: root.headerWidth - 2
color: 'red'
opacity: 0
Drag.active: headerMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
MouseArea {
id: headerMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
drag.target: parent
drag.axis: Drag.XAxis
property double startX
property double originalX
drag.smoothed: false
onPressed: {
root.stopScrolling = true
}
onReleased: {
root.stopScrolling = false
parent.opacity = 0
}
onEntered: parent.opacity = 0.5
onExited: parent.opacity = 0
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
parent.opacity = 0.5
headerWidth = Math.max(10, mapToItem(null, x, y).x + 2)
timeline.setHeaderWidth(headerWidth)
}
}
}
}
}
}
}
}
MouseArea {
......
......@@ -636,3 +636,13 @@ void TimelineController::focusItem(int itemId)
setPosition(start);
}
int TimelineController::headerWidth() const
{
return qMax(10, KdenliveSettings::headerwidth());
}
void TimelineController::setHeaderWidth(int width)
{
KdenliveSettings::setHeaderwidth(width);
}
......@@ -50,6 +50,7 @@ class TimelineController : public QObject
Q_PROPERTY(bool showThumbnails READ showThumbnails NOTIFY showThumbnailsChanged)
Q_PROPERTY(bool showMarkers READ showMarkers NOTIFY showMarkersChanged)
Q_PROPERTY(bool showAudioThumbnails READ showAudioThumbnails NOTIFY showAudioThumbnailsChanged)
Q_PROPERTY(int headerWidth READ headerWidth WRITE setHeaderWidth)
public:
TimelineController(KActionCollection *actionCollection, QObject *parent);
......@@ -161,6 +162,9 @@ public:
Q_INVOKABLE void selectItems(QVariantList arg, int startFrame, int endFrame);
Q_INVOKABLE int headerWidth() const;
Q_INVOKABLE void setHeaderWidth(int width);
/* @brief Seek to next snap point
*/
void gotoNextSnap();
......
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