X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpreferencesthread.C;h=47f16efd8345f2594f11e081d66b6ed08ccc9ce6;hp=23494e709b54e2c5bf5fba93c734bf5962e789ea;hb=45a8ba3455cf252332c03533a7590df5267ce9aa;hpb=6ff8b339d215bb1c2cef589fd7959aa2e1834105 diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index 23494e70..47f16efd 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -52,7 +52,9 @@ #include "playbackengine.h" #include "playbackprefs.h" #include "preferences.h" +#include "record.h" #include "recordprefs.h" +#include "render.h" #include "shbtnprefs.h" #include "theme.h" #include "trackcanvas.h" @@ -122,6 +124,7 @@ BC_Window* PreferencesThread::new_gui() redraw_overlays = 0; close_assets = 0; reload_plugins = 0; + reset_caches = 0; //int need_new_indexes = 0; rerender = 0; @@ -235,6 +238,7 @@ int PreferencesThread::apply_settings() if( window ) window->lock_window("PreferencesThread::apply_settings 5"); if( strcmp(preferences->theme, mwindow->preferences->theme) || + strcmp(preferences->locale, mwindow->preferences->locale) || strcmp(preferences->plugin_icons, mwindow->preferences->plugin_icons) || preferences->awindow_picon_h != mwindow->preferences->awindow_picon_h || preferences->layout_scale != mwindow->preferences->layout_scale || @@ -248,9 +252,15 @@ int PreferencesThread::apply_settings() File::setenv_path("LV2_PATH", preferences->lv2_path, 1); mwindow->restart_status = -1; } + if( preferences->cache_size != mwindow->preferences->cache_size || + preferences->cache_transitions != mwindow->preferences->cache_transitions ) + reset_caches = 1; + + if( mwindow->preferences->perpetual_session && !preferences->perpetual_session ) + mwindow->remove_undo_data(); mwindow->edl->copy_session(edl, 1); - mwindow->preferences->copy_from(preferences); + mwindow->update_preferences(preferences); BC_Signals::set_catch_segv(mwindow->preferences->trap_sigsegv); BC_Signals::set_catch_intr(mwindow->preferences->trap_sigintr); @@ -263,6 +273,8 @@ int PreferencesThread::apply_settings() else { BC_Trace::disable_locks(); } + if( reset_caches ) + mwindow->reset_caches(0); mwindow->reset_android_remote(); int ffmpeg_early_probe = mwindow->preferences->get_file_probe_armed("FFMPEG_Early"); @@ -364,6 +376,16 @@ int PreferencesThread::apply_settings() return 0; } +const char *PreferencesThread::busy() +{ + if( mwindow->render->thread->running() ) + return _("render"); + Record *record = mwindow->gui->record; + if( record->capturing || record->recording || record->writing_file ) + return _("record"); + return 0; +} + const char* PreferencesThread::category_to_text(int category) { PlaybackConfig *playback_config = edl->session->playback_config; @@ -413,19 +435,17 @@ PreferencesWindow::PreferencesWindow(MWindow *mwindow, { this->mwindow = mwindow; this->thread = thread; - dialog = 0; category = 0; + dialog = 0; + confirm_dialog = 0; } PreferencesWindow::~PreferencesWindow() { lock_window("PreferencesWindow::~PreferencesWindow"); delete category; - - - if(dialog) delete dialog; - - + delete dialog; + delete confirm_dialog; for(int i = 0; i < categories.total; i++) delete categories.values[i]; unlock_window(); @@ -496,6 +516,13 @@ void PreferencesWindow::update_rates() unlock_window(); } +void PreferencesWindow::confirm_update(const char *reason, int close) +{ + delete confirm_dialog; + confirm_dialog = new PreferencesConfirmDialog(thread, reason, close); + confirm_dialog->start(); +} + int PreferencesWindow::set_current_dialog(int number) { @@ -630,8 +657,13 @@ PreferencesApply::PreferencesApply(MWindow *mwindow, PreferencesThread *thread) } int PreferencesApply::handle_event() { - thread->apply_settings(); - mwindow->save_defaults(); + const char *reason = thread->busy(); + if( reason ) + thread->window->confirm_update(reason, 0); + else { + thread->apply_settings(); + mwindow->save_defaults(); + } return 1; } int PreferencesApply::resize_event(int w, int h) @@ -649,18 +681,24 @@ PreferencesOK::PreferencesOK(MWindow *mwindow, PreferencesThread *thread) this->mwindow = mwindow; this->thread = thread; } +PreferencesOK::~PreferencesOK() +{ +} + int PreferencesOK::keypress_event() { - if(get_keypress() == RETURN) - { - thread->window->set_done(0); - return 1; - } + if( get_keypress() == RETURN ) + return handle_event(); return 0; } + int PreferencesOK::handle_event() { - thread->window->set_done(0); + const char *reason = mwindow->restart() ? _("restart") : thread->busy(); + if( reason ) + thread->window->confirm_update(reason, 1); + else + thread->window->set_done(0); return 1; } int PreferencesOK::resize_event(int w, int h) @@ -670,6 +708,46 @@ int PreferencesOK::resize_event(int w, int h) } +PreferencesConfirmDialog::PreferencesConfirmDialog(PreferencesThread *thread, + const char *reason, int close) +{ + this->thread = thread; + this->close = close; + sprintf(query, _("Busy: %s in progress. Are you sure?"), reason); +} +PreferencesConfirmDialog::~PreferencesConfirmDialog() +{ + close_window(); +} +BC_Window *PreferencesConfirmDialog::new_gui() +{ + qwindow = new PreferencesConfirmWindow(this); + qwindow->create_objects(query, 0); + return qwindow; +} +void PreferencesConfirmDialog::handle_done_event(int result) +{ + if( result != 2 ) return; // not yes + if( !close ) { + thread->window->lock_window("PreferencesConfirmDialog::handle_done_event"); + thread->apply_settings(); + thread->mwindow->save_defaults(); + thread->window->unlock_window(); + } + else + thread->window->set_done(0); +} + +PreferencesConfirmWindow::PreferencesConfirmWindow(PreferencesConfirmDialog *dialog) + : QuestionWindow(dialog->thread->mwindow) +{ + this->dialog = dialog; +} +PreferencesConfirmWindow::~PreferencesConfirmWindow() +{ +} + + PreferencesCancel::PreferencesCancel(MWindow *mwindow, PreferencesThread *thread) : BC_GenericButton(thread->window->get_w() - BC_GenericButton::calculate_w(thread->window, _("Cancel")) - xS(10), thread->window->get_h() - BC_GenericButton::calculate_h() - yS(10),