Focus lower video track on project opening, correctly scroll view when active track changes

parent 3f765fa0
......@@ -394,6 +394,20 @@ QVariant TimelineItemModel::getTrackProperty(int tid, const QString &name) const
return getTrackById_const(tid)->getProperty(name);
}
int TimelineItemModel::getFirstVideoTrackIndex() const
{
int trackId;
auto it = m_allTracks.cbegin();
while (it != m_allTracks.cend()) {
trackId = getTrackMltIndex((*it)->getId());
if ((*it)->getProperty("kdenlive:audio_track").toInt() != 1) {
break;
}
++it;
}
return trackId;
}
const QString TimelineItemModel::getTrackFullName(int tid) const
{
QString tag = getTrackTagById(tid);
......
......@@ -81,6 +81,9 @@ public:
QModelIndex parent(const QModelIndex &index) const override;
Q_INVOKABLE void setTrackProperty(int tid, const QString &name, const QString &value);
Q_INVOKABLE QVariant getTrackProperty(int tid, const QString &name) const;
/** @brief returns the lower video track index in timeline.
**/
int getFirstVideoTrackIndex() const;
const QString getTrackFullName(int tid) const;
void notifyChange(const QModelIndex &topleft, const QModelIndex &bottomright, bool start, bool duration, bool updateThumb) override;
void notifyChange(const QModelIndex &topleft, const QModelIndex &bottomright, const QVector<int> &roles) override;
......
......@@ -131,6 +131,7 @@ Rectangle {
property int copiedClip: -1
property var dragList: []
property int zoomOnMouse: -1
property int viewActiveTrack: timeline.activeTrack
//onCurrentTrackChanged: timeline.selection = []
onTimeScaleChanged: {
......@@ -144,6 +145,15 @@ Rectangle {
ruler.adjustStepSize()
}
onViewActiveTrackChanged: {
var tk = Logic.getTrackById(timeline.activeTrack)
if (tk.y < scrollView.flickableItem.contentY) {
scrollView.flickableItem.contentY = Math.max(0, tk.y - scrollView.height / 3)
} else if (tk.y + tk.height > scrollView.flickableItem.contentY + scrollView.viewport.height) {
scrollView.flickableItem.contentY = Math.min(scrollView.flickableItem.height, tk.y - scrollView.height / 3)
}
}
onTimelineSelectionChanged: {
if (root.timelineSelection.length == 0) {
root.dragList = []
......
......@@ -92,7 +92,7 @@ void TimelineWidget::setModel(std::shared_ptr<TimelineItemModel> model)
m_proxy->setRoot(rootObject());
setVisible(true);
loading = false;
m_proxy->setActiveTrack(model->getTrackIndexFromPosition(model->getTracksCount() - 1));
m_proxy->setActiveTrack(model->getFirstVideoTrackIndex());
m_proxy->checkDuration();
}
......
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