#include "lib/job_manager.h"
#include "lib/job.h"
#include "lib/video_content.h"
+#include "lib/subtitle_content.h"
#include "wx/wx_signal_manager.h"
#include "wx/wx_util.h"
#include "wx/about_dialog.h"
#include "wx/film_viewer.h"
#include "wx/player_information.h"
#include "wx/update_dialog.h"
-#include "wx/config_dialog.h"
+#include "wx/player_config_dialog.h"
#include <wx/wx.h>
#include <wx/stdpaths.h>
#include <wx/splash.h>
#include <wx/cmdline.h>
#include <wx/preferences.h>
+#ifdef __WXOSX__
+#include <ApplicationServices/ApplicationServices.h>
+#endif
#include <boost/bind.hpp>
#include <iostream>
+#ifdef check
+#undef check
+#endif
+
using std::string;
using std::cout;
using std::exception;
enum {
ID_file_open = 1,
+ ID_file_add_ov,
+ ID_file_add_kdm,
ID_view_scale_appropriate,
ID_view_scale_full,
ID_view_scale_half,
SetIcon (wxIcon (std_to_wx ("id")));
#endif
+ _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this));
+
Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open);
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_ov, this), ID_file_add_ov);
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_kdm, this), ID_file_add_kdm);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>()), ID_view_scale_appropriate);
return;
}
+ if (dcp->subtitle) {
+ dcp->subtitle->set_use (true);
+ }
+
_viewer->set_film (_film);
_info->triggered_update ();
}
{
wxMenu* file = new wxMenu;
file->Append (ID_file_open, _("&Open...\tCtrl-O"));
+ file->Append (ID_file_add_ov, _("&Add OV..."));
+ file->Append (ID_file_add_kdm, _("&Add KDM..."));
#ifdef __WXOSX__
file->Append (wxID_EXIT, _("&Exit"));
c->Destroy ();
}
+ void file_add_ov ()
+ {
+ wxDirDialog* c = new wxDirDialog (
+ this,
+ _("Select DCP to open as OV"),
+ wxStandardPaths::Get().GetDocumentsDir(),
+ wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
+ );
+
+ int r;
+ while (true) {
+ r = c->ShowModal ();
+ if (r == wxID_OK && c->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) {
+ shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+ DCPOMATIC_ASSERT (dcp);
+ dcp->add_ov (wx_to_std(c->GetPath()));
+ dcp->examine (shared_ptr<Job>());
+ }
+
+ c->Destroy ();
+ _info->triggered_update ();
+ }
+
+ void file_add_kdm ()
+ {
+ wxFileDialog* d = new wxFileDialog (this, _("Select KDM"));
+
+ if (d->ShowModal() == wxID_OK) {
+ shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+ DCPOMATIC_ASSERT (dcp);
+ try {
+ dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)));
+ } catch (exception& e) {
+ error_dialog (this, wxString::Format (_("Could not load KDM (%s)"), e.what ()));
+ d->Destroy ();
+ return;
+ }
+
+ dcp->examine (shared_ptr<Job>());
+ }
+
+ d->Destroy ();
+ _info->triggered_update ();
+ }
+
void file_exit ()
{
Close ();
void edit_preferences ()
{
if (!_config_dialog) {
- _config_dialog = create_config_dialog ();
+ _config_dialog = create_player_config_dialog ();
}
_config_dialog->Show (this);
}
_update_news_requested = false;
}
+ void config_changed ()
+ {
+ /* Instantly save any config changes when using the player GUI */
+ try {
+ Config::instance()->write_config();
+ } catch (exception& e) {
+ error_dialog (
+ this,
+ wxString::Format (
+ _("Could not write to config file at %s. Your changes have not been saved."),
+ std_to_wx (Config::instance()->cinemas_file().string()).data()
+ )
+ );
+ }
+ }
+
bool _update_news_requested;
PlayerInformation* _info;
wxPreferencesEditor* _config_dialog;
FilmViewer* _viewer;
boost::shared_ptr<Film> _film;
+ boost::signals2::scoped_connection _config_changed_connection;
};
static const wxCmdLineEntryDesc command_line_description[] = {