timeline: implement select to seek and seek to select
This commit is contained in:
@@ -82,7 +82,7 @@ void Config::SetDefaults()
|
||||
SetEntryInternal(QStringLiteral("InvertTimelineScrollAxes"), NodeValue::kBoolean, true);
|
||||
SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean, false);
|
||||
SetEntryInternal(QStringLiteral("PasteSeeks"), NodeValue::kBoolean, true);
|
||||
SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean, false);
|
||||
SetEntryInternal(QStringLiteral("SeekAlsoSelects"), NodeValue::kBoolean, false);
|
||||
SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean, false);
|
||||
SetEntryInternal(QStringLiteral("AutoSeekToBeginning"), NodeValue::kBoolean, true);
|
||||
SetEntryInternal(QStringLiteral("DropFileOnMediaToReplace"), NodeValue::kBoolean, false);
|
||||
|
||||
@@ -73,7 +73,7 @@ PreferencesBehaviorTab::PreferencesBehaviorTab()
|
||||
tr("Hold ALT on any UI element to switch scrolling axes"),
|
||||
timeline_group);
|
||||
AddItem(tr("Seek Also Selects"),
|
||||
QStringLiteral("SelectAlsoSeeks"),
|
||||
QStringLiteral("SeekAlsoSelects"),
|
||||
timeline_group);
|
||||
AddItem(tr("Seek to the End of Pastes"),
|
||||
QStringLiteral("PasteSeeks"),
|
||||
|
||||
@@ -198,6 +198,17 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
|
||||
signal_block_change_timer_->setSingleShot(true);
|
||||
connect(signal_block_change_timer_, &QTimer::timeout, this, [this]{
|
||||
signal_block_change_timer_->stop();
|
||||
|
||||
if (OLIVE_CONFIG("SelectAlsoSeeks").toBool()) {
|
||||
rational start = RATIONAL_MAX;
|
||||
for (Block *b : selected_blocks_) {
|
||||
start = std::min(start, b->in());
|
||||
}
|
||||
if (start != RATIONAL_MAX) {
|
||||
GetConnectedNode()->SetPlayhead(start);
|
||||
}
|
||||
}
|
||||
|
||||
emit BlockSelectionChanged(selected_blocks_);
|
||||
});
|
||||
}
|
||||
@@ -242,6 +253,36 @@ void TimelineWidget::resizeEvent(QResizeEvent *event)
|
||||
UpdateTimecodeWidthFromSplitters(views_.first()->splitter());
|
||||
}
|
||||
|
||||
void TimelineWidget::TimeChangedEvent(const rational &t)
|
||||
{
|
||||
if (OLIVE_CONFIG("SeekAlsoSelects").toBool()) {
|
||||
TimelineWidgetSelections sels;
|
||||
|
||||
QVector<Block*> new_blocks;
|
||||
|
||||
for (auto it=sequence()->GetTracks().cbegin(); it!=sequence()->GetTracks().cend(); it++) {
|
||||
Track *track = *it;
|
||||
if (track->IsLocked()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block *b = track->VisibleBlockAtTime(sequence()->GetPlayhead());
|
||||
if (!b || dynamic_cast<GapBlock*>(b)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
new_blocks.push_back(b);
|
||||
sels[track->ToReference()].insert(b->range());
|
||||
}
|
||||
|
||||
if (selected_blocks_ != new_blocks) {
|
||||
selected_blocks_ = new_blocks;
|
||||
SetSelections(sels, false);
|
||||
SignalBlockSelectionChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidget::ScaleChangedEvent(const double &scale)
|
||||
{
|
||||
super::ScaleChangedEvent(scale);
|
||||
|
||||
@@ -290,6 +290,7 @@ signals:
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
virtual void TimeChangedEvent(const rational &) override;
|
||||
virtual void TimebaseChangedEvent(const rational &) override;
|
||||
virtual void ScaleChangedEvent(const double &) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user