update length value from signals/slots

I was looking for a way to update the length value automatically with signals
and slots (rather than just checking every time the viewer time changes). This
should do the trick.
This commit is contained in:
itsmattkc
2019-11-17 13:46:14 +09:00
parent 9d154e1909
commit 823e820bfa
2 changed files with 10 additions and 3 deletions
+8 -3
View File
@@ -134,6 +134,7 @@ void ViewerWidget::ConnectViewerNode(ViewerOutput *node)
disconnect(viewer_node_, SIGNAL(TimebaseChanged(const rational&)), this, SLOT(SetTimebase(const rational&)));
disconnect(viewer_node_, SIGNAL(SizeChanged(int, int)), this, SLOT(SizeChangedSlot(int, int)));
disconnect(viewer_node_, SIGNAL(LengthChanged(const rational&)), this, SLOT(LengthChangedSlot(const rational&)));
// Effectively disables the viewer and clears the state
SizeChangedSlot(0, 0);
@@ -149,8 +150,10 @@ void ViewerWidget::ConnectViewerNode(ViewerOutput *node)
connect(viewer_node_, SIGNAL(TimebaseChanged(const rational&)), this, SLOT(SetTimebase(const rational&)));
connect(viewer_node_, SIGNAL(SizeChanged(int, int)), this, SLOT(SizeChangedSlot(int, int)));
connect(viewer_node_, SIGNAL(LengthChanged(const rational&)), this, SLOT(LengthChangedSlot(const rational&)));
SizeChangedSlot(viewer_node_->video_params().width(), viewer_node_->video_params().height());
LengthChangedSlot(viewer_node_->Length());
}
video_renderer_->SetViewerNode(viewer_node_);
@@ -178,9 +181,6 @@ void ViewerWidget::UpdateTimeInternal(int64_t i)
controls_->SetTime(i);
if (viewer_node_ != nullptr) {
// FIXME: Implement some sort of signalling to update this when the sequence length actually changes
controls_->SetEndTime(olive::time_to_timestamp(viewer_node_->Length(), time_base_));
UpdateTextureFromNode(time_set);
PushScrubbedAudio();
@@ -359,6 +359,11 @@ void ViewerWidget::SizeChangedSlot(int width, int height)
sizer_->SetChildSize(width, height);
}
void ViewerWidget::LengthChangedSlot(const rational &length)
{
controls_->SetEndTime(olive::time_to_timestamp(length, time_base_));
}
void ViewerWidget::resizeEvent(QResizeEvent *event)
{
// Set scrollbar page step to the width
+2
View File
@@ -147,6 +147,8 @@ private slots:
void SizeChangedSlot(int width, int height);
void LengthChangedSlot(const rational& length);
};
#endif // VIEWER_WIDGET_H