#include <boost/filesystem.hpp>
#include <wx/stdpaths.h>
#include <wx/notebook.h>
+#include <libdcp/colour_matrix.h>
#include "lib/config.h"
-#include "lib/server.h"
#include "lib/ratio.h"
#include "lib/scaler.h"
#include "lib/filter.h"
#include "lib/dcp_content_type.h"
+#include "lib/colour_conversion.h"
#include "config_dialog.h"
#include "wx_util.h"
#include "filter_dialog.h"
-#include "server_dialog.h"
#include "dir_picker_ctrl.h"
#include "dci_metadata_dialog.h"
+#include "preset_colour_conversion_dialog.h"
+#include "server_dialog.h"
-using namespace std;
+using std::vector;
+using std::string;
+using std::list;
using boost::bind;
+using boost::shared_ptr;
+using boost::lexical_cast;
ConfigDialog::ConfigDialog (wxWindow* parent)
: wxDialog (parent, wxID_ANY, _("DCP-o-matic Preferences"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
_notebook->AddPage (_misc_panel, _("Miscellaneous"), true);
make_servers_panel ();
_notebook->AddPage (_servers_panel, _("Encoding servers"), false);
+ make_colour_conversions_panel ();
+ _notebook->AddPage (_colour_conversions_panel, _("Colour conversions"), false);
make_metadata_panel ();
_notebook->AddPage (_metadata_panel, _("Metadata"), false);
make_tms_panel ();
_notebook->AddPage (_tms_panel, _("TMS"), false);
+ make_kdm_email_panel ();
+ _notebook->AddPage (_kdm_email_panel, _("KDM email"), false);
wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
overall_sizer->Add (s, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
_num_local_encoding_threads = new wxSpinCtrl (_misc_panel);
table->Add (_num_local_encoding_threads, 1);
+ add_label_to_sizer (table, _misc_panel, _("Outgoing mail server"), true);
+ _mail_server = new wxTextCtrl (_misc_panel, wxID_ANY);
+ table->Add (_mail_server, 1, wxEXPAND | wxALL);
+
+ add_label_to_sizer (table, _misc_panel, _("From address for KDM emails"), true);
+ _kdm_from = new wxTextCtrl (_misc_panel, wxID_ANY);
+ table->Add (_kdm_from, 1, wxEXPAND | wxALL);
+
{
add_label_to_sizer (table, _misc_panel, _("Default duration of still images"), true);
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
_num_local_encoding_threads->SetValue (config->num_local_encoding_threads ());
_num_local_encoding_threads->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ConfigDialog::num_local_encoding_threads_changed, this));
+ _mail_server->SetValue (std_to_wx (config->mail_server ()));
+ _mail_server->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ConfigDialog::mail_server_changed, this));
+ _kdm_from->SetValue (std_to_wx (config->kdm_from ()));
+ _kdm_from->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ConfigDialog::kdm_from_changed, this));
+
_default_still_length->SetRange (1, 3600);
_default_still_length->SetValue (config->default_still_length ());
_default_still_length->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ConfigDialog::default_still_length_changed, this));
- _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()))));
+ _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
_default_directory->Bind (wxEVT_COMMAND_DIRPICKER_CHANGED, boost::bind (&ConfigDialog::default_directory_changed, this));
_default_dci_metadata_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ConfigDialog::edit_default_dci_metadata_clicked, this));
_default_dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ConfigDialog::default_dcp_content_type_changed, this));
_default_j2k_bandwidth->SetRange (50, 250);
- _default_j2k_bandwidth->SetValue (config->default_j2k_bandwidth() / 1e6);
+ _default_j2k_bandwidth->SetValue (config->default_j2k_bandwidth() / 1000000);
_default_j2k_bandwidth->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ConfigDialog::default_j2k_bandwidth_changed, this));
}
_creator->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ConfigDialog::creator_changed, this));
}
+static string
+server_column (string s)
+{
+ return s;
+}
+
void
ConfigDialog::make_servers_panel ()
{
wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
_servers_panel->SetSizer (s);
- wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- table->AddGrowableCol (0, 1);
- s->Add (table, 1, wxALL | wxEXPAND, 8);
-
- Config* config = Config::instance ();
-
- _servers = new wxListCtrl (_servers_panel, wxID_ANY, wxDefaultPosition, wxSize (220, 100), wxLC_REPORT | wxLC_SINGLE_SEL);
- wxListItem ip;
- ip.SetId (0);
- ip.SetText (_("IP address"));
- ip.SetWidth (120);
- _servers->InsertColumn (0, ip);
- ip.SetId (1);
- ip.SetText (_("Threads"));
- ip.SetWidth (80);
- _servers->InsertColumn (1, ip);
- table->Add (_servers, 1, wxEXPAND | wxALL);
-
- {
- wxSizer* s = new wxBoxSizer (wxVERTICAL);
- _add_server = new wxButton (_servers_panel, wxID_ANY, _("Add"));
- s->Add (_add_server, 0, wxTOP | wxBOTTOM, 2);
- _edit_server = new wxButton (_servers_panel, wxID_ANY, _("Edit"));
- s->Add (_edit_server, 0, wxTOP | wxBOTTOM, 2);
- _remove_server = new wxButton (_servers_panel, wxID_ANY, _("Remove"));
- s->Add (_remove_server, 0, wxTOP | wxBOTTOM, 2);
- table->Add (s, 0);
- }
-
- vector<ServerDescription*> servers = config->servers ();
- for (vector<ServerDescription*>::iterator i = servers.begin(); i != servers.end(); ++i) {
- add_server_to_control (*i);
- }
+ _use_any_servers = new wxCheckBox (_servers_panel, wxID_ANY, _("Use all servers"));
+ s->Add (_use_any_servers, 0, wxALL, DCPOMATIC_SIZER_X_GAP);
- _add_server->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ConfigDialog::add_server_clicked, this));
- _edit_server->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ConfigDialog::edit_server_clicked, this));
- _remove_server->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ConfigDialog::remove_server_clicked, this));
+ vector<string> columns;
+ columns.push_back (wx_to_std (_("IP address / host name")));
+ _servers_list = new EditableList<std::string, ServerDialog> (
+ _servers_panel,
+ columns,
+ boost::bind (&Config::servers, Config::instance()),
+ boost::bind (&Config::set_servers, Config::instance(), _1),
+ boost::bind (&server_column, _1)
+ );
+
+ s->Add (_servers_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
+
+ _use_any_servers->SetValue (Config::instance()->use_any_servers ());
+ _use_any_servers->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ConfigDialog::use_any_servers_changed, this));
+}
- _servers->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&ConfigDialog::server_selection_changed, this));
- _servers->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&ConfigDialog::server_selection_changed, this));
- server_selection_changed ();
+void
+ConfigDialog::use_any_servers_changed ()
+{
+ Config::instance()->set_use_any_servers (_use_any_servers->GetValue ());
}
void
Config::instance()->set_default_directory (wx_to_std (_default_directory->GetPath ()));
}
-void
-ConfigDialog::add_server_to_control (ServerDescription* s)
-{
- wxListItem item;
- int const n = _servers->GetItemCount ();
- item.SetId (n);
- _servers->InsertItem (item);
- _servers->SetItem (n, 0, std_to_wx (s->host_name ()));
- _servers->SetItem (n, 1, std_to_wx (boost::lexical_cast<string> (s->threads ())));
-}
-
-void
-ConfigDialog::add_server_clicked ()
-{
- ServerDialog* d = new ServerDialog (this, 0);
- d->ShowModal ();
- ServerDescription* s = d->server ();
- d->Destroy ();
-
- add_server_to_control (s);
- vector<ServerDescription*> o = Config::instance()->servers ();
- o.push_back (s);
- Config::instance()->set_servers (o);
-}
-
-void
-ConfigDialog::edit_server_clicked ()
-{
- int i = _servers->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- if (i == -1) {
- return;
- }
-
- wxListItem item;
- item.SetId (i);
- item.SetColumn (0);
- _servers->GetItem (item);
-
- vector<ServerDescription*> 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<string> (servers[i]->threads ())));
-}
-
-void
-ConfigDialog::remove_server_clicked ()
-{
- int i = _servers->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- if (i >= 0) {
- _servers->DeleteItem (i);
- }
-
- vector<ServerDescription*> o = Config::instance()->servers ();
- o.erase (o.begin() + i);
- Config::instance()->set_servers (o);
-}
-
-void
-ConfigDialog::server_selection_changed ()
-{
- int const i = _servers->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- _edit_server->Enable (i >= 0);
- _remove_server->Enable (i >= 0);
-}
-
void
ConfigDialog::edit_default_dci_metadata_clicked ()
{
void
ConfigDialog::default_j2k_bandwidth_changed ()
{
- Config::instance()->set_default_j2k_bandwidth (_default_j2k_bandwidth->GetValue() * 1e6);
+ Config::instance()->set_default_j2k_bandwidth (_default_j2k_bandwidth->GetValue() * 1000000);
+}
+
+static std::string
+colour_conversion_column (PresetColourConversion c)
+{
+ return c.name;
+}
+
+void
+ConfigDialog::make_colour_conversions_panel ()
+{
+ vector<string> columns;
+ columns.push_back (wx_to_std (_("Name")));
+ _colour_conversions_panel = new EditableList<PresetColourConversion, PresetColourConversionDialog> (
+ _notebook,
+ columns,
+ boost::bind (&Config::colour_conversions, Config::instance()),
+ boost::bind (&Config::set_colour_conversions, Config::instance(), _1),
+ boost::bind (&colour_conversion_column, _1),
+ 300
+ );
+}
+
+void
+ConfigDialog::mail_server_changed ()
+{
+ Config::instance()->set_mail_server (wx_to_std (_mail_server->GetValue ()));
+}
+
+
+void
+ConfigDialog::kdm_from_changed ()
+{
+ Config::instance()->set_kdm_from (wx_to_std (_kdm_from->GetValue ()));
+}
+
+void
+ConfigDialog::make_kdm_email_panel ()
+{
+ _kdm_email_panel = new wxPanel (_notebook);
+ wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
+ _kdm_email_panel->SetSizer (s);
+
+ _kdm_email = new wxTextCtrl (_kdm_email_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
+ s->Add (_kdm_email, 1, wxEXPAND | wxALL, 12);
+
+ _kdm_email->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ConfigDialog::kdm_email_changed, this));
+ _kdm_email->SetValue (wx_to_std (Config::instance()->kdm_email ()));
+}
+
+void
+ConfigDialog::kdm_email_changed ()
+{
+ Config::instance()->set_kdm_email (wx_to_std (_kdm_email->GetValue ()));
}