2 Copyright (C) 2017-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "check_box.h"
23 #include "export_subtitles_dialog.h"
24 #include "file_picker_ctrl.h"
26 #include "lib/warnings.h"
27 DCPOMATIC_DISABLE_WARNINGS
28 #include <wx/filepicker.h>
29 DCPOMATIC_ENABLE_WARNINGS
30 #include <boost/bind.hpp>
37 ExportSubtitlesDialog::ExportSubtitlesDialog (wxWindow* parent, int reels, bool interop)
38 : TableDialog (parent, _("Export subtitles"), 2, 1, true)
42 _split_reels = new CheckBox (this, _("Write reels into separate files"));
43 add (_split_reels, false);
47 _split_reels->Enable (false);
50 _include_font = new CheckBox (this, _("Define font in output and export font file"));
51 add (_include_font, false);
55 _include_font->Enable (false);
58 wxString const wildcard = _interop ? _("Subtitle files (.xml)|*.xml") : _("Subtitle files (.mxf)|*.mxf");
60 _file_label = add (_("Output file"), true);
61 _file = new FilePickerCtrl (this, _("Select output file"), wildcard, false, true);
64 _dir_label = add (_("Output folder"), true);
65 _dir = new DirPickerCtrl (this);
68 _split_reels->Bind (wxEVT_CHECKBOX, bind(&ExportSubtitlesDialog::setup_sensitivity, this));
69 _include_font->Bind (wxEVT_CHECKBOX, bind(&ExportSubtitlesDialog::setup_sensitivity, this));
70 _file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&ExportSubtitlesDialog::setup_sensitivity, this));
71 _dir->Bind (wxEVT_DIRPICKER_CHANGED, bind(&ExportSubtitlesDialog::setup_sensitivity, this));
79 ExportSubtitlesDialog::setup_sensitivity ()
81 bool const multi = split_reels() || (_interop && _include_font->GetValue());
82 _file_label->Enable (!multi);
83 _file->Enable (!multi);
84 _dir_label->Enable (multi);
87 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById(wxID_OK, this));
88 DCPOMATIC_ASSERT (ok);
89 ok->Enable (path().is_absolute());
93 /** @return Either a full path to a file, if the output will be one file, or
94 * a full path to a directory.
96 boost::filesystem::path
97 ExportSubtitlesDialog::path () const
99 if (_file->IsEnabled()) {
100 wxFileName fn (_file->GetPath());
101 fn.SetExt (_interop ? "xml" : "mxf");
102 return wx_to_std (fn.GetFullPath());
105 return wx_to_std (_dir->GetPath());
110 ExportSubtitlesDialog::split_reels () const
112 return _split_reels->GetValue ();
117 ExportSubtitlesDialog::include_font () const
119 return !_interop || _include_font->GetValue();