viewer: allow temporarily suspending the auto-cache
While the auto-cache will always default to on, there are cases where the user may not want the viewer to barrel ahead caching something (footage viewer for instance or if the user is making a lot of changes in a short amount of time).
This commit is contained in:
@@ -58,7 +58,8 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
time_changed_from_timer_(false),
|
||||
prequeuing_(false),
|
||||
busy_(false),
|
||||
our_cache_background_task_(nullptr)
|
||||
our_cache_background_task_(nullptr),
|
||||
autocache_(true)
|
||||
{
|
||||
// Set up main layout
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
@@ -114,7 +115,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
renderer_->SetRenderMode(RenderMode::kOffline);
|
||||
|
||||
// Setup cache wait timer (waits a few seconds of inactivity before caching)
|
||||
cache_wait_timer_.setInterval(250);
|
||||
cache_wait_timer_.setInterval(Config::Current()["AutoCacheInterval"].toInt());
|
||||
cache_wait_timer_.setSingleShot(true);
|
||||
connect(&cache_wait_timer_, &QTimer::timeout, this, &ViewerWidget::StartBackgroundCaching);
|
||||
|
||||
@@ -369,6 +370,18 @@ void ViewerWidget::ForceUpdate()
|
||||
UpdateTextureFromNode(GetTime());
|
||||
}
|
||||
|
||||
void ViewerWidget::SetAutoCacheEnabled(bool e)
|
||||
{
|
||||
autocache_ = e;
|
||||
|
||||
if (autocache_) {
|
||||
StartBackgroundCaching();
|
||||
} else if (cache_background_task_ == our_cache_background_task_) {
|
||||
StopAllBackgroundCacheTasks(false);
|
||||
cache_background_task_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::SetGizmos(Node *node)
|
||||
{
|
||||
display_widget_->SetTimeTarget(GetConnectedNode());
|
||||
@@ -865,10 +878,10 @@ void ViewerWidget::StartBackgroundCaching()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GetConnectedNode()
|
||||
if (autocache_
|
||||
&& GetConnectedNode()
|
||||
&& (GetConnectedNode()->video_frame_cache()->HasInvalidatedRanges()
|
||||
|| GetConnectedNode()->audio_playback_cache()->HasInvalidatedRanges())
|
||||
&& Config::Current()["AutoCache"].toBool()) {
|
||||
|| GetConnectedNode()->audio_playback_cache()->HasInvalidatedRanges())) {
|
||||
if (cache_background_task_ || busy_viewers_) {
|
||||
|
||||
// Something else is caching right now, we don't want to do multiple at once so we'll check
|
||||
@@ -987,6 +1000,16 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
{
|
||||
// Auto-cache
|
||||
QAction* autocache_action = menu.addAction(tr("Auto-Cache"));
|
||||
autocache_action->setCheckable(true);
|
||||
autocache_action->setChecked(autocache_);
|
||||
connect(autocache_action, &QAction::triggered, this, &ViewerWidget::SetAutoCacheEnabled);
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
{
|
||||
// Safe Margins
|
||||
Menu* safe_margin_menu = new Menu(tr("Safe Margins"), &menu);
|
||||
|
||||
Reference in New Issue
Block a user