X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpreferencesthread.C;h=e273813615b865f617e6af2a8d56f00f1514f9ce;hp=73d8d5d4e4ab06b717729af0bee3911d5d9c5334;hb=5ec378f09aeeb646705fdb8035b39a186374fba0;hpb=e620b69f6d3f1de30d8b2a16c46d7729462e5211 diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index 73d8d5d4..e2738136 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" @@ -64,8 +66,8 @@ -#define WIDTH 860 -#define HEIGHT 700 +#define WIDTH xS(860) +#define HEIGHT yS(700) PreferencesMenuitem::PreferencesMenuitem(MWindow *mwindow) @@ -100,10 +102,12 @@ PreferencesThread::PreferencesThread(MWindow *mwindow) this->mwindow = mwindow; window = 0; thread_running = 0; + confirm_dialog = 0; } PreferencesThread::~PreferencesThread() { + delete confirm_dialog; close_window(); } @@ -125,7 +129,7 @@ BC_Window* PreferencesThread::new_gui() //int need_new_indexes = 0; rerender = 0; - mwindow->gui->lock_window("NewThread::new_gui"); + mwindow->gui->lock_window("NewThread::new_gui"); int scr_x = mwindow->gui->get_screen_x(0, -1); int scr_w = mwindow->gui->get_screen_w(0, -1); int scr_h = mwindow->gui->get_screen_h(0, -1); @@ -237,6 +241,7 @@ int PreferencesThread::apply_settings() if( strcmp(preferences->theme, mwindow->preferences->theme) || strcmp(preferences->plugin_icons, mwindow->preferences->plugin_icons) || preferences->awindow_picon_h != mwindow->preferences->awindow_picon_h || + preferences->layout_scale != mwindow->preferences->layout_scale || preferences->vicon_size != mwindow->preferences->vicon_size || preferences->vicon_color_mode != mwindow->preferences->vicon_color_mode ) mwindow->restart_status = -1; // reconstruct/restart program @@ -363,6 +368,23 @@ 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; +} + +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; @@ -406,12 +428,6 @@ SET_TRACE } - - - - - - PreferencesWindow::PreferencesWindow(MWindow *mwindow, PreferencesThread *thread, int x, int y, int w, int h) : BC_Window(_(PROGRAM_NAME ": Preferences"), x,y, w,h,w,h, 1) @@ -586,15 +602,6 @@ int PreferencesWindow::set_current_dialog(int number) } - - - - - - - - - PreferencesButton::PreferencesButton(MWindow *mwindow, PreferencesThread *thread, int x, @@ -616,19 +623,11 @@ int PreferencesButton::handle_event() } - - - - - - - PreferencesDialog::PreferencesDialog(MWindow *mwindow, PreferencesWindow *pwindow) - : BC_SubWindow(10, - 40, - pwindow->get_w() - 20, - pwindow->get_h() - BC_GenericButton::calculate_h() - 10 - 40) + : BC_SubWindow(xS(10), yS(40), + pwindow->get_w() - xS(20), + pwindow->get_h() - BC_GenericButton::calculate_h() - yS(10 + 40)) { this->pwindow = pwindow; this->mwindow = mwindow; @@ -639,14 +638,12 @@ PreferencesDialog::~PreferencesDialog() { } -// ============================== category window - - +// ============================== category window PreferencesApply::PreferencesApply(MWindow *mwindow, PreferencesThread *thread) : BC_GenericButton(thread->window->get_w() / 2 - BC_GenericButton::calculate_w(thread->window, _("Apply")) / 2, - thread->window->get_h() - BC_GenericButton::calculate_h() - 10, + thread->window->get_h() - BC_GenericButton::calculate_h() - yS(10), _("Apply")) { this->mwindow = mwindow; @@ -654,53 +651,100 @@ PreferencesApply::PreferencesApply(MWindow *mwindow, PreferencesThread *thread) } int PreferencesApply::handle_event() { - thread->apply_settings(); - mwindow->save_defaults(); + const char *reason = thread->busy(); + if( reason ) + thread->confirm_update(reason, 0); + else { + thread->apply_settings(); + mwindow->save_defaults(); + } return 1; } int PreferencesApply::resize_event(int w, int h) { - reposition_window(w/2 - get_w()/2, h-get_h()-10); + reposition_window(w/2 - get_w()/2, h-get_h()-yS(10)); return 1; } - - PreferencesOK::PreferencesOK(MWindow *mwindow, PreferencesThread *thread) - : BC_GenericButton(10, - thread->window->get_h() - BC_GenericButton::calculate_h() - 10, + : BC_GenericButton(xS(10), + thread->window->get_h() - BC_GenericButton::calculate_h() - yS(10), _("OK")) { 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->confirm_update(reason, 1); + else + thread->window->set_done(0); return 1; } int PreferencesOK::resize_event(int w, int h) { - reposition_window(10, h-get_h()-10); + reposition_window(xS(10), h-get_h()-yS(10)); return 1; } +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() +{ +} +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 ) return; // no + 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")) - 10, - thread->window->get_h() - BC_GenericButton::calculate_h() - 10, - _("Cancel")) + : 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), + _("Cancel")) { this->mwindow = mwindow; this->thread = thread; @@ -721,27 +765,16 @@ int PreferencesCancel::handle_event() } int PreferencesCancel::resize_event(int w, int h) { - reposition_window(w-get_w()-10, h-get_h()-10); + reposition_window(w-get_w()-xS(10), h-get_h()-yS(10)); return 1; } - - - - - - - - PreferencesCategory::PreferencesCategory(MWindow *mwindow, PreferencesThread *thread, int x, int y) : BC_PopupTextBox(thread->window, &thread->window->categories, thread->category_to_text(thread->current_dialog), - x, - y, - 200, - 150) + x, y, xS(200), yS(150)) { this->mwindow = mwindow; this->thread = thread;