void file_open ()
{
auto d = wxStandardPaths::Get().GetDocumentsDir();
- auto c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
+ wxDirDialog dialog(this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
int r;
while (true) {
- r = c->ShowModal ();
- if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
+ r = dialog.ShowModal();
+ if (r == wxID_OK && dialog.GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
} else {
break;
}
if (r == wxID_OK) {
- boost::filesystem::path const dcp (wx_to_std (c->GetPath ()));
+ boost::filesystem::path const dcp(wx_to_std(dialog.GetPath()));
load_dcp (dcp);
}
-
- c->Destroy ();
}
void file_save ()
void help_about ()
{
- auto d = new AboutDialog (this);
- d->ShowModal ();
- d->Destroy ();
+ AboutDialog dialog(this);
+ dialog.ShowModal();
}
wxPanel* _overall_panel = nullptr;
void
AudioPanel::gain_calculate_button_clicked ()
{
- auto d = new GainCalculatorDialog (this);
- auto const r = d->ShowModal ();
- auto c = d->db_change();
+ GainCalculatorDialog dialog(this);
+ auto const r = dialog.ShowModal();
+ auto change = dialog.db_change();
- if (r == wxID_CANCEL || !c) {
- d->Destroy ();
+ if (r == wxID_CANCEL || !change) {
return;
}
auto old_peak_dB = peak ();
auto old_value = _gain->wrapped()->GetValue();
- _gain->wrapped()->SetValue(old_value + *c);
+ _gain->wrapped()->SetValue(old_value + *change);
/* This appears to be necessary, as the change is not signalled,
I think.
_gain->wrapped()->SetValue (old_value);
_gain->view_changed ();
}
-
- d->Destroy ();
}
if (_warn_overwrite) {
style |= wxFD_OVERWRITE_PROMPT;
}
- wxFileDialog* d = new wxFileDialog (this, _prompt, wxEmptyString, wxEmptyString, _wildcard, style);
- d->SetPath (_path);
- if (d->ShowModal () == wxID_OK) {
- SetPath (d->GetPath ());
+ wxFileDialog dialog(this, _prompt, wxEmptyString, wxEmptyString, _wildcard, style);
+ dialog.SetPath(_path);
+ if (dialog.ShowModal() == wxID_OK) {
+ SetPath(dialog.GetPath());
}
- d->Destroy ();
}
void
void export_cinemas_file ()
{
- auto d = new wxFileDialog (
+ wxFileDialog dialog(
_panel, _("Select Cinemas File"), wxEmptyString, wxEmptyString, wxT("XML files (*.xml)|*.xml"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- if (d->ShowModal () == wxID_OK) {
- boost::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(d->GetPath()), boost::filesystem::copy_option::overwrite_if_exists);
+ if (dialog.ShowModal() == wxID_OK) {
+ boost::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(dialog.GetPath()), boost::filesystem::copy_option::overwrite_if_exists);
}
- d->Destroy ();
}
#ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
}
bool copy_and_link = true;
if (boost::filesystem::exists(new_file)) {
- auto d = new ConfigMoveDialog (_panel, new_file);
- if (d->ShowModal() == wxID_OK) {
+ ConfigMoveDialog dialog(_panel, new_file);
+ if (dialog.ShowModal() == wxID_OK) {
copy_and_link = false;
}
- d->Destroy ();
}
if (copy_and_link) {
void send_test_email_clicked ()
{
- auto dialog = new SendTestEmailDialog(_panel);
- auto result = dialog->ShowModal();
- dialog->Destroy();
- if (result == wxID_OK) {
- Emailer emailer(
- wx_to_std(dialog->from()),
- { wx_to_std(dialog->to()) },
- wx_to_std(_("DCP-o-matic test email")),
- wx_to_std(_("This is a test email from DCP-o-matic."))
- );
- auto config = Config::instance();
- try {
- emailer.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
- } catch (NetworkError& e) {
- error_dialog (_panel, std_to_wx(e.summary()), std_to_wx(e.detail().get_value_or("")));
- return;
- } catch (std::exception& e) {
- error_dialog (_panel, _("Test email sending failed."), std_to_wx(e.what()));
- return;
- } catch (...) {
- error_dialog (_panel, _("Test email sending failed."));
- return;
- }
- message_dialog (_panel, _("Test email sent."));
+ SendTestEmailDialog dialog(_panel);
+ if (dialog.ShowModal() != wxID_OK) {
+ return;
+ }
+
+ Emailer emailer(
+ wx_to_std(dialog.from()),
+ { wx_to_std(dialog.to()) },
+ wx_to_std(_("DCP-o-matic test email")),
+ wx_to_std(_("This is a test email from DCP-o-matic."))
+ );
+ auto config = Config::instance();
+ try {
+ emailer.send(config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
+ } catch (NetworkError& e) {
+ error_dialog(_panel, std_to_wx(e.summary()), std_to_wx(e.detail().get_value_or("")));
+ return;
+ } catch (std::exception& e) {
+ error_dialog(_panel, _("Test email sending failed."), std_to_wx(e.what()));
+ return;
+ } catch (...) {
+ error_dialog(_panel, _("Test email sending failed."));
+ return;
}
+ message_dialog(_panel, _("Test email sent."));
}
wxTextCtrl* _server;
}
if (_job->message()) {
- auto d = new MessageDialog (_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
- d->ShowModal ();
- d->Destroy ();
+ MessageDialog dialog(_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
+ dialog.ShowModal();
}
if (_job->enable_notify() && _notify->GetValue()) {
void
KDMOutputPanel::advanced_clicked ()
{
- auto d = new KDMAdvancedDialog (this, _forensic_mark_video, _forensic_mark_audio, _forensic_mark_audio_up_to);
- d->ShowModal ();
- _forensic_mark_video = d->forensic_mark_video ();
- _forensic_mark_audio = d->forensic_mark_audio ();
- _forensic_mark_audio_up_to = d->forensic_mark_audio_up_to ();
- d->Destroy ();
+ KDMAdvancedDialog dialog(this, _forensic_mark_video, _forensic_mark_audio, _forensic_mark_audio_up_to);
+ dialog.ShowModal();
+ _forensic_mark_video = dialog.forensic_mark_video();
+ _forensic_mark_audio = dialog.forensic_mark_audio();
+ _forensic_mark_audio_up_to = dialog.forensic_mark_audio_up_to();
}
void
KDMOutputPanel::add_email_addresses_clicked ()
{
- auto dialog = new ExtraKDMEmailDialog (this, _extra_addresses);
- if (dialog->ShowModal() == wxID_OK) {
- _extra_addresses = dialog->get();
+ ExtraKDMEmailDialog dialog(this, _extra_addresses);
+ if (dialog.ShowModal() == wxID_OK) {
+ _extra_addresses = dialog.get();
}
- dialog->Destroy();
}
void
LanguageTagDialog::add_language ()
{
- auto full = new FullLanguageTagDialog (GetParent());
- auto r = full->ShowModal ();
- if (r == wxID_OK) {
- Config::instance()->add_custom_language (full->get());
- set (full->get());
+ FullLanguageTagDialog full(GetParent());
+ if (full.ShowModal() == wxID_OK) {
+ Config::instance()->add_custom_language(full.get());
+ set(full.get());
}
- full->Destroy ();
}
return false;
}
- auto d = new NagDialog (parent, nag, message, can_cancel);
- int const r = d->ShowModal();
- d->Destroy ();
-
- return r == wxID_CANCEL;
+ NagDialog dialog(parent, nag, message, can_cancel);
+ return dialog.ShowModal() == wxID_CANCEL;
}
li.m_mask = wxLIST_MASK_TEXT;
_list->GetItem (li);
- auto d = new RenameTemplateDialog (this);
- d->set (li.m_text);
- if (d->ShowModal() == wxID_OK) {
- if (!d->get().IsEmpty()) {
- Config::instance()->rename_template (wx_to_std (li.m_text), wx_to_std (d->get ()));
- _list->SetItem (item, 0, d->get());
- } else {
- error_dialog (this, _("Template names must not be empty."));
- }
+ RenameTemplateDialog dialog(this);
+ dialog.set(li.m_text);
+ if (dialog.ShowModal() != wxID_OK) {
+ return;
+ }
+
+ if (!dialog.get().IsEmpty()) {
+ Config::instance()->rename_template(wx_to_std(li.m_text), wx_to_std(dialog.get()));
+ _list->SetItem(item, 0, dialog.get());
+ } else {
+ error_dialog (this, _("Template names must not be empty."));
}
- d->Destroy ();
}
auto c = _parent->selected_text ();
DCPOMATIC_ASSERT (c.size() == 1);
- auto d = new SubtitleAppearanceDialog (this, _parent->film(), c.front(), c.front()->text_of_original_type(_original_type));
- if (d->ShowModal () == wxID_OK) {
- d->apply ();
+ SubtitleAppearanceDialog dialog(this, _parent->film(), c.front(), c.front()->text_of_original_type(_original_type));
+ if (dialog.ShowModal() == wxID_OK) {
+ dialog.apply();
}
- d->Destroy ();
}
{
auto vc = _parent->selected_video ();
- auto d = new ContentColourConversionDialog (this, vc.front()->video->yuv ());
- d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front().conversion));
- if (d->ShowModal() == wxID_OK) {
+ ContentColourConversionDialog dialog(this, vc.front()->video->yuv());
+ dialog.set(vc.front()->video->colour_conversion().get_value_or(PresetColourConversion::all().front().conversion));
+ if (dialog.ShowModal() == wxID_OK) {
for (auto i: vc) {
- i->video->set_colour_conversion (d->get ());
+ i->video->set_colour_conversion(dialog.get());
}
} else {
/* Reset the colour conversion choice */
film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
}
- d->Destroy ();
}
VideoPanel::scale_custom_edit_clicked ()
{
auto vc = _parent->selected_video().front()->video;
- auto d = new CustomScaleDialog (this, vc->size(), _parent->film()->frame_size(), vc->custom_ratio(), vc->custom_size());
- int const r = d->ShowModal ();
- if (r == wxID_OK) {
- for (auto i: _parent->selected_video()) {
- i->video->set_custom_ratio (d->custom_ratio());
- i->video->set_custom_size (d->custom_size());
- }
+ CustomScaleDialog dialog(this, vc->size(), _parent->film()->frame_size(), vc->custom_ratio(), vc->custom_size());
+ if (dialog.ShowModal() != wxID_OK) {
+ return false;
+ }
+
+ for (auto i: _parent->selected_video()) {
+ i->video->set_custom_ratio(dialog.custom_ratio());
+ i->video->set_custom_size(dialog.custom_size());
}
- d->Destroy ();
- return r == wxID_OK;
+
+ return true;
}