Remove film player, DVD ripping, alignment, screen configs; never finished and not...
[dcpomatic.git] / src / wx / config_dialog.cc
index c53eeddf0e4e395d4b40fd60e48f6bce172c8aea..9408be97003c1e5c311546df1f06d0f3b2e0a4df 100644 (file)
 
 #include <iostream>
 #include <boost/lexical_cast.hpp>
+#include <boost/filesystem.hpp>
+#include <wx/stdpaths.h>
 #include "lib/config.h"
 #include "lib/server.h"
-#include "lib/screen.h"
 #include "lib/format.h"
 #include "lib/scaler.h"
 #include "lib/filter.h"
 #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)
@@ -68,6 +70,15 @@ 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);
        for (int i = 0; i < 2; ++i) {
@@ -142,6 +153,9 @@ 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);
@@ -170,7 +184,7 @@ ConfigDialog::ConfigDialog (wxWindow* parent)
        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) {
@@ -212,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 &)
 {
@@ -263,21 +283,14 @@ ConfigDialog::edit_server_clicked (wxCommandEvent &)
        _servers->GetItem (item);
 
        vector<ServerDescription*> servers = Config::instance()->servers ();
-       vector<ServerDescription*>::iterator j = servers.begin();
-       while (j != servers.end() && (*j)->host_name() != wx_to_std (item.GetText ())) {
-               ++j;
-       }
-
-       if (j == servers.end()) {
-               return;
-       }
+       assert (i >= 0 && i < int (servers.size ()));
 
-       ServerDialog* d = new ServerDialog (this, *j);
+       ServerDialog* d = new ServerDialog (this, servers[i]);
        d->ShowModal ();
        d->Destroy ();
 
-       _servers->SetItem (i, 0, std_to_wx ((*j)->host_name ()));
-       _servers->SetItem (i, 1, std_to_wx (boost::lexical_cast<string> ((*j)->threads ())));
+       _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
@@ -287,6 +300,10 @@ ConfigDialog::remove_server_clicked (wxCommandEvent &)
        if (i >= 0) {
                _servers->DeleteItem (i);
        }
+
+       vector<ServerDescription*> o = Config::instance()->servers ();
+       o.erase (o.begin() + i);
+       Config::instance()->set_servers (o);
 }
 
 void
@@ -310,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 ();
 }