summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-29 09:57:58 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-29 09:57:58 +0100
commit736b3a068ba5a402b541d32f270669e6e1a4e5c4 (patch)
tree2185f71bde7283683161bd3a557f13b7a610e967 /src/wx
parent71be005818ddaa59cdcca2fa5fb3210d8ea7ae4f (diff)
Allow configuration of KDM filename format.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/kdm_dialog.cc14
-rw-r--r--src/wx/kdm_dialog.h4
-rw-r--r--src/wx/kdm_output_panel.cc35
-rw-r--r--src/wx/kdm_output_panel.h5
-rw-r--r--src/wx/name_format_editor.h91
5 files changed, 149 insertions, 0 deletions
diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc
index 7f3f4b07b..ee164518a 100644
--- a/src/wx/kdm_dialog.cc
+++ b/src/wx/kdm_dialog.cc
@@ -161,3 +161,17 @@ KDMDialog::formulation () const
{
return _output->formulation ();
}
+
+KDMNameFormat
+KDMDialog::name_format () const
+{
+ return _output->name_format ();
+}
+
+int
+KDMDialog::ShowModal ()
+{
+ int const r = wxDialog::ShowModal ();
+ _output->save_kdm_name_format ();
+ return r;
+}
diff --git a/src/wx/kdm_dialog.h b/src/wx/kdm_dialog.h
index e0111b6c5..7d64fea77 100644
--- a/src/wx/kdm_dialog.h
+++ b/src/wx/kdm_dialog.h
@@ -19,6 +19,7 @@
*/
#include "wx_util.h"
+#include "lib/kdm_name_format.h"
#include <dcp/types.h>
#include <wx/wx.h>
#include <boost/shared_ptr.hpp>
@@ -50,6 +51,9 @@ public:
boost::filesystem::path directory () const;
bool write_to () const;
dcp::Formulation formulation () const;
+ KDMNameFormat name_format () const;
+
+ int ShowModal ();
private:
void setup_sensitivity ();
diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc
index 901832684..49e561c65 100644
--- a/src/wx/kdm_output_panel.cc
+++ b/src/wx/kdm_output_panel.cc
@@ -18,8 +18,10 @@
*/
+#include "lib/config.h"
#include "kdm_output_panel.h"
#include "wx_util.h"
+#include "name_format_editor.h"
#include <dcp/types.h>
#ifdef DCPOMATIC_USE_OWN_PICKER
#include "dir_picker_ctrl.h"
@@ -43,6 +45,27 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent, bool interop)
table->Add (_type, 1, wxEXPAND);
_type->SetSelection (0);
+ {
+ int flags = wxALIGN_TOP | wxTOP;
+ wxString t = _("Filename format");
+#ifdef __WXOSX__
+ flags |= wxALIGN_RIGHT;
+ t += wxT (":");
+#endif
+ wxStaticText* m = new wxStaticText (this, wxID_ANY, t);
+ table->Add (m, 0, flags, DCPOMATIC_SIZER_Y_GAP);
+ }
+
+ _filename_format = new NameFormatEditor<KDMNameFormat> (this, Config::instance()->kdm_filename_format());
+ NameFormat::Map ex;
+ ex["film_name"] = "Bambi";
+ ex["cinema"] = "Lumière";
+ ex["screen"] = "Screen 1";
+ ex["from"] = "2012/03/15 12:30";
+ ex["to"] = "2012/03/22 02:30";
+ _filename_format->set_example (ex);
+ table->Add (_filename_format->panel(), 1, wxEXPAND);
+
_write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
table->Add (_write_to, 1, wxEXPAND);
@@ -91,3 +114,15 @@ KDMOutputPanel::formulation () const
{
return (dcp::Formulation) reinterpret_cast<intptr_t> (_type->GetClientData (_type->GetSelection()));
}
+
+void
+KDMOutputPanel::save_kdm_name_format () const
+{
+ Config::instance()->set_kdm_filename_format (name_format ());
+}
+
+KDMNameFormat
+KDMOutputPanel::name_format () const
+{
+ return _filename_format->get ();
+}
diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h
index 0ca55e325..002b189f5 100644
--- a/src/wx/kdm_output_panel.h
+++ b/src/wx/kdm_output_panel.h
@@ -19,6 +19,8 @@
*/
#include "wx_util.h"
+#include "name_format_editor.h"
+#include "lib/kdm_name_format.h"
#include <dcp/types.h>
#include <wx/wx.h>
#include <boost/filesystem.hpp>
@@ -34,11 +36,14 @@ public:
boost::filesystem::path directory () const;
bool write_to () const;
dcp::Formulation formulation () const;
+ KDMNameFormat name_format () const;
void setup_sensitivity ();
+ void save_kdm_name_format () const;
private:
wxChoice* _type;
+ NameFormatEditor<KDMNameFormat>* _filename_format;
wxRadioButton* _write_to;
#ifdef DCPOMATIC_USE_OWN_PICKER
DirPickerCtrl* _folder;
diff --git a/src/wx/name_format_editor.h b/src/wx/name_format_editor.h
new file mode 100644
index 000000000..ee88d46b3
--- /dev/null
+++ b/src/wx/name_format_editor.h
@@ -0,0 +1,91 @@
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_NAME_FORMAT_EDITOR_H
+#define DCPOMATIC_NAME_FORMAT_EDITOR_H
+
+#include "lib/name_format.h"
+#include "lib/compose.hpp"
+#include <wx/wx.h>
+#include <boost/foreach.hpp>
+
+template <class T>
+class NameFormatEditor
+{
+public:
+ NameFormatEditor (wxWindow* parent, T name)
+ : _panel (new wxPanel (parent))
+ , _example (new wxStaticText (_panel, wxID_ANY, ""))
+ , _sizer (new wxBoxSizer (wxVERTICAL))
+ , _specification (new wxTextCtrl (_panel, wxID_ANY, ""))
+ , _name (name)
+ {
+ _sizer->Add (_specification, 0, wxEXPAND, DCPOMATIC_SIZER_Y_GAP);
+ _sizer->Add (_example, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
+ _panel->SetSizer (_sizer);
+
+ BOOST_FOREACH (NameFormat::Component c, name.components ()) {
+ wxStaticText* t = new wxStaticText (_panel, wxID_ANY, std_to_wx (String::compose ("%%%1 %2", c.placeholder, c.title)));
+ _sizer->Add (t);
+ wxFont font = t->GetFont();
+ font.SetStyle (wxFONTSTYLE_ITALIC);
+ font.SetPointSize (font.GetPointSize() - 1);
+ t->SetFont (font);
+ t->SetForegroundColour (wxColour (0, 0, 204));
+ }
+
+ _specification->SetValue (std_to_wx (_name.specification ()));
+ _specification->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&NameFormatEditor::update_example, this));
+
+ update_example ();
+ }
+
+ wxPanel* panel () const
+ {
+ return _panel;
+ }
+
+ void set_example (NameFormat::Map v) {
+ _example_values = v;
+ update_example ();
+ }
+
+ T get () const {
+ return _name;
+ }
+
+private:
+
+ virtual void update_example ()
+ {
+ _name.set_specification (wx_to_std (_specification->GetValue ()));
+ _example->SetLabel (wxString::Format (_("e.g. %s"), _name.get (_example_values)));
+ }
+
+ wxPanel* _panel;
+ wxStaticText* _example;
+ wxSizer* _sizer;
+ wxTextCtrl* _specification;
+
+ T _name;
+ NameFormat::Map _example_values;
+};
+
+#endif