diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-06-05 00:32:00 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-07-09 01:16:39 +0200 |
| commit | 6ab6cd5a8c300c6db6f52bb9d74e5d7533976fe0 (patch) | |
| tree | 7fc78ed20e356dd4842bd1491abdfd479f2c4b8e /src/wx | |
| parent | 202da27202bd644138ef4033cd2e4b6d752303b1 (diff) | |
Replace TMS upload with upload to any number of destinations.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/full_config_dialog.cc | 95 | ||||
| -rw-r--r-- | src/wx/upload_destination_panel.cc | 25 | ||||
| -rw-r--r-- | src/wx/upload_destination_panel.h | 5 |
3 files changed, 42 insertions, 83 deletions
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index d4d7af686..71084f79b 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -53,6 +53,7 @@ #ifdef DCPOMATIC_GROK #include "grok/gpu_config_panel.h" #endif +#include "upload_destination_panel.h" #include "wx_util.h" #include "wx_variant.h" #include "lib/config.h" @@ -535,98 +536,32 @@ public: private: void setup() override { - _upload = new CheckBox(_panel, _("Upload DCP to TMS after creation")); - _panel->GetSizer()->Add(_upload, 0, wxALL | wxEXPAND, _border); + add_label_to_sizer(_panel->GetSizer(), _panel, _("Upload DCP after creation to"), true, 0, wxALL); - wxFlexGridSizer* table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol(1, 1); - _panel->GetSizer()->Add(table, 1, wxALL | wxEXPAND, _border); - - add_label_to_sizer(table, _panel, _("Protocol"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _tms_protocol = new wxChoice(_panel, wxID_ANY); - table->Add(_tms_protocol, 1, wxEXPAND); - - _tms_passive = new CheckBox(_panel, _("Passive mode")); - table->Add(_tms_passive, 1, wxEXPAND); - table->AddSpacer(0); - - add_label_to_sizer(table, _panel, _("IP address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _tms_ip = new wxTextCtrl(_panel, wxID_ANY); - table->Add(_tms_ip, 1, wxEXPAND); - - add_label_to_sizer(table, _panel, _("Target path"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _tms_path = new wxTextCtrl(_panel, wxID_ANY); - table->Add(_tms_path, 1, wxEXPAND); - - add_label_to_sizer(table, _panel, _("User name"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _tms_user = new wxTextCtrl(_panel, wxID_ANY); - table->Add(_tms_user, 1, wxEXPAND); - - add_label_to_sizer(table, _panel, _("Password"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _tms_password = new PasswordEntry(_panel); - table->Add(_tms_password->get_panel(), 1, wxEXPAND); - - _tms_protocol->Append(_("SCP (for AAM and Doremi)")); - _tms_protocol->Append(_("FTP (for Dolby)")); + _destinations = new UploadDestinationPanel(_panel); + _panel->GetSizer()->Add(_destinations, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, DCPOMATIC_SIZER_GAP); - _upload->bind(&UploadPage::upload_changed, this); - _tms_protocol->Bind(wxEVT_CHOICE, boost::bind(&UploadPage::tms_changed, this)); - _tms_passive->bind(&UploadPage::tms_changed, this); - - _tms_ip->Bind(wxEVT_TEXT, boost::bind(&UploadPage::tms_changed, this)); - _tms_path->Bind(wxEVT_TEXT, boost::bind(&UploadPage::tms_changed, this)); - _tms_user->Bind(wxEVT_TEXT, boost::bind(&UploadPage::tms_changed, this)); - _tms_password->Changed.connect(boost::bind(&UploadPage::tms_changed, this)); + _destinations->DestinationsChanged.connect(boost::bind(&UploadPage::destinations_changed, this)); } void config_changed() override { - auto config = Config::instance(); - - checked_set(_upload, config->upload_after_make_dcp()); - if (auto tms = Config::instance()->tms()) { - checked_set(_tms_protocol, static_cast<int>(tms->protocol)); - checked_set(_tms_passive, tms->protocol == FileTransferProtocol::FTP && tms->passive_ftp); - checked_set(_tms_ip, tms->host); - checked_set(_tms_path, tms->path); - checked_set(_tms_user, tms->user); - checked_set(_tms_password, tms->password); - } else { - checked_set(_tms_protocol, static_cast<int>(FileTransferProtocol::FTP)); - checked_set(_tms_passive, false); - checked_set(_tms_ip, ""); - checked_set(_tms_path, ""); - checked_set(_tms_user, ""); - checked_set(_tms_password, ""); - } + _destinations->set_upload_destinations(Config::instance()->upload_destinations()); + _destinations->enable_upload_destinations(Config::instance()->auto_upload_destinations()); } - void upload_changed() + void destinations_changed() { - Config::instance()->set_upload_after_make_dcp(_upload->GetValue()); + vector<string> names; + for (auto const& destination: _destinations->destinations()) { + names.push_back(destination.name); + } + Config::instance()->set_auto_upload_destinations(names); } - void tms_changed() - { - Config::instance()->set_tms({ - wx_to_std(_("TMS")), - static_cast<FileTransferProtocol>(_tms_protocol->GetSelection()), - _tms_passive->get(), - boost::none, - wx_to_std(_tms_ip->GetValue()), - wx_to_std(_tms_path->GetValue()), - wx_to_std(_tms_user->GetValue()), - _tms_password->get() - }); - } +private: + UploadDestinationPanel* _destinations; - CheckBox* _upload; - CheckBox* _tms_passive; - wxChoice* _tms_protocol; - wxTextCtrl* _tms_ip; - wxTextCtrl* _tms_path; - wxTextCtrl* _tms_user; - PasswordEntry* _tms_password; }; diff --git a/src/wx/upload_destination_panel.cc b/src/wx/upload_destination_panel.cc index 6465400d9..3e9ffc47e 100644 --- a/src/wx/upload_destination_panel.cc +++ b/src/wx/upload_destination_panel.cc @@ -41,9 +41,7 @@ UploadDestinationPanel::UploadDestinationPanel(wxWindow* parent) _list = new wxTreeListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_NO_HEADER | wxTL_3STATE); _list->AppendColumn(char_to_wx("foo"), 640); - for (auto destination: Config::instance()->upload_destinations()) { - add_destination(destination); - } + set_upload_destinations(Config::instance()->upload_destinations()); auto buttons = new wxBoxSizer(wxVERTICAL); @@ -187,3 +185,24 @@ UploadDestinationPanel::destinations() const return checked; } + +void +UploadDestinationPanel::set_upload_destinations(vector<UploadDestination> const& destinations) +{ + _list->DeleteAllItems(); + _destinations.clear(); + + for (auto destination: destinations) { + add_destination(destination); + } +} + + +void +UploadDestinationPanel::enable_upload_destinations(vector<string> const& names) +{ + for (auto const& dest: _destinations) { + _list->CheckItem(dest.first, std::find(names.begin(), names.end(), dest.second.name) != names.end() ? wxCHK_CHECKED : wxCHK_UNCHECKED); + } +} + diff --git a/src/wx/upload_destination_panel.h b/src/wx/upload_destination_panel.h index fb2fee99e..3ea3694b3 100644 --- a/src/wx/upload_destination_panel.h +++ b/src/wx/upload_destination_panel.h @@ -37,6 +37,11 @@ public: /** @return ticked, i.e. "enabled" destinations */ std::vector<UploadDestination> destinations() const; + void set_upload_destinations(std::vector<UploadDestination> const& destinations); + + /** Specify a list of upload destination names to enable (tick) */ + void enable_upload_destinations(std::vector<std::string> const& names); + boost::signals2::signal<void ()> DestinationsChanged; private: |
