diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-04-29 00:47:47 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-06-03 22:46:26 +0200 |
| commit | fb5b8ae43e373c37b78202217528be73efa162cc (patch) | |
| tree | 9dfb23d6188ba86485795eb13876ebc01f560874 /src/wx | |
| parent | eb2452d1d76e7b87a61e88773b29206ff5833e34 (diff) | |
Allow multiple upload destinations instead of just the TMS.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/full_config_dialog.cc | 126 | ||||
| -rw-r--r-- | src/wx/upload_destination_dialog.cc | 105 | ||||
| -rw-r--r-- | src/wx/upload_destination_dialog.h | 51 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
4 files changed, 185 insertions, 98 deletions
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 704bce621..4e737caf9 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_dialog.h" #include "wx_util.h" #include "wx_variant.h" #include "lib/config.h" @@ -513,129 +514,58 @@ private: }; -class TMSPage : public preferences::Page +class UploadPage : public preferences::Page { public: - TMSPage(wxSize panel_size, int border) + UploadPage(wxSize panel_size, int border) : Page(panel_size, border) {} wxString GetName() const override { - return _("TMS"); + return _("Upload"); } #ifdef DCPOMATIC_OSX wxBitmap GetLargeIcon() const override { - return wxBitmap(icon_path("tms"), wxBITMAP_TYPE_PNG); + return wxBitmap(icon_path("upload"), wxBITMAP_TYPE_PNG); } #endif private: void setup() override { - _upload = new CheckBox(_panel, _("Upload DCP to TMS after creation")); - _panel->GetSizer()->Add(_upload, 0, wxALL | wxEXPAND, _border); - - 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)")); - - _upload->bind(&TMSPage::upload_changed, this); - _tms_protocol->Bind(wxEVT_CHOICE, boost::bind(&TMSPage::tms_protocol_changed, this)); - _tms_passive->bind(&TMSPage::tms_passive_changed, this); + vector<EditableListColumn> columns; + columns.push_back(EditableListColumn(_("Name"))); + columns.push_back(EditableListColumn(_("Host"), 256, true)); + _destinations_list = new EditableList<UploadDestination, UploadDestinationDialog>( + _panel, + columns, + boost::bind(&Config::upload_destinations, Config::instance()), + boost::bind(&Config::set_upload_destinations, Config::instance(), _1), + [](UploadDestination const& destination, int column) -> std::string { + switch (column) { + case 0: + return destination.name; + case 1: + return destination.host; + } + return {}; + }, + EditableListTitle::VISIBLE, + EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE + ); - _tms_ip->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_ip_changed, this)); - _tms_path->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_path_changed, this)); - _tms_user->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_user_changed, this)); - _tms_password->Changed.connect(boost::bind(&TMSPage::tms_password_changed, this)); + _panel->GetSizer()->Add(_destinations_list, 1, wxEXPAND | wxALL, _border); } void config_changed() override { - auto config = Config::instance(); - - checked_set(_upload, config->upload_after_make_dcp()); - checked_set(_tms_protocol, static_cast<int>(config->tms_protocol())); - checked_set(_tms_passive, config->tms_protocol() == FileTransferProtocol::FTP && config->tms_passive()); - checked_set(_tms_ip, config->tms_ip()); - checked_set(_tms_path, config->tms_path()); - checked_set(_tms_user, config->tms_user()); - checked_set(_tms_password, config->tms_password()); - - _tms_passive->Enable(config->tms_protocol() == FileTransferProtocol::FTP); - } - - void upload_changed() - { - Config::instance()->set_upload_after_make_dcp(_upload->GetValue()); - } - - void tms_protocol_changed() - { - Config::instance()->set_tms_protocol(static_cast<FileTransferProtocol>(_tms_protocol->GetSelection())); - } - - void tms_passive_changed() - { - Config::instance()->set_tms_passive(_tms_passive->get()); - } - void tms_ip_changed() - { - Config::instance()->set_tms_ip(wx_to_std(_tms_ip->GetValue())); - } - - void tms_path_changed() - { - Config::instance()->set_tms_path(wx_to_std(_tms_path->GetValue())); - } - - void tms_user_changed() - { - Config::instance()->set_tms_user(wx_to_std(_tms_user->GetValue())); - } - - void tms_password_changed() - { - Config::instance()->set_tms_password(_tms_password->get()); } - CheckBox* _upload; - CheckBox* _tms_passive; - wxChoice* _tms_protocol; - wxTextCtrl* _tms_ip; - wxTextCtrl* _tms_path; - wxTextCtrl* _tms_user; - PasswordEntry* _tms_password; + EditableList<UploadDestination, UploadDestinationDialog>* _destinations_list; }; @@ -1494,7 +1424,7 @@ create_full_config_dialog() e->AddPage(new GPUPage(ps, border)); #endif e->AddPage(new preferences::KeysPage(ps, border)); - e->AddPage(new TMSPage(ps, border)); + e->AddPage(new UploadPage(ps, border)); e->AddPage(new preferences::EmailPage(ps, border)); e->AddPage(new preferences::KDMEmailPage(ps, border)); e->AddPage(new NotificationsPage(ps, border)); diff --git a/src/wx/upload_destination_dialog.cc b/src/wx/upload_destination_dialog.cc new file mode 100644 index 000000000..55440b71a --- /dev/null +++ b/src/wx/upload_destination_dialog.cc @@ -0,0 +1,105 @@ +/* + Copyright (C) 2025 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "check_box.h" +#include "dcpomatic_choice.h" +#include "password_entry.h" +#include "upload_destination_dialog.h" +#include "wx_util.h" +#include "lib/upload_destination.h" + + +using std::shared_ptr; +using std::string; +using std::vector; + + +UploadDestinationDialog::UploadDestinationDialog(wxWindow* parent) + : TableDialog(parent, _("Upload destination"), 2, 1, true) +{ + add(_("Name"), true); + _name = add(new wxTextCtrl(this, wxID_ANY, {}, wxDefaultPosition, wxSize(480, -1))); + add(_("Protocol"), true); + _protocol = add(new Choice(this)); + _passive = add(new CheckBox(this, _("Passive"))); + add_spacer(); + add(_("Host"), true); + _host = add(new wxTextCtrl(this, wxID_ANY)); + add(_("Path"), true); + _path = add(new wxTextCtrl(this, wxID_ANY)); + add(_("User"), true); + _user = add(new wxTextCtrl(this, wxID_ANY)); + add(_("Password"), true); + _password = new PasswordEntry(this); + add(_password->get_panel()); + + _protocol->add_entry(_("SCP")); + _protocol->add_entry(_("FTP")); + + _protocol->bind(&UploadDestinationDialog::protocol_changed, this); + + layout(); + + _name->SetFocus(); + + _protocol->set(0); + protocol_changed(); +} + + +void +UploadDestinationDialog::protocol_changed() +{ + auto const ftp = _protocol->get() == 1; + _passive->Enable(ftp); + _passive->SetValue(ftp); +} + + +void +UploadDestinationDialog::set(UploadDestination const& destination) +{ + checked_set(_name, destination.name); + checked_set(_protocol, static_cast<int>(destination.protocol)); + checked_set(_passive, destination.passive_ftp); + checked_set(_host, destination.host); + checked_set(_path, destination.path); + checked_set(_user, destination.user); + checked_set(_password, destination.password); + + protocol_changed(); +} + +vector<UploadDestination> +UploadDestinationDialog::get () const +{ + return { + UploadDestination( + wx_to_std(_name->GetValue()), + static_cast<FileTransferProtocol>(_protocol->GetSelection()), + _passive->get(), + wx_to_std(_host->GetValue()), + wx_to_std(_path->GetValue()), + wx_to_std(_user->GetValue()), + _password->get() + ) + }; +} diff --git a/src/wx/upload_destination_dialog.h b/src/wx/upload_destination_dialog.h new file mode 100644 index 000000000..62abafe0f --- /dev/null +++ b/src/wx/upload_destination_dialog.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2025 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "table_dialog.h" +#include "lib/upload_destination.h" +#include <boost/optional.hpp> + + +class CheckBox; +class Choice; +class PasswordEntry; +class wxTextCtrl; + + +class UploadDestinationDialog : public TableDialog +{ +public: + explicit UploadDestinationDialog(wxWindow *); + + void set(UploadDestination const& destination); + std::vector<UploadDestination> get() const; + +private: + void protocol_changed(); + + wxTextCtrl* _name; + Choice* _protocol; + CheckBox* _passive; + wxTextCtrl* _host; + wxTextCtrl* _path; + wxTextCtrl* _user; + PasswordEntry* _password; +}; diff --git a/src/wx/wscript b/src/wx/wscript index 3dfc157e2..3890a929c 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -185,6 +185,7 @@ sources = """ timeline_time_axis_view.cc timing_panel.cc try_unmount_dialog.cc + upload_destination_dialog.cc update_dialog.cc verify_dcp_dialog.cc verify_dcp_progress_panel.cc |
