X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fwx%2Fconfig_dialog.cc;h=adf039e41f09045ab2b49b1f174abf55c8ef9efc;hb=7f8062032e16d9c9cfc28659a6da67f8205dc27b;hp=4b55c12545c0223b38c03cc5c2bd39b7624b4a6f;hpb=c317087f637eeaa88c00a7b415b1d42ab28ba031;p=dcpomatic.git diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 4b55c1254..adf039e41 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -23,9 +23,10 @@ #include #include +#include +#include #include "lib/config.h" #include "lib/server.h" -#include "lib/screen.h" #include "lib/format.h" #include "lib/scaler.h" #include "lib/filter.h" @@ -33,12 +34,13 @@ #include "wx_util.h" #include "filter_dialog.h" #include "server_dialog.h" +#include "dir_picker_ctrl.h" using namespace std; -using namespace boost; +using boost::bind; ConfigDialog::ConfigDialog (wxWindow* parent) - : wxDialog (parent, wxID_ANY, _("DVD-o-matic Configuration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + : wxDialog (parent, wxID_ANY, _("DVD-o-matic Preferences"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { wxFlexGridSizer* table = new wxFlexGridSizer (3, 6, 6); table->AddGrowableCol (1, 1); @@ -68,10 +70,20 @@ ConfigDialog::ConfigDialog (wxWindow* parent) table->Add (_num_local_encoding_threads, 1, wxEXPAND); table->AddSpacer (0); + add_label_to_sizer (table, this, "Default directory for new films"); +#ifdef __WXMSW__ + _default_directory = new DirPickerCtrl (this); +#else + _default_directory = new wxDirPickerCtrl (this, wxDD_DIR_MUST_EXIST); +#endif + table->Add (_default_directory, 1, wxEXPAND); + table->AddSpacer (0); + add_label_to_sizer (table, this, "Colour look-up table"); _colour_lut = new wxComboBox (this, wxID_ANY); - _colour_lut->Append (wxT ("sRGB")); - _colour_lut->Append (wxT ("Rec 709")); + for (int i = 0; i < 2; ++i) { + _colour_lut->Append (std_to_wx (colour_lut_index_to_name (i))); + } _colour_lut->SetSelection (0); table->Add (_colour_lut, 1, wxEXPAND); table->AddSpacer (0); @@ -103,17 +115,17 @@ ConfigDialog::ConfigDialog (wxWindow* parent) } add_label_to_sizer (table, this, "Encoding Servers"); - _servers = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); + _servers = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (220, 100), wxLC_REPORT | wxLC_SINGLE_SEL); wxListItem ip; ip.SetId (0); ip.SetText (_("IP address")); - ip.SetWidth (100); + ip.SetWidth (120); _servers->InsertColumn (0, ip); ip.SetId (1); ip.SetText (_("Threads")); - ip.SetWidth (90); + ip.SetWidth (80); _servers->InsertColumn (1, ip); - table->Add (_servers, 1, wxEXPAND); + table->Add (_servers, 1, wxEXPAND | wxALL); { wxSizer* s = new wxBoxSizer (wxVERTICAL); @@ -141,10 +153,13 @@ ConfigDialog::ConfigDialog (wxWindow* parent) _num_local_encoding_threads->SetValue (config->num_local_encoding_threads ()); _num_local_encoding_threads->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (ConfigDialog::num_local_encoding_threads_changed), 0, this); + _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())))); + _default_directory->Connect (wxID_ANY, wxEVT_COMMAND_DIRPICKER_CHANGED, wxCommandEventHandler (ConfigDialog::default_directory_changed), 0, this); + _colour_lut->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (ConfigDialog::colour_lut_changed), 0, this); _j2k_bandwidth->SetRange (50, 250); - _j2k_bandwidth->SetValue (config->j2k_bandwidth() / 1e6); + _j2k_bandwidth->SetValue (rint ((double) config->j2k_bandwidth() / 1e6)); _j2k_bandwidth->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (ConfigDialog::j2k_bandwidth_changed), 0, this); _reference_scaler->SetSelection (Scaler::as_index (config->reference_scaler ())); @@ -154,20 +169,22 @@ ConfigDialog::ConfigDialog (wxWindow* parent) _reference_filters->SetLabel (std_to_wx (p.first + " " + p.second)); _reference_filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_reference_filters_clicked), 0, this); - vector servers = config->servers (); - for (vector::iterator i = servers.begin(); i != servers.end(); ++i) { + vector servers = config->servers (); + for (vector::iterator i = servers.begin(); i != servers.end(); ++i) { add_server_to_control (*i); } _add_server->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::add_server_clicked), 0, this); + _edit_server->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_server_clicked), 0, this); _remove_server->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::remove_server_clicked), 0, this); - _servers->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (ConfigDialog::server_selection_changed)); + _servers->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (ConfigDialog::server_selection_changed), 0, this); + _servers->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler (ConfigDialog::server_selection_changed), 0, this); wxListEvent ev; server_selection_changed (ev); wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 1, wxEXPAND); + overall_sizer->Add (table, 1, wxEXPAND | wxALL, 6); wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); if (buttons) { @@ -209,6 +226,12 @@ ConfigDialog::num_local_encoding_threads_changed (wxCommandEvent &) Config::instance()->set_num_local_encoding_threads (_num_local_encoding_threads->GetValue ()); } +void +ConfigDialog::default_directory_changed (wxCommandEvent &) +{ + Config::instance()->set_default_directory (wx_to_std (_default_directory->GetPath ())); +} + void ConfigDialog::colour_lut_changed (wxCommandEvent &) { @@ -222,7 +245,7 @@ ConfigDialog::j2k_bandwidth_changed (wxCommandEvent &) } void -ConfigDialog::add_server_to_control (Server* s) +ConfigDialog::add_server_to_control (ServerDescription* s) { wxListItem item; int const n = _servers->GetItemCount (); @@ -237,10 +260,13 @@ ConfigDialog::add_server_clicked (wxCommandEvent &) { ServerDialog* d = new ServerDialog (this, 0); d->ShowModal (); - Server* s = d->server (); + ServerDescription* s = d->server (); d->Destroy (); add_server_to_control (s); + vector o = Config::instance()->servers (); + o.push_back (s); + Config::instance()->set_servers (o); } void @@ -256,7 +282,15 @@ ConfigDialog::edit_server_clicked (wxCommandEvent &) item.SetColumn (0); _servers->GetItem (item); - /* XXX: partial */ + vector servers = Config::instance()->servers (); + assert (i >= 0 && i < int (servers.size ())); + + ServerDialog* d = new ServerDialog (this, servers[i]); + d->ShowModal (); + d->Destroy (); + + _servers->SetItem (i, 0, std_to_wx (servers[i]->host_name ())); + _servers->SetItem (i, 1, std_to_wx (boost::lexical_cast (servers[i]->threads ()))); } void @@ -266,12 +300,18 @@ ConfigDialog::remove_server_clicked (wxCommandEvent &) if (i >= 0) { _servers->DeleteItem (i); } + + vector o = Config::instance()->servers (); + o.erase (o.begin() + i); + Config::instance()->set_servers (o); } void -ConfigDialog::server_selection_changed (wxListEvent& ev) +ConfigDialog::server_selection_changed (wxListEvent &) { -// _remove_server->Enable (ev.GetIndex() >= 0); + int const i = _servers->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + _edit_server->Enable (i >= 0); + _remove_server->Enable (i >= 0); } void @@ -287,7 +327,7 @@ void ConfigDialog::edit_reference_filters_clicked (wxCommandEvent &) { FilterDialog* d = new FilterDialog (this, Config::instance()->reference_filters ()); - d->ActiveChanged.connect (sigc::mem_fun (*this, &ConfigDialog::reference_filters_changed)); + d->ActiveChanged.connect (boost::bind (&ConfigDialog::reference_filters_changed, this, _1)); d->ShowModal (); d->Destroy (); }