From: Carl Hetherington Date: Tue, 9 Apr 2024 20:11:56 +0000 (+0200) Subject: Split VerifyDCPResultPanel so that construction and fill are separate. X-Git-Tag: v2.17.16~12 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=91b6f5b7921c7af26c0bb04074d603a712f0e9d4 Split VerifyDCPResultPanel so that construction and fill are separate. --- diff --git a/src/wx/verify_dcp_result_dialog.cc b/src/wx/verify_dcp_result_dialog.cc index 8f834ff58..9617878c5 100644 --- a/src/wx/verify_dcp_result_dialog.cc +++ b/src/wx/verify_dcp_result_dialog.cc @@ -32,7 +32,8 @@ VerifyDCPResultDialog::VerifyDCPResultDialog(wxWindow* parent, shared_ptrfill(job); sizer->Add(panel, 1, wxEXPAND); auto buttons = CreateStdDialogButtonSizer(0); diff --git a/src/wx/verify_dcp_result_panel.cc b/src/wx/verify_dcp_result_panel.cc index f536c3408..4920ab350 100644 --- a/src/wx/verify_dcp_result_panel.cc +++ b/src/wx/verify_dcp_result_panel.cc @@ -39,34 +39,38 @@ using std::string; using std::vector; -VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent, shared_ptr job) +VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent) : wxPanel(parent, wxID_ANY) { auto sizer = new wxBoxSizer(wxVERTICAL); auto notebook = new wxNotebook(this, wxID_ANY); sizer->Add(notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - map pages; - pages[dcp::VerificationNote::Type::ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY); - notebook->AddPage(pages[dcp::VerificationNote::Type::ERROR], _("Errors")); - pages[dcp::VerificationNote::Type::BV21_ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY); - notebook->AddPage(pages[dcp::VerificationNote::Type::BV21_ERROR], _("SMPTE Bv2.1 errors")); - pages[dcp::VerificationNote::Type::WARNING] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY); - notebook->AddPage(pages[dcp::VerificationNote::Type::WARNING], _("Warnings")); + _pages[dcp::VerificationNote::Type::ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY); + notebook->AddPage(_pages[dcp::VerificationNote::Type::ERROR], _("Errors")); + _pages[dcp::VerificationNote::Type::BV21_ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY); + notebook->AddPage(_pages[dcp::VerificationNote::Type::BV21_ERROR], _("SMPTE Bv2.1 errors")); + _pages[dcp::VerificationNote::Type::WARNING] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY); + notebook->AddPage(_pages[dcp::VerificationNote::Type::WARNING], _("Warnings")); - auto summary = new wxStaticText(this, wxID_ANY, wxT("")); - sizer->Add(summary, 0, wxALL, DCPOMATIC_DIALOG_BORDER); + _summary = new wxStaticText(this, wxID_ANY, wxT("")); + sizer->Add(_summary, 0, wxALL, DCPOMATIC_DIALOG_BORDER); SetSizer(sizer); sizer->Layout(); sizer->SetSizeHints(this); - for (auto const& i: pages) { + for (auto const& i: _pages) { i.second->GetCaret()->Hide(); } +} + +void +VerifyDCPResultPanel::fill(shared_ptr job) +{ if (job->finished_ok() && job->notes().empty()) { - summary->SetLabel(_("DCP validates OK.")); + _summary->SetLabel(_("DCP validates OK.")); return; } @@ -75,11 +79,11 @@ VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent, shared_ptrBeginStandardBullet(N_("standard/diamond"), 1, 50); - pages[type]->WriteText(message); - pages[type]->Newline(); - pages[type]->EndStandardBullet(); + auto add_bullet = [this](dcp::VerificationNote::Type type, wxString message) { + _pages[type]->BeginStandardBullet(N_("standard/diamond"), 1, 50); + _pages[type]->WriteText(message); + _pages[type]->Newline(); + _pages[type]->EndStandardBullet(); }; auto add = [&counts, &add_bullet](dcp::VerificationNote note, wxString message) { @@ -473,7 +477,7 @@ VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent, shared_ptrSetLabel(summary_text); + _summary->SetLabel(summary_text); if (counts[dcp::VerificationNote::Type::ERROR] == 0) { add_bullet(dcp::VerificationNote::Type::ERROR, _("No errors found.")); diff --git a/src/wx/verify_dcp_result_panel.h b/src/wx/verify_dcp_result_panel.h index 7fd7a91d3..f0a502064 100644 --- a/src/wx/verify_dcp_result_panel.h +++ b/src/wx/verify_dcp_result_panel.h @@ -19,15 +19,24 @@ */ +#include #include +#include #include class VerifyDCPJob; +class wxRichTextCtrl; class VerifyDCPResultPanel : public wxPanel { public: - VerifyDCPResultPanel(wxWindow* parent, std::shared_ptr job); + VerifyDCPResultPanel(wxWindow* parent); + + void fill(std::shared_ptr job); + +private: + wxStaticText* _summary; + std::map _pages; };