summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-01 23:30:57 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-01 23:30:57 +0100
commit7a9d77bc3573d85a5066e3472ae15b8b700a226c (patch)
tree8727e815b4aa876906de6b67fc92202c856cbd78 /src
parent3cad01eefa07e14d64ccf8972a35674dc5b23c4a (diff)
Move KDM Email preferences page to its own file.
Diffstat (limited to 'src')
-rw-r--r--src/wx/full_config_dialog.cc129
-rw-r--r--src/wx/kdm_email_preferences_page.cc166
-rw-r--r--src/wx/kdm_email_preferences_page.h63
-rw-r--r--src/wx/wscript1
4 files changed, 232 insertions, 127 deletions
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc
index 6fb56c545..76efbbab9 100644
--- a/src/wx/full_config_dialog.cc
+++ b/src/wx/full_config_dialog.cc
@@ -37,6 +37,7 @@
#include "filter_dialog.h"
#include "full_config_dialog.h"
#include "kdm_choice.h"
+#include "kdm_email_preferences_page.h"
#include "language_tag_widget.h"
#include "make_chain_dialog.h"
#include "nag_dialog.h"
@@ -698,132 +699,6 @@ private:
};
-class KDMEmailPage : public preferences::Page
-{
-public:
-
- KDMEmailPage(wxSize panel_size, int border)
-#ifdef DCPOMATIC_OSX
- /* We have to force both width and height of this one */
- : Page(wxSize(panel_size.GetWidth(), 128), border)
-#else
- : Page(panel_size, border)
-#endif
- {}
-
- wxString GetName() const override
- {
- return _("KDM Email");
- }
-
-#ifdef DCPOMATIC_OSX
- wxBitmap GetLargeIcon() const override
- {
- return wxBitmap(icon_path("kdm_email"), wxBITMAP_TYPE_PNG);
- }
-#endif
-
-private:
- void setup() override
- {
- auto table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- table->AddGrowableCol(1, 1);
- _panel->GetSizer()->Add(table, 0, wxEXPAND | wxALL, _border);
-
- add_label_to_sizer(table, _panel, _("Subject"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _subject = new wxTextCtrl(_panel, wxID_ANY);
- table->Add(_subject, 1, wxEXPAND | wxALL);
-
- add_label_to_sizer(table, _panel, _("From address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _from = new wxTextCtrl(_panel, wxID_ANY);
- table->Add(_from, 1, wxEXPAND | wxALL);
-
- vector<EditableListColumn> columns;
- columns.push_back(EditableListColumn(_("Address")));
- add_label_to_sizer(table, _panel, _("CC addresses"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _cc = new EditableList<string, EmailDialog>(
- _panel,
- columns,
- bind(&Config::kdm_cc, Config::instance()),
- bind(&Config::set_kdm_cc, Config::instance(), _1),
- [] (string s, int) {
- return s;
- },
- EditableListTitle::VISIBLE,
- EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE
- );
- table->Add(_cc, 1, wxEXPAND | wxALL);
-
- add_label_to_sizer(table, _panel, _("BCC address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _bcc = new wxTextCtrl(_panel, wxID_ANY);
- table->Add(_bcc, 1, wxEXPAND | wxALL);
-
- _email = new wxTextCtrl(_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE);
- _panel->GetSizer()->Add(_email, 0, wxEXPAND | wxALL, _border);
-
- _reset_email = new Button(_panel, _("Reset to default subject and text"));
- _panel->GetSizer()->Add(_reset_email, 0, wxEXPAND | wxALL, _border);
-
- _cc->layout();
-
- _subject->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_subject_changed, this));
- _from->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_from_changed, this));
- _bcc->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_bcc_changed, this));
- _email->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_email_changed, this));
- _reset_email->Bind(wxEVT_BUTTON, boost::bind(&KDMEmailPage::reset_email, this));
- }
-
- void config_changed() override
- {
- auto config = Config::instance();
-
- checked_set(_subject, config->kdm_subject());
- checked_set(_from, config->kdm_from());
- checked_set(_bcc, config->kdm_bcc());
- checked_set(_email, Config::instance()->kdm_email());
- }
-
- void kdm_subject_changed()
- {
- Config::instance()->set_kdm_subject(wx_to_std(_subject->GetValue()));
- }
-
- void kdm_from_changed()
- {
- Config::instance()->set_kdm_from(wx_to_std(_from->GetValue()));
- }
-
- void kdm_bcc_changed()
- {
- Config::instance()->set_kdm_bcc(wx_to_std(_bcc->GetValue()));
- }
-
- void kdm_email_changed()
- {
- if (_email->GetValue().IsEmpty()) {
- /* Sometimes we get sent an erroneous notification that the email
- is empty; I don't know why.
- */
- return;
- }
- Config::instance()->set_kdm_email(wx_to_std(_email->GetValue()));
- }
-
- void reset_email()
- {
- Config::instance()->reset_kdm_email();
- checked_set(_email, Config::instance()->kdm_email());
- }
-
- wxTextCtrl* _subject;
- wxTextCtrl* _from;
- EditableList<string, EmailDialog>* _cc;
- wxTextCtrl* _bcc;
- wxTextCtrl* _email;
- wxButton* _reset_email;
-};
-
-
class NotificationsPage : public preferences::Page
{
public:
@@ -1681,7 +1556,7 @@ create_full_config_dialog()
e->AddPage(new preferences::KeysPage(ps, border));
e->AddPage(new TMSPage(ps, border));
e->AddPage(new preferences::EmailPage(ps, border));
- e->AddPage(new KDMEmailPage(ps, border));
+ e->AddPage(new preferences::KDMEmailPage(ps, border));
e->AddPage(new NotificationsPage(ps, border));
e->AddPage(new CoverSheetPage(ps, border));
e->AddPage(new IdentifiersPage(ps, border));
diff --git a/src/wx/kdm_email_preferences_page.cc b/src/wx/kdm_email_preferences_page.cc
new file mode 100644
index 000000000..ae7eb0bd1
--- /dev/null
+++ b/src/wx/kdm_email_preferences_page.cc
@@ -0,0 +1,166 @@
+/*
+ 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 "email_dialog.h"
+#include "kdm_email_preferences_page.h"
+
+
+using std::string;
+using std::vector;
+using boost::bind;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+using namespace dcpomatic::preferences;
+
+
+KDMEmailPage::KDMEmailPage(wxSize panel_size, int border)
+#ifdef DCPOMATIC_OSX
+ /* We have to force both width and height of this one */
+ : Page(wxSize(panel_size.GetWidth(), 128), border)
+#else
+ : Page(panel_size, border)
+#endif
+{
+
+}
+
+
+wxString
+KDMEmailPage::GetName() const
+{
+ return _("KDM Email");
+}
+
+
+#ifdef DCPOMATIC_OSX
+wxBitmap
+KDMEmailPage::GetLargeIcon() const
+{
+ return wxBitmap(icon_path("kdm_email"), wxBITMAP_TYPE_PNG);
+}
+#endif
+
+
+void
+KDMEmailPage::setup()
+{
+ auto table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ table->AddGrowableCol(1, 1);
+ _panel->GetSizer()->Add(table, 0, wxEXPAND | wxALL, _border);
+
+ add_label_to_sizer(table, _panel, _("Subject"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
+ _subject = new wxTextCtrl(_panel, wxID_ANY);
+ table->Add(_subject, 1, wxEXPAND | wxALL);
+
+ add_label_to_sizer(table, _panel, _("From address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
+ _from = new wxTextCtrl(_panel, wxID_ANY);
+ table->Add(_from, 1, wxEXPAND | wxALL);
+
+ vector<EditableListColumn> columns;
+ columns.push_back(EditableListColumn(_("Address")));
+ add_label_to_sizer(table, _panel, _("CC addresses"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
+ _cc = new EditableList<string, EmailDialog>(
+ _panel,
+ columns,
+ bind(&Config::kdm_cc, Config::instance()),
+ bind(&Config::set_kdm_cc, Config::instance(), _1),
+ [] (string s, int) {
+ return s;
+ },
+ EditableListTitle::VISIBLE,
+ EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE
+ );
+ table->Add(_cc, 1, wxEXPAND | wxALL);
+
+ add_label_to_sizer(table, _panel, _("BCC address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
+ _bcc = new wxTextCtrl(_panel, wxID_ANY);
+ table->Add(_bcc, 1, wxEXPAND | wxALL);
+
+ _email = new wxTextCtrl(_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE);
+ _panel->GetSizer()->Add(_email, 0, wxEXPAND | wxALL, _border);
+
+ _reset_email = new Button(_panel, _("Reset to default subject and text"));
+ _panel->GetSizer()->Add(_reset_email, 0, wxEXPAND | wxALL, _border);
+
+ _cc->layout();
+
+ _subject->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_subject_changed, this));
+ _from->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_from_changed, this));
+ _bcc->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_bcc_changed, this));
+ _email->Bind(wxEVT_TEXT, boost::bind(&KDMEmailPage::kdm_email_changed, this));
+ _reset_email->Bind(wxEVT_BUTTON, boost::bind(&KDMEmailPage::reset_email, this));
+}
+
+
+void
+KDMEmailPage::config_changed()
+{
+ auto config = Config::instance();
+
+ checked_set(_subject, config->kdm_subject());
+ checked_set(_from, config->kdm_from());
+ checked_set(_bcc, config->kdm_bcc());
+ checked_set(_email, Config::instance()->kdm_email());
+}
+
+
+void
+KDMEmailPage::kdm_subject_changed()
+{
+ Config::instance()->set_kdm_subject(wx_to_std(_subject->GetValue()));
+}
+
+
+void
+KDMEmailPage::kdm_from_changed()
+{
+ Config::instance()->set_kdm_from(wx_to_std(_from->GetValue()));
+}
+
+
+void
+KDMEmailPage::kdm_bcc_changed()
+{
+ Config::instance()->set_kdm_bcc(wx_to_std(_bcc->GetValue()));
+}
+
+
+void
+KDMEmailPage::kdm_email_changed()
+{
+ if (_email->GetValue().IsEmpty()) {
+ /* Sometimes we get sent an erroneous notification that the email
+ is empty; I don't know why.
+ */
+ return;
+ }
+ Config::instance()->set_kdm_email(wx_to_std(_email->GetValue()));
+}
+
+
+void
+KDMEmailPage::reset_email()
+{
+ Config::instance()->reset_kdm_email();
+ checked_set(_email, Config::instance()->kdm_email());
+}
+
diff --git a/src/wx/kdm_email_preferences_page.h b/src/wx/kdm_email_preferences_page.h
new file mode 100644
index 000000000..fd51285e6
--- /dev/null
+++ b/src/wx/kdm_email_preferences_page.h
@@ -0,0 +1,63 @@
+/*
+ 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 "config_dialog.h"
+
+
+class EmailDialog;
+
+
+namespace dcpomatic {
+namespace preferences {
+
+
+class KDMEmailPage : public preferences::Page
+{
+public:
+ KDMEmailPage(wxSize panel_size, int border);
+
+ wxString GetName() const override;
+
+#ifdef DCPOMATIC_OSX
+ wxBitmap GetLargeIcon() const override;
+#endif
+
+private:
+ void setup() override;
+ void config_changed() override;
+ void kdm_subject_changed();
+ void kdm_from_changed();
+ void kdm_bcc_changed();
+ void kdm_email_changed();
+ void reset_email();
+
+ wxTextCtrl* _subject;
+ wxTextCtrl* _from;
+ EditableList<std::string, EmailDialog>* _cc;
+ wxTextCtrl* _bcc;
+ wxTextCtrl* _email;
+ wxButton* _reset_email;
+};
+
+
+}
+}
+
diff --git a/src/wx/wscript b/src/wx/wscript
index 565fb66c1..06fa8af4f 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -108,6 +108,7 @@ sources = """
kdm_advanced_dialog.cc
kdm_cpl_panel.cc
kdm_dialog.cc
+ kdm_email_preferences_page.cc
kdm_output_panel.cc
kdm_timing_panel.cc
language_subtag_panel.cc