#include "wx/content_panel.h"
#include "wx/report_problem_dialog.h"
#include "wx/video_waveform_dialog.h"
+#include "wx/save_template_dialog.h"
#include "lib/film.h"
#include "lib/config.h"
#include "lib/util.h"
#include "lib/compose.hpp"
#include "lib/cinema_kdms.h"
#include "lib/dcpomatic_socket.h"
+#include "lib/hints.h"
#include <dcp/exceptions.h>
+#include <dcp/raw_convert.h>
#include <wx/generic/aboutdlgg.h>
#include <wx/stdpaths.h>
#include <wx/cmdline.h>
#endif
#include <boost/filesystem.hpp>
#include <boost/noncopyable.hpp>
-#include <boost/make_shared.hpp>
#include <iostream>
#include <fstream>
+/* This is OK as it's only used with DCPOMATIC_WINDOWS */
#include <sstream>
#ifdef check
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::optional;
-using boost::make_shared;
+using dcp::raw_convert;
class FilmChangedDialog : public boost::noncopyable
{
ID_file_new = 1,
ID_file_open,
ID_file_save,
+ ID_file_save_as_template,
ID_file_history,
/* Allow spare IDs after _history for the recent files list */
ID_content_scale_to_fit_width = 100,
, _hints_dialog (0)
, _servers_list_dialog (0)
, _config_dialog (0)
+ , _kdm_dialog (0)
, _file_menu (0)
, _history_items (0)
, _history_position (0)
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_new, this), ID_file_new);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_open, this), ID_file_open);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_save, this), ID_file_save);
+ Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_save_as_template, this), ID_file_save_as_template);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
}
}
- void new_film (boost::filesystem::path path)
+ void new_film (boost::filesystem::path path, optional<string> template_name)
{
- shared_ptr<Film> film = make_shared<Film> (path);
+ shared_ptr<Film> film (new Film (path));
+ if (template_name) {
+ film->use_template (template_name.get());
+ }
film->write_metadata ();
film->set_name (path.filename().generic_string());
set_film (film);
void load_film (boost::filesystem::path file)
try
{
- shared_ptr<Film> film = make_shared<Film> (file);
+ shared_ptr<Film> film (new Film (file));
list<string> const notes = film->read_metadata ();
if (film->state_version() == 4) {
_film = film;
_film_viewer->set_film (_film);
_film_editor->set_film (_film);
+ delete _video_waveform_dialog;
+ _video_waveform_dialog = 0;
set_menu_sensitivity ();
- Config::instance()->add_to_history (_film->directory ());
+ if (_film->directory()) {
+ Config::instance()->add_to_history (_film->directory().get());
+ }
}
shared_ptr<Film> film () const {
if (r == wxID_OK) {
- if (boost::filesystem::is_directory (d->get_path()) && !boost::filesystem::is_empty(d->get_path())) {
+ if (boost::filesystem::is_directory (d->path()) && !boost::filesystem::is_empty(d->path())) {
if (!confirm_dialog (
this,
std_to_wx (
String::compose (wx_to_std (_("The directory %1 already exists and is not empty. "
"Are you sure you want to use it?")),
- d->get_path().string().c_str())
+ d->path().string().c_str())
)
)) {
return;
}
- } else if (boost::filesystem::is_regular_file (d->get_path())) {
+ } else if (boost::filesystem::is_regular_file (d->path())) {
error_dialog (
this,
- String::compose (wx_to_std (_("%1 already exists as a file, so you cannot use it for a new film.")), d->get_path().c_str())
+ String::compose (wx_to_std (_("%1 already exists as a file, so you cannot use it for a new film.")), d->path().c_str())
);
return;
}
if (maybe_save_then_delete_film ()) {
- new_film (d->get_path ());
+ new_film (d->path(), d->template_name());
}
}
_film->write_metadata ();
}
+ void file_save_as_template ()
+ {
+ SaveTemplateDialog* d = new SaveTemplateDialog (this);
+ int const r = d->ShowModal ();
+ if (r == wxID_OK) {
+ bool ok = true;
+ if (Config::instance()->existing_template (d->name ())) {
+ ok = confirm_dialog (d, _("There is already a template with this name. Do you want to overwrite it?"));
+ }
+ if (ok) {
+ Config::instance()->save_template (_film, d->name ());
+ }
+ }
+ d->Destroy ();
+ }
+
void file_history (wxCommandEvent& event)
{
vector<boost::filesystem::path> history = Config::instance()->history ();
}
}
+ if (!get_hints(_film).empty() && Config::instance()->show_hints_before_make_dcp()) {
+ HintsDialog* hints = new HintsDialog (this, _film, false);
+ int const r = hints->ShowModal();
+ hints->Destroy ();
+ if (r == wxID_CANCEL) {
+ return;
+ }
+ }
+
try {
/* It seems to make sense to auto-save metadata here, since the make DCP may last
a long time, and crashes/power failures are moderately likely.
return;
}
- KDMDialog* d = new KDMDialog (this, _film);
- if (d->ShowModal () != wxID_OK) {
- d->Destroy ();
- return;
- }
-
- try {
- list<ScreenKDM> screen_kdms = _film->make_kdms (d->screens(), d->cpl(), d->from(), d->until(), d->formulation());
- if (d->write_to ()) {
- ScreenKDM::write_files (
- _film->name(),
- screen_kdms,
- d->directory()
- );
- } else {
- JobManager::instance()->add (
- boost::make_shared<SendKDMEmailJob> (
- _film->name(),
- _film->dcp_name(),
- d->from(),
- d->until(),
- CinemaKDMs::collect (screen_kdms),
- _film->log()
- )
- );
- }
- } catch (dcp::NotEncryptedError& e) {
- error_dialog (this, _("CPL's content is not encrypted."));
- } catch (exception& e) {
- error_dialog (this, e.what ());
- } catch (...) {
- error_dialog (this, _("An unknown exception occurred."));
+ if (_kdm_dialog) {
+ _kdm_dialog->Destroy ();
+ _kdm_dialog = 0;
}
- d->Destroy ();
+ _kdm_dialog = new KDMDialog (this, _film);
+ _kdm_dialog->Show (this);
}
void jobs_make_dcp_batch ()
return;
}
+ if (!get_hints(_film).empty() && Config::instance()->show_hints_before_make_dcp()) {
+ HintsDialog* hints = new HintsDialog (this, _film, false);
+ int const r = hints->ShowModal();
+ hints->Destroy ();
+ if (r == wxID_CANCEL) {
+ return;
+ }
+ }
+
_film->write_metadata ();
/* i = 0; try to connect via socket
boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query);
Socket socket (5);
socket.connect (*endpoint_iterator);
- string s = _film->directory().string ();
+ DCPOMATIC_ASSERT (_film->directory ());
+ string s = _film->directory()->string ();
socket.write (s.length() + 1);
socket.write ((uint8_t *) s.c_str(), s.length() + 1);
/* OK\0 */
void jobs_show_dcp ()
{
+ DCPOMATIC_ASSERT (_film->directory ());
#ifdef DCPOMATIC_WINDOWS
wstringstream args;
args << "/select," << _film->dir (_film->dcp_name(false));
#ifdef DCPOMATIC_LINUX
int r = system ("which nautilus");
if (WEXITSTATUS (r) == 0) {
- r = system (string ("nautilus " + _film->directory().string()).c_str ());
+ r = system (string ("nautilus " + _film->directory()->string()).c_str ());
if (WEXITSTATUS (r)) {
error_dialog (this, _("Could not show DCP (could not run nautilus)"));
}
} else {
int r = system ("which konqueror");
if (WEXITSTATUS (r) == 0) {
- r = system (string ("konqueror " + _film->directory().string()).c_str ());
+ r = system (string ("konqueror " + _film->directory()->string()).c_str ());
if (WEXITSTATUS (r)) {
error_dialog (this, _("Could not show DCP (could not run konqueror)"));
}
void tools_video_waveform ()
{
if (!_video_waveform_dialog) {
- _video_waveform_dialog = new VideoWaveformDialog (this, _film_viewer);
+ _video_waveform_dialog = new VideoWaveformDialog (this, _film, _film_viewer);
}
_video_waveform_dialog->Show ();
void tools_hints ()
{
if (!_hints_dialog) {
- _hints_dialog = new HintsDialog (this, _film);
+ _hints_dialog = new HintsDialog (this, _film, true);
}
_hints_dialog->Show ();
add_item (_file_menu, _("&Open...\tCtrl-O"), ID_file_open, ALWAYS);
_file_menu->AppendSeparator ();
add_item (_file_menu, _("&Save\tCtrl-S"), ID_file_save, NEEDS_FILM);
+ _file_menu->AppendSeparator ();
+ add_item (_file_menu, _("Save as &template..."), ID_file_save_as_template, NEEDS_FILM);
_history_position = _file_menu->GetMenuItems().GetCount();
}
for (size_t i = 0; i < history.size(); ++i) {
- SafeStringStream s;
+ string s;
if (i < 9) {
- s << "&" << (i + 1) << " ";
+ s = String::compose ("&%1 %2", i + 1, history[i].string());
+ } else {
+ s = history[i].string();
}
- s << history[i].string();
- _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s.str ()));
+ _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s));
}
_history_items = history.size ();
HintsDialog* _hints_dialog;
ServersListDialog* _servers_list_dialog;
wxPreferencesEditor* _config_dialog;
+ KDMDialog* _kdm_dialog;
wxMenu* _file_menu;
shared_ptr<Film> _film;
int _history_items;
{
wxInitAllImageHandlers ();
+ Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+
wxSplashScreen* splash = 0;
try {
if (!Config::have_existing ("config.xml")) {
}
if (!_film_to_create.empty ()) {
- _frame->new_film (_film_to_create);
+ _frame->new_film (_film_to_create, optional<string> ());
if (!_content_to_add.empty ()) {
_frame->film()->examine_and_add_content (content_factory (_frame->film(), _content_to_add));
}
}
}
+ void config_failed_to_load ()
+ {
+ message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create."));
+ }
+
DOMFrame* _frame;
shared_ptr<wxTimer> _timer;
string _film_to_load;