summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-02 00:41:00 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-02 00:41:00 +0100
commitbe1440be284f244b4b9ac74b8bff5847c6237d07 (patch)
tree1845c414de987071cdafa35ff61299e58dc0145a /src
parentf1c4d11e07f143888fdf82aa533712b675741303 (diff)
Use a customised config dialog for the KDM creator.
Diffstat (limited to 'src')
-rw-r--r--src/tools/dcpomatic_kdm.cc4
-rw-r--r--src/wx/kdm_config_dialog.cc209
-rw-r--r--src/wx/kdm_config_dialog.h27
-rw-r--r--src/wx/wscript1
4 files changed, 239 insertions, 2 deletions
diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc
index 256627d0d..850631d38 100644
--- a/src/tools/dcpomatic_kdm.cc
+++ b/src/tools/dcpomatic_kdm.cc
@@ -26,8 +26,8 @@
#include "wx/invalid_certificate_period_dialog.h"
#include "wx/file_dialog.h"
#include "wx/file_picker_ctrl.h"
-#include "wx/full_config_dialog.h"
#include "wx/job_view_dialog.h"
+#include "wx/kdm_config_dialog.h"
#include "wx/kdm_timing_panel.h"
#include "wx/nag_dialog.h"
#include "wx/new_dkdm_folder_dialog.h"
@@ -284,7 +284,7 @@ private:
void edit_preferences ()
{
if (!_config_dialog) {
- _config_dialog = create_full_config_dialog ();
+ _config_dialog = create_kdm_config_dialog();
}
_config_dialog->Show (this);
}
diff --git a/src/wx/kdm_config_dialog.cc b/src/wx/kdm_config_dialog.cc
new file mode 100644
index 000000000..1e9d3a0f4
--- /dev/null
+++ b/src/wx/kdm_config_dialog.cc
@@ -0,0 +1,209 @@
+/*
+ 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/>.
+
+*/
+
+
+/** @file src/kdm_config_dialog.cc
+ * @brief A dialogue to edit DCP-o-matic KDM Creator configuration.
+ */
+
+
+#include "check_box.h"
+#include "config_dialog.h"
+#include "email_preferences_page.h"
+#include "kdm_email_preferences_page.h"
+#include "file_picker_ctrl.h"
+#include "static_text.h"
+#include "wx_variant.h"
+
+
+using boost::bind;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+using namespace dcpomatic;
+
+
+class KDMGeneralPage : public preferences::GeneralPage
+{
+public:
+ KDMGeneralPage(wxSize panel_size, int border)
+ : GeneralPage(panel_size, border)
+ {}
+
+private:
+ void setup() override
+ {
+ auto table = new wxGridBagSizer(DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ _panel->GetSizer()->Add(table, 1, wxALL | wxEXPAND, _border);
+
+ int r = 0;
+ add_language_controls(table, r);
+ add_config_file_controls(table, r);
+ add_update_controls(table, r);
+
+ add_label_to_sizer(table, _panel, _("Debug log file"), true, wxGBPosition(r, 0));
+ _debug_log_file = new FilePickerCtrl(_panel, _("Select debug log file"), char_to_wx("*"), false, true, "DebugLogPath");
+ table->Add(_debug_log_file, wxGBPosition(r, 1));
+ ++r;
+
+ _debug_log_file->Bind(wxEVT_FILEPICKER_CHANGED, bind(&KDMGeneralPage::debug_log_file_changed, this));
+ }
+
+ void config_changed() override
+ {
+ GeneralPage::config_changed();
+
+ auto config = Config::instance();
+ if (config->kdm_debug_log_file()) {
+ checked_set(_debug_log_file, *config->kdm_debug_log_file());
+ }
+ }
+
+private:
+ void debug_log_file_changed()
+ {
+ if (auto path = _debug_log_file->path()) {
+ Config::instance()->set_kdm_debug_log_file(*path);
+ }
+ }
+
+ FilePickerCtrl* _debug_log_file = nullptr;
+};
+
+
+/** @class KDMAdvancedPage
+ * @brief Advanced page of the preferences dialog for the KDM creator.
+ */
+class KDMAdvancedPage : public preferences::Page
+{
+public:
+ KDMAdvancedPage(wxSize panel_size, int border)
+ : Page(panel_size, border)
+ {}
+
+ wxString GetName() const override
+ {
+ return _("Advanced");
+ }
+
+#ifdef DCPOMATIC_OSX
+ wxBitmap GetLargeIcon() const override
+ {
+ return wxBitmap(icon_path("advanced"), wxBITMAP_TYPE_PNG);
+ }
+#endif
+
+private:
+ void add_top_aligned_label_to_sizer(wxSizer* table, wxWindow* parent, wxString text)
+ {
+ int flags = wxALIGN_TOP | wxTOP | wxLEFT;
+#ifdef __WXOSX__
+ flags |= wxALIGN_RIGHT;
+ text += char_to_wx(":");
+#endif
+ auto m = new StaticText(parent, text);
+ table->Add(m, 0, flags, DCPOMATIC_SIZER_Y_GAP);
+ }
+
+ void setup() override
+ {
+ auto 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_top_aligned_label_to_sizer(table, _panel, _("Log"));
+ auto t = new wxBoxSizer(wxVERTICAL);
+ _log_general = new CheckBox(_panel, _("General"));
+ t->Add(_log_general, 1, wxEXPAND | wxALL);
+ _log_warning = new CheckBox(_panel, _("Warnings"));
+ t->Add(_log_warning, 1, wxEXPAND | wxALL);
+ _log_error = new CheckBox(_panel, _("Errors"));
+ t->Add(_log_error, 1, wxEXPAND | wxALL);
+ _log_debug_email = new CheckBox(_panel, _("Debug: email sending"));
+ t->Add(_log_debug_email, 1, wxEXPAND | wxALL);
+ table->Add(t, 0, wxALL, 6);
+ }
+
+ _log_general->bind(&KDMAdvancedPage::log_changed, this);
+ _log_warning->bind(&KDMAdvancedPage::log_changed, this);
+ _log_error->bind(&KDMAdvancedPage::log_changed, this);
+ _log_debug_email->bind(&KDMAdvancedPage::log_changed, this);
+ }
+
+ void config_changed() override
+ {
+ auto config = Config::instance();
+
+ checked_set(_log_general, config->log_types() & LogEntry::TYPE_GENERAL);
+ checked_set(_log_warning, config->log_types() & LogEntry::TYPE_WARNING);
+ checked_set(_log_error, config->log_types() & LogEntry::TYPE_ERROR);
+ checked_set(_log_debug_email, config->log_types() & LogEntry::TYPE_DEBUG_EMAIL);
+ }
+
+ void log_changed()
+ {
+ int types = 0;
+ if (_log_general->GetValue()) {
+ types |= LogEntry::TYPE_GENERAL;
+ }
+ if (_log_warning->GetValue()) {
+ types |= LogEntry::TYPE_WARNING;
+ }
+ if (_log_error->GetValue()) {
+ types |= LogEntry::TYPE_ERROR;
+ }
+ if (_log_debug_email->GetValue()) {
+ types |= LogEntry::TYPE_DEBUG_EMAIL;
+ }
+ Config::instance()->set_log_types(types);
+ }
+
+ CheckBox* _log_general = nullptr;
+ CheckBox* _log_warning = nullptr;
+ CheckBox* _log_error = nullptr;
+ CheckBox* _log_debug_email = nullptr;
+};
+
+
+wxPreferencesEditor*
+create_kdm_config_dialog()
+{
+ auto e = new wxPreferencesEditor(variant::wx::insert_dcpomatic_kdm_creator(_("%s Preferences")));
+
+#ifdef DCPOMATIC_OSX
+ /* Width that we force some of the config panels to be on OSX so that
+ the containing window doesn't shrink too much when we select those panels.
+ This is obviously an unpleasant hack.
+ */
+ auto ps = wxSize(520, -1);
+ int const border = 16;
+#else
+ auto ps = wxSize(-1, -1);
+ int const border = 8;
+#endif
+
+ e->AddPage(new KDMGeneralPage(wxSize(-1, 500), border));
+ e->AddPage(new preferences::KeysPage(ps, border));
+ e->AddPage(new preferences::EmailPage(ps, border));
+ e->AddPage(new preferences::KDMEmailPage(ps, border));
+ e->AddPage(new KDMAdvancedPage(ps, border));
+ return e;
+}
diff --git a/src/wx/kdm_config_dialog.h b/src/wx/kdm_config_dialog.h
new file mode 100644
index 000000000..a55f2e64e
--- /dev/null
+++ b/src/wx/kdm_config_dialog.h
@@ -0,0 +1,27 @@
+/*
+ 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/>.
+
+*/
+
+/** @file src/kdm_config_dialog.h
+ * @brief A dialogue to edit DCP-o-matic KDM creator configuration.
+ */
+
+class wxPreferencesEditor;
+
+wxPreferencesEditor* create_kdm_config_dialog();
diff --git a/src/wx/wscript b/src/wx/wscript
index 06fa8af4f..9448c1eaa 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -106,6 +106,7 @@ sources = """
job_view.cc
job_view_dialog.cc
kdm_advanced_dialog.cc
+ kdm_config_dialog.cc
kdm_cpl_panel.cc
kdm_dialog.cc
kdm_email_preferences_page.cc