Exciting new Alt/h help key provided by sge (Georgy) with many thanks!
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / preferencesthread.C
index e273813615b865f617e6af2a8d56f00f1514f9ce..3ca281e54e6fe08cc1cfa7cf2c104f03b2871998 100644 (file)
@@ -102,12 +102,10 @@ PreferencesThread::PreferencesThread(MWindow *mwindow)
        this->mwindow = mwindow;
        window = 0;
        thread_running = 0;
-       confirm_dialog = 0;
 }
 
 PreferencesThread::~PreferencesThread()
 {
-       delete confirm_dialog;
        close_window();
 }
 
@@ -126,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;
 
@@ -239,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 ||
@@ -252,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);
@@ -267,12 +273,16 @@ 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");
+       mwindow->gui->lock_window("PreferencesThread::apply_settings 6");
        mwindow->gui->ffmpeg_toggle->update(ffmpeg_early_probe);
        mwindow->gui->ffmpeg_toggle->set_tooltip(ffmpeg_early_probe ?
                FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP);
+       mwindow->gui->unlock_window();
        mwindow->gui->mainshbtns->load(mwindow->preferences);
        mwindow->init_brender();
 
@@ -378,13 +388,6 @@ const char *PreferencesThread::busy()
        return 0;
 }
 
-void PreferencesThread::confirm_update(const char *reason, int close)
-{
-       delete confirm_dialog;
-       confirm_dialog = new PreferencesConfirmDialog(this, reason, close);
-       confirm_dialog->start();
-}
-
 const char* PreferencesThread::category_to_text(int category)
 {
        PlaybackConfig *playback_config = edl->session->playback_config;
@@ -434,19 +437,19 @@ PreferencesWindow::PreferencesWindow(MWindow *mwindow,
 {
        this->mwindow = mwindow;
        this->thread = thread;
-       dialog = 0;
        category = 0;
+       dialog = 0;
+       confirm_dialog = 0;
+// *** CONTEXT_HELP ***
+       context_help_set_keyword("Settings and Preferences");
 }
 
 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();
@@ -517,6 +520,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)
 {
@@ -653,7 +663,7 @@ int PreferencesApply::handle_event()
 {
        const char *reason = thread->busy();
        if( reason )
-               thread->confirm_update(reason, 0);
+               thread->window->confirm_update(reason, 0);
        else {
                thread->apply_settings();
                mwindow->save_defaults();
@@ -683,14 +693,14 @@ int PreferencesOK::keypress_event()
 {
        if( get_keypress() == RETURN )
                return handle_event();
-       return 0;
+       return context_help_check_and_show();
 }
 
 int PreferencesOK::handle_event()
 {
        const char *reason = mwindow->restart() ? _("restart") : thread->busy();
        if( reason )
-               thread->confirm_update(reason, 1);
+               thread->window->confirm_update(reason, 1);
        else
                thread->window->set_done(0);
        return 1;
@@ -711,6 +721,7 @@ PreferencesConfirmDialog::PreferencesConfirmDialog(PreferencesThread *thread,
 }
 PreferencesConfirmDialog::~PreferencesConfirmDialog()
 {
+       close_window();
 }
 BC_Window *PreferencesConfirmDialog::new_gui()
 {
@@ -720,7 +731,7 @@ BC_Window *PreferencesConfirmDialog::new_gui()
 }
 void PreferencesConfirmDialog::handle_done_event(int result)
 {
-       if( !result ) return; // no
+       if( result != 2 ) return; // not yes
        if( !close ) {
                thread->window->lock_window("PreferencesConfirmDialog::handle_done_event");
                thread->apply_settings();
@@ -756,7 +767,7 @@ int PreferencesCancel::keypress_event()
                thread->window->set_done(1);
                return 1;
        }
-       return 0;
+       return context_help_check_and_show();
 }
 int PreferencesCancel::handle_event()
 {