diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-02 00:40:23 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-02 00:40:23 +0100 |
| commit | f1c4d11e07f143888fdf82aa533712b675741303 (patch) | |
| tree | 3db2a0fbbbd9561f492e4d397aa8aa60fd5ff178 /src | |
| parent | 7bf9cf9c047a2df19e19d557a86f34585453660d (diff) | |
Move config file location config up to the general dialogue.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/config_dialog.cc | 76 | ||||
| -rw-r--r-- | src/wx/config_dialog.h | 6 | ||||
| -rw-r--r-- | src/wx/full_config_dialog.cc | 64 |
3 files changed, 83 insertions, 63 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 95c168e8e..6b5669722 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -24,7 +24,9 @@ #include "certificate_chain_editor.h" #include "check_box.h" #include "config_dialog.h" +#include "config_move_dialog.h" #include "dcpomatic_button.h" +#include "file_picker_ctrl.h" #include "nag_dialog.h" #include "static_text.h" #include "wx_variant.h" @@ -164,6 +166,77 @@ GeneralPage::add_language_controls(wxGridBagSizer* table, int& r) _language->Bind(wxEVT_CHOICE, bind(&GeneralPage::language_changed, this)); } + +void +GeneralPage::add_config_file_controls(wxGridBagSizer* table, int& r) +{ + add_label_to_sizer(table, _panel, _("Configuration file"), true, wxGBPosition(r, 0)); + _config_file = new FilePickerCtrl(_panel, _("Select configuration file"), char_to_wx("*.xml"), true, false, "ConfigFilePath"); + table->Add(_config_file, wxGBPosition(r, 1)); + ++r; + + add_label_to_sizer(table, _panel, _("Cinema and screen database file"), true, wxGBPosition(r, 0)); + _cinemas_file = new FilePickerCtrl(_panel, _("Select cinema and screen database file"), char_to_wx("*.sqlite3"), true, false, "CinemaDatabasePath"); + table->Add(_cinemas_file, wxGBPosition(r, 1)); + auto export_cinemas = new Button(_panel, _("Export...")); + table->Add(export_cinemas, wxGBPosition(r, 2)); + ++r; + + export_cinemas->Bind(wxEVT_BUTTON, boost::bind(&GeneralPage::export_cinemas_file, this)); + _config_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind(&GeneralPage::config_file_changed, this)); + _cinemas_file->Bind(wxEVT_FILEPICKER_CHANGED, boost::bind(&GeneralPage::cinemas_file_changed, this)); +} + + +void +GeneralPage::config_file_changed() +{ + auto config = Config::instance(); + auto const new_file = _config_file->path(); + if (!new_file || *new_file == config->config_read_file()) { + return; + } + bool copy_and_link = true; + if (dcp::filesystem::exists(*new_file)) { + ConfigMoveDialog dialog(_panel, *new_file); + if (dialog.ShowModal() == wxID_OK) { + copy_and_link = false; + } + } + + if (copy_and_link) { + config->write(); + if (new_file != config->config_read_file()) { + config->copy_and_link(*new_file); + } + } else { + config->link(*new_file); + } +} + +void +GeneralPage::cinemas_file_changed() +{ + if (auto path = _cinemas_file->path()) { + Config::instance()->set_cinemas_file(*path); + } +} + + +void +GeneralPage::export_cinemas_file() +{ + wxFileDialog dialog( + _panel, _("Select Cinemas File"), wxEmptyString, wxEmptyString, char_to_wx("SQLite files (*.sqlite3)|*.sqlite3"), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT + ); + + if (dialog.ShowModal() == wxID_OK) { + dcp::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(dialog.GetPath()), dcp::filesystem::CopyOptions::OVERWRITE_EXISTING); + } +} + + void GeneralPage::add_update_controls(wxGridBagSizer* table, int& r) { @@ -210,6 +283,9 @@ GeneralPage::config_changed() checked_set(_language, lang); + checked_set(_config_file, config->config_read_file()); + checked_set(_cinemas_file, config->cinemas_file()); + checked_set(_check_for_updates, config->check_for_updates()); checked_set(_check_for_test_updates, config->check_for_test_updates()); diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index 736562384..77b8b2b5e 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -98,6 +98,7 @@ public: protected: void add_language_controls(wxGridBagSizer* table, int& r); + void add_config_file_controls(wxGridBagSizer* table, int& r); void add_update_controls(wxGridBagSizer* table, int& r); void config_changed() override; @@ -105,11 +106,16 @@ private: void setup_sensitivity(); void set_language_changed(); void language_changed(); + void config_file_changed(); + void cinemas_file_changed(); + void export_cinemas_file(); void check_for_updates_changed(); void check_for_test_updates_changed(); CheckBox* _set_language; wxChoice* _language; + FilePickerCtrl* _config_file; + FilePickerCtrl* _cinemas_file; CheckBox* _check_for_updates; CheckBox* _check_for_test_updates; }; diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 76efbbab9..016fb15f9 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -120,17 +120,7 @@ private: table->Add(_server_encoding_threads, wxGBPosition(r, 1)); ++r; - add_label_to_sizer(table, _panel, _("Configuration file"), true, wxGBPosition(r, 0)); - _config_file = new FilePickerCtrl(_panel, _("Select configuration file"), char_to_wx("*.xml"), true, false, "ConfigFilePath"); - table->Add(_config_file, wxGBPosition(r, 1)); - ++r; - - add_label_to_sizer(table, _panel, _("Cinema and screen database file"), true, wxGBPosition(r, 0)); - _cinemas_file = new FilePickerCtrl(_panel, _("Select cinema and screen database file"), char_to_wx("*.sqlite3"), true, false, "CinemaDatabasePath"); - table->Add(_cinemas_file, wxGBPosition(r, 1)); - auto export_cinemas = new Button(_panel, _("Export...")); - table->Add(export_cinemas, wxGBPosition(r, 2)); - ++r; + add_config_file_controls(table, r); add_label_to_sizer(table, _panel, _("Default \"add file\" location"), true, wxGBPosition(r, 0)); _default_add_file_location = new Choice(_panel); @@ -157,14 +147,10 @@ private: _default_add_file_location->add_entry(_("Same place as project")); _default_add_file_location->bind(&FullGeneralPage::default_add_file_location_changed, this); - _config_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind(&FullGeneralPage::config_file_changed, this)); - _cinemas_file->Bind(wxEVT_FILEPICKER_CHANGED, boost::bind(&FullGeneralPage::cinemas_file_changed, this)); - _master_encoding_threads->SetRange(1, 128); _master_encoding_threads->Bind(wxEVT_SPINCTRL, boost::bind(&FullGeneralPage::master_encoding_threads_changed, this)); _server_encoding_threads->SetRange(1, 128); _server_encoding_threads->Bind(wxEVT_SPINCTRL, boost::bind(&FullGeneralPage::server_encoding_threads_changed, this)); - export_cinemas->Bind(wxEVT_BUTTON, boost::bind(&FullGeneralPage::export_cinemas_file, this)); _relative_paths->bind(&FullGeneralPage::relative_paths_changed, this); #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG @@ -184,25 +170,11 @@ private: checked_set(_analyse_ebur128, config->analyse_ebur128()); #endif checked_set(_automatic_audio_analysis, config->automatic_audio_analysis()); - checked_set(_config_file, config->config_read_file()); - checked_set(_cinemas_file, config->cinemas_file()); checked_set(_default_add_file_location, config->default_add_file_location() == Config::DefaultAddFileLocation::SAME_AS_LAST_TIME ? 0 : 1); GeneralPage::config_changed(); } - void export_cinemas_file() - { - wxFileDialog dialog( - _panel, _("Select Cinemas File"), wxEmptyString, wxEmptyString, char_to_wx("SQLite files (*.sqlite3)|*.sqlite3"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT - ); - - if (dialog.ShowModal() == wxID_OK) { - dcp::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(dialog.GetPath()), dcp::filesystem::CopyOptions::OVERWRITE_EXISTING); - } - } - void relative_paths_changed() { Config::instance()->set_relative_paths(_relative_paths->get()); @@ -230,38 +202,6 @@ private: Config::instance()->set_server_encoding_threads(_server_encoding_threads->GetValue()); } - void config_file_changed() - { - auto config = Config::instance(); - auto const new_file = _config_file->path(); - if (!new_file || *new_file == config->config_read_file()) { - return; - } - bool copy_and_link = true; - if (dcp::filesystem::exists(*new_file)) { - ConfigMoveDialog dialog(_panel, *new_file); - if (dialog.ShowModal() == wxID_OK) { - copy_and_link = false; - } - } - - if (copy_and_link) { - config->write(); - if (new_file != config->config_read_file()) { - config->copy_and_link(*new_file); - } - } else { - config->link(*new_file); - } - } - - void cinemas_file_changed() - { - if (auto path = _cinemas_file->path()) { - Config::instance()->set_cinemas_file(*path); - } - } - void default_add_file_location_changed() { Config::instance()->set_default_add_file_location( @@ -272,8 +212,6 @@ private: Choice* _default_add_file_location; wxSpinCtrl* _master_encoding_threads; wxSpinCtrl* _server_encoding_threads; - FilePickerCtrl* _config_file; - FilePickerCtrl* _cinemas_file; CheckBox* _relative_paths; #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG CheckBox* _analyse_ebur128; |
