fixed issue where timecodes in UI weren't updated correctly

This commit is contained in:
itsmattkc
2021-04-13 13:22:46 +10:00
parent 31b543c421
commit e54854b78a
3 changed files with 31 additions and 29 deletions
+19 -21
View File
@@ -288,29 +288,27 @@ void TimeBasedWidget::PassWheelEventsToScrollBar(QObject *object)
void TimeBasedWidget::SetTimestamp(int64_t timestamp)
{
if (GetTime() != timestamp) {
if (UserIsDraggingPlayhead()) {
// If the user is dragging the playhead, we will simply nudge over and not use autoscroll rules.
QMetaObject::invokeMethod(this, "CatchUpScrollToPlayhead", Qt::QueuedConnection);
} else {
// Otherwise, assume we jumped to this out of nowhere and must now autoscroll
switch (static_cast<AutoScroll::Method>(Config::Current()["Autoscroll"].toInt())) {
case AutoScroll::kNone:
// Do nothing
break;
case AutoScroll::kPage:
QMetaObject::invokeMethod(this, "PageScrollToPlayhead", Qt::QueuedConnection);
break;
case AutoScroll::kSmooth:
QMetaObject::invokeMethod(this, "CenterScrollOnPlayhead", Qt::QueuedConnection);
break;
}
if (UserIsDraggingPlayhead()) {
// If the user is dragging the playhead, we will simply nudge over and not use autoscroll rules.
QMetaObject::invokeMethod(this, "CatchUpScrollToPlayhead", Qt::QueuedConnection);
} else {
// Otherwise, assume we jumped to this out of nowhere and must now autoscroll
switch (static_cast<AutoScroll::Method>(Config::Current()["Autoscroll"].toInt())) {
case AutoScroll::kNone:
// Do nothing
break;
case AutoScroll::kPage:
QMetaObject::invokeMethod(this, "PageScrollToPlayhead", Qt::QueuedConnection);
break;
case AutoScroll::kSmooth:
QMetaObject::invokeMethod(this, "CenterScrollOnPlayhead", Qt::QueuedConnection);
break;
}
ruler_->SetTime(timestamp);
TimeChangedEvent(timestamp);
}
ruler_->SetTime(timestamp);
TimeChangedEvent(timestamp);
}
void TimeBasedWidget::SetTimebase(const rational &timebase)
+8 -6
View File
@@ -50,8 +50,10 @@
namespace olive {
#define super TimeBasedWidget
TimelineWidget::TimelineWidget(QWidget *parent) :
TimeBasedWidget(true, true, parent),
super(true, true, parent),
rubberband_(QRubberBand::Rectangle, this),
active_tool_(nullptr),
use_audio_time_units_(false)
@@ -111,8 +113,6 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
connect(views_.first()->view()->horizontalScrollBar(), &QScrollBar::rangeChanged, scrollbar(), &QScrollBar::setRange);
vert_layout->addWidget(scrollbar());
connect(ruler(), &TimeRuler::TimeChanged, this, &TimelineWidget::SetViewTimestamp);
foreach (TimelineAndTrackView* tview, views_) {
TimelineView* view = tview->view();
@@ -187,7 +187,7 @@ void TimelineWidget::Clear()
void TimelineWidget::TimebaseChangedEvent(const rational &timebase)
{
TimeBasedWidget::TimebaseChangedEvent(timebase);
super::TimebaseChangedEvent(timebase);
timecode_label_->SetTimebase(timebase);
@@ -198,7 +198,7 @@ void TimelineWidget::TimebaseChangedEvent(const rational &timebase)
void TimelineWidget::resizeEvent(QResizeEvent *event)
{
TimeBasedWidget::resizeEvent(event);
super::resizeEvent(event);
// Update timecode label size
UpdateTimecodeWidthFromSplitters(views_.first()->splitter());
@@ -206,6 +206,8 @@ void TimelineWidget::resizeEvent(QResizeEvent *event)
void TimelineWidget::TimeChangedEvent(const int64_t& timestamp)
{
super::TimeChangedEvent(timestamp);
SetViewTimestamp(timestamp);
timecode_label_->SetValue(timestamp);
@@ -213,7 +215,7 @@ void TimelineWidget::TimeChangedEvent(const int64_t& timestamp)
void TimelineWidget::ScaleChangedEvent(const double &scale)
{
TimeBasedWidget::ScaleChangedEvent(scale);
super::ScaleChangedEvent(scale);
foreach (TimelineAndTrackView* view, views_) {
view->view()->SetScale(scale);
+4 -2
View File
@@ -180,9 +180,11 @@ void SeekableWidget::SeekToScreenPoint(int screen)
}
}
SetTime(timestamp);
if (timestamp != GetTime()) {
SetTime(timestamp);
emit TimeChanged(timestamp);
emit TimeChanged(timestamp);
}
}
void SeekableWidget::DrawTimelinePoints(QPainter* p, int marker_bottom)