From b8331ce4b9bdc3fdafe8e1964178488ef4a31398 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 23 Mar 2019 01:41:05 +1100 Subject: [PATCH] restored setting to play past the end of the sequence --- dialogs/preferencesdialog.cpp | 6 ++++++ dialogs/preferencesdialog.h | 5 +++++ global/config.cpp | 5 +++++ global/config.h | 7 +++++++ panels/viewer.cpp | 5 +++-- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index 4703e0ae8..a9b8d2d6d 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -256,6 +256,8 @@ void PreferencesDialog::accept() { olive::CurrentConfig.use_native_menu_styling = native_menus->isChecked(); #endif + olive::CurrentConfig.auto_seek_to_beginning = auto_seek_to_beginning->isChecked(); + // Check if the thumbnail or waveform icon if (olive::CurrentConfig.thumbnail_resolution != thumbnail_res_spinbox->value() || olive::CurrentConfig.waveform_resolution != waveform_res_spinbox->value()) { @@ -560,6 +562,10 @@ void PreferencesDialog::setup_ui() { add_default_effects_to_clips->setChecked(olive::CurrentConfig.add_default_effects_to_clips); behavior_tab_layout->addWidget(add_default_effects_to_clips); + auto_seek_to_beginning = new QCheckBox(tr("Automatically Seek to the Beginning When Playing at the End of a Sequence")); + auto_seek_to_beginning->setChecked(olive::CurrentConfig.auto_seek_to_beginning); + behavior_tab_layout->addWidget(auto_seek_to_beginning); + // Appearance QWidget* appearance_tab = new QWidget(this); tabWidget->addTab(appearance_tab, tr("Appearance")); diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index 67538b7a7..fa87c457b 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -248,6 +248,11 @@ private: */ QCheckBox* add_default_effects_to_clips; + /** + * @brief UI widget for enabling/disabling Config::auto_seek_to_beginning + */ + QCheckBox* auto_seek_to_beginning; + /** * @brief UI widget for selecting the current UI style */ diff --git a/global/config.cpp b/global/config.cpp index 14377d672..667b178a9 100644 --- a/global/config.cpp +++ b/global/config.cpp @@ -64,6 +64,7 @@ Config::Config() upcoming_queue_type(olive::FRAME_QUEUE_TYPE_SECONDS), loop(false), seek_also_selects(false), + auto_seek_to_beginning(true), effect_textbox_lines(3), use_software_fallback(false), center_timeline_timecodes(true), @@ -179,6 +180,9 @@ void Config::load(QString path) { } else if (stream.name() == "SeekAlsoSelects") { stream.readNext(); seek_also_selects = (stream.text() == "1"); + } else if (stream.name() == "AutoSeekToBeginning") { + stream.readNext(); + auto_seek_to_beginning = (stream.text() == "1"); } else if (stream.name() == "CSSPath") { stream.readNext(); css_path = stream.text().toString(); @@ -271,6 +275,7 @@ void Config::save(QString path) { stream.writeTextElement("UpcomingFrameQueueType", QString::number(upcoming_queue_type)); stream.writeTextElement("Loop", QString::number(loop)); stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); + stream.writeTextElement("AutoSeekToBeginning", QString::number(auto_seek_to_beginning)); stream.writeTextElement("CSSPath", css_path); stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines)); stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback)); diff --git a/global/config.h b/global/config.h index f11183ef5..968e4a8c3 100644 --- a/global/config.h +++ b/global/config.h @@ -413,6 +413,13 @@ struct Config { */ bool seek_also_selects; + /** + * @brief Automatically seek to the beginning of a sequence if the user plays beyond the end of it + * + * TRUE if this behavior should be enabled. + */ + bool auto_seek_to_beginning; + /** * @brief CSS Path * diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 510bc6263..7e17bb583 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -402,7 +402,7 @@ void Viewer::play(bool in_to_out) { if (!is_recording_cued() && playback_speed >= 0 && (playing_in_to_out - || seq->playhead >= sequence_end_frame + || (olive::CurrentConfig.auto_seek_to_beginning && seq->playhead >= sequence_end_frame) || (seek_to_in && seq->playhead >= seq->workarea_out))) { seek(seek_to_in ? seq->workarea_in : 0); } @@ -890,7 +890,8 @@ void Viewer::timer_update() { pause(); } } else if (playback_speed > 0) { - if (seq->playhead >= seq->getEndFrame()) { + long end_frame = seq->getEndFrame(); + if ((olive::CurrentConfig.auto_seek_to_beginning || previous_playhead < end_frame) && seq->playhead >= end_frame) { pause(); } if (seq->using_workarea && seq->playhead >= seq->workarea_out) {