summaryrefslogtreecommitdiff
path: root/src/wx/config_dialog.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-02 12:27:14 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-02 19:22:59 +0100
commita073de1b022b362347d46b7895dc946d6506cf95 (patch)
tree8e8cfb6e0dccbf12cd76a2da6b7a2f742ff87e6d /src/wx/config_dialog.cc
parent68a61d00f3754f6fc473f6ac86fb3abfe670d190 (diff)
Move General preferences tab parent to its own file.
Diffstat (limited to 'src/wx/config_dialog.cc')
-rw-r--r--src/wx/config_dialog.cc226
1 files changed, 0 insertions, 226 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index 178e8fca8..0d95b4118 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -101,229 +101,3 @@ Page::window_destroyed()
}
-GeneralPage::GeneralPage(wxSize panel_size, int border)
- : Page(panel_size, border)
-{
-
-}
-
-
-wxString
-GeneralPage::GetName() const
-{
- return _("General");
-}
-
-
-void
-GeneralPage::add_language_controls(wxGridBagSizer* table, int& r)
-{
- _set_language = new CheckBox(_panel, _("Set language"));
- table->Add(_set_language, wxGBPosition(r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
- _language = new wxChoice(_panel, wxID_ANY);
- vector<pair<string, string>> languages;
- languages.push_back(make_pair("Čeština", "cs_CZ"));
- languages.push_back(make_pair("汉语/漢語", "zh_CN"));
- languages.push_back(make_pair("Dansk", "da_DK"));
- languages.push_back(make_pair("Deutsch", "de_DE"));
- languages.push_back(make_pair("English", "en_GB"));
- languages.push_back(make_pair("Español", "es_ES"));
- languages.push_back(make_pair("فارسی", "fa_IR"));
- languages.push_back(make_pair("Français", "fr_FR"));
- languages.push_back(make_pair("Italiano", "it_IT"));
- languages.push_back(make_pair("Nederlands", "nl_NL"));
- languages.push_back(make_pair("Русский", "ru_RU"));
- languages.push_back(make_pair("Polski", "pl_PL"));
- languages.push_back(make_pair("Português europeu", "pt_PT"));
- languages.push_back(make_pair("Português do Brasil", "pt_BR"));
- languages.push_back(make_pair("Svenska", "sv_SE"));
- languages.push_back(make_pair("Slovenščina", "sl_SI"));
- languages.push_back(make_pair("Slovenský jazyk", "sk_SK"));
- // languages.push_back(make_pair("Türkçe", "tr_TR"));
- languages.push_back(make_pair("українська мова", "uk_UA"));
- languages.push_back(make_pair("Magyar nyelv", "hu_HU"));
- checked_set(_language, languages);
- table->Add(_language, wxGBPosition(r, 1));
- ++r;
-
- auto restart = add_label_to_sizer(
- table, _panel, variant::wx::insert_dcpomatic(_("(restart %s to see language changes)")), false, wxGBPosition(r, 0), wxGBSpan(1, 2)
- );
- wxFont font = restart->GetFont();
- font.SetStyle(wxFONTSTYLE_ITALIC);
- font.SetPointSize(font.GetPointSize() - 1);
- restart->SetFont(font);
- ++r;
-
- _set_language->bind(&GeneralPage::set_language_changed, this);
- _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)
-{
- _check_for_updates = new CheckBox(_panel, _("Check for updates on startup"));
- table->Add(_check_for_updates, wxGBPosition(r, 0), wxGBSpan(1, 2));
- ++r;
-
- _check_for_test_updates = new CheckBox(_panel, _("Check for testing updates on startup"));
- table->Add(_check_for_test_updates, wxGBPosition(r, 0), wxGBSpan(1, 2));
- ++r;
-
- _check_for_updates->bind(&GeneralPage::check_for_updates_changed, this);
- _check_for_test_updates->bind(&GeneralPage::check_for_test_updates_changed, this);
-}
-
-void
-GeneralPage::config_changed()
-{
- auto config = Config::instance();
-
- checked_set(_set_language, static_cast<bool>(config->language()));
-
- /* Backwards compatibility of config file */
-
- map<string, string> compat_map;
- compat_map["fr"] = "fr_FR";
- compat_map["it"] = "it_IT";
- compat_map["es"] = "es_ES";
- compat_map["sv"] = "sv_SE";
- compat_map["de"] = "de_DE";
- compat_map["nl"] = "nl_NL";
- compat_map["ru"] = "ru_RU";
- compat_map["pl"] = "pl_PL";
- compat_map["da"] = "da_DK";
- compat_map["pt"] = "pt_PT";
- compat_map["sk"] = "sk_SK";
- compat_map["cs"] = "cs_CZ";
- compat_map["uk"] = "uk_UA";
-
- auto lang = config->language().get_value_or("en_GB");
- if (compat_map.find(lang) != compat_map.end()) {
- lang = compat_map[lang];
- }
-
- 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());
-
- setup_sensitivity();
-}
-
-void
-GeneralPage::setup_sensitivity()
-{
- _language->Enable(_set_language->GetValue());
- _check_for_test_updates->Enable(_check_for_updates->GetValue());
-}
-
-void
-GeneralPage::set_language_changed()
-{
- setup_sensitivity();
- if (_set_language->GetValue()) {
- language_changed();
- } else {
- Config::instance()->unset_language();
- }
-}
-
-void
-GeneralPage::language_changed()
-{
- int const sel = _language->GetSelection();
- if (sel != -1) {
- Config::instance()->set_language(string_client_data(_language->GetClientObject(sel)));
- } else {
- Config::instance()->unset_language();
- }
-}
-
-void
-GeneralPage::check_for_updates_changed()
-{
- Config::instance()->set_check_for_updates(_check_for_updates->GetValue());
-}
-
-void
-GeneralPage::check_for_test_updates_changed()
-{
- Config::instance()->set_check_for_test_updates(_check_for_test_updates->GetValue());
-}
-
-