summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-07-25 16:49:35 +0100
committerCarl Hetherington <cth@carlh.net>2017-07-25 16:49:35 +0100
commitc3e2b2051f4c50d92c7bbe59c42174984c2f3e54 (patch)
tree267ef4cde4d1c23424b3c0250d53063564e7fff3 /src/wx
parentbd12168f1381e8e5fb197e5f25cf716fcf012010 (diff)
First go at configurable config.xml location.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/config_dialog.cc35
-rw-r--r--src/wx/config_move_dialog.cc41
-rw-r--r--src/wx/config_move_dialog.h28
-rw-r--r--src/wx/confirm_kdm_email_dialog.cc18
-rw-r--r--src/wx/confirm_kdm_email_dialog.h3
-rw-r--r--src/wx/question_dialog.cc43
-rw-r--r--src/wx/question_dialog.h33
-rw-r--r--src/wx/wscript2
8 files changed, 188 insertions, 15 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index 233766cba..f41d5146c 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -34,6 +34,7 @@
#include "email_dialog.h"
#include "name_format_editor.h"
#include "nag_dialog.h"
+#include "config_move_dialog.h"
#include "lib/config.h"
#include "lib/ratio.h"
#include "lib/filter.h"
@@ -212,6 +213,11 @@ private:
table->Add (_server_encoding_threads, wxGBPosition (r, 1));
++r;
+ add_label_to_sizer (table, _panel, _("Configuration file"), true, wxGBPosition (r, 0));
+ _config_file = new FilePickerCtrl (_panel, _("Select configuration file"), "*.xml", true);
+ table->Add (_config_file, wxGBPosition (r, 1));
+ ++r;
+
add_label_to_sizer (table, _panel, _("Cinema and screen database file"), true, wxGBPosition (r, 0));
_cinemas_file = new FilePickerCtrl (_panel, _("Select cinema and screen database file"), "*.xml", true);
table->Add (_cinemas_file, wxGBPosition (r, 1));
@@ -265,6 +271,7 @@ private:
_set_language->Bind (wxEVT_CHECKBOX, boost::bind (&GeneralPage::set_language_changed, this));
_language->Bind (wxEVT_CHOICE, boost::bind (&GeneralPage::language_changed, this));
+ _config_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind (&GeneralPage::config_file_changed, this));
_cinemas_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind (&GeneralPage::cinemas_file_changed, this));
_preview_sound->Bind (wxEVT_CHECKBOX, boost::bind (&GeneralPage::preview_sound_changed, this));
_preview_sound_output->Bind (wxEVT_CHOICE, boost::bind (&GeneralPage::preview_sound_output_changed, this));
@@ -325,6 +332,7 @@ private:
checked_set (_check_for_test_updates, config->check_for_test_updates ());
checked_set (_issuer, config->dcp_issuer ());
checked_set (_creator, config->dcp_creator ());
+ checked_set (_config_file, config->config_file());
checked_set (_cinemas_file, config->cinemas_file());
checked_set (_preview_sound, config->preview_sound());
@@ -438,6 +446,32 @@ private:
Config::instance()->set_dcp_creator (wx_to_std (_creator->GetValue ()));
}
+ void config_file_changed ()
+ {
+ Config* config = Config::instance();
+ boost::filesystem::path new_file = wx_to_std(_config_file->GetPath());
+ if (new_file == config->config_file()) {
+ return;
+ }
+ bool copy_and_link = true;
+ if (boost::filesystem::exists(new_file)) {
+ ConfigMoveDialog* d = new ConfigMoveDialog (_panel, new_file);
+ if (d->ShowModal() == wxID_OK) {
+ copy_and_link = false;
+ }
+ d->Destroy ();
+ }
+
+ if (copy_and_link) {
+ config->write ();
+ if (new_file != config->config_file()) {
+ config->copy_and_link (new_file);
+ }
+ } else {
+ config->link (new_file);
+ }
+ }
+
void cinemas_file_changed ()
{
Config::instance()->set_cinemas_file (wx_to_std (_cinemas_file->GetPath ()));
@@ -463,6 +497,7 @@ private:
wxChoice* _language;
wxSpinCtrl* _master_encoding_threads;
wxSpinCtrl* _server_encoding_threads;
+ FilePickerCtrl* _config_file;
FilePickerCtrl* _cinemas_file;
wxCheckBox* _preview_sound;
wxChoice* _preview_sound_output;
diff --git a/src/wx/config_move_dialog.cc b/src/wx/config_move_dialog.cc
new file mode 100644
index 000000000..ec677f6af
--- /dev/null
+++ b/src/wx/config_move_dialog.cc
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2017 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/>.
+
+*/
+
+#include "config_move_dialog.h"
+#include "wx_util.h"
+#include <boost/filesystem.hpp>
+
+ConfigMoveDialog::ConfigMoveDialog (wxWindow* parent, boost::filesystem::path new_file)
+ : QuestionDialog (
+ parent,
+ _("Move configuration"),
+ _("Use this file as new configuration"),
+ _("Overwrite this file with current configuration")
+ )
+{
+ wxString message = wxString::Format (
+ _("The file %s already exists. Do you want to use it as your new configuration or overwrite it with your current configuration?"),
+ std_to_wx(new_file.string()).data()
+ );
+
+ _sizer->Add (new wxStaticText (this, wxID_ANY, message), 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+
+ layout ();
+}
diff --git a/src/wx/config_move_dialog.h b/src/wx/config_move_dialog.h
new file mode 100644
index 000000000..b7cea1155
--- /dev/null
+++ b/src/wx/config_move_dialog.h
@@ -0,0 +1,28 @@
+/*
+ Copyright (C) 2017 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/>.
+
+*/
+
+#include "question_dialog.h"
+#include <boost/filesystem.hpp>
+
+class ConfigMoveDialog : public QuestionDialog
+{
+public:
+ ConfigMoveDialog (wxWindow* parent, boost::filesystem::path new_file);
+};
diff --git a/src/wx/confirm_kdm_email_dialog.cc b/src/wx/confirm_kdm_email_dialog.cc
index d622f2934..4815f26db 100644
--- a/src/wx/confirm_kdm_email_dialog.cc
+++ b/src/wx/confirm_kdm_email_dialog.cc
@@ -28,31 +28,21 @@ using std::list;
using std::string;
ConfirmKDMEmailDialog::ConfirmKDMEmailDialog (wxWindow* parent, list<string> emails)
- : wxDialog (parent, wxID_ANY, _("Confirm KDM email"))
+ : QuestionDialog (parent, _("Confirm KDM email"), _("Send emails"), _("Don't send emails"))
{
- wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
-
wxString message = _("Are you sure you want to send emails to the following addresses?\n\n");
BOOST_FOREACH (string i, emails) {
message += "\t" + std_to_wx (i) + "\n";
}
- sizer->Add (new wxStaticText (this, wxID_ANY, message), 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+ _sizer->Add (new wxStaticText (this, wxID_ANY, message), 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
wxCheckBox* shut_up = new wxCheckBox (this, wxID_ANY, _("Don't ask this again"));
- sizer->Add (shut_up, 0, wxALL, DCPOMATIC_DIALOG_BORDER);
+ _sizer->Add (shut_up, 0, wxALL, DCPOMATIC_DIALOG_BORDER);
shut_up->Bind (wxEVT_CHECKBOX, bind (&ConfirmKDMEmailDialog::shut_up, this, _1));
- wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0);
- sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
- buttons->SetAffirmativeButton (new wxButton (this, wxID_OK, _("Send emails")));
- buttons->SetNegativeButton (new wxButton (this, wxID_CANCEL, _("Don't send emails")));
- buttons->Realize ();
-
- SetSizer (sizer);
- sizer->Layout ();
- sizer->SetSizeHints (this);
+ layout ();
}
void
diff --git a/src/wx/confirm_kdm_email_dialog.h b/src/wx/confirm_kdm_email_dialog.h
index 84182ad93..311cb08ea 100644
--- a/src/wx/confirm_kdm_email_dialog.h
+++ b/src/wx/confirm_kdm_email_dialog.h
@@ -18,10 +18,11 @@
*/
+#include "question_dialog.h"
#include <wx/wx.h>
#include <list>
-class ConfirmKDMEmailDialog : public wxDialog
+class ConfirmKDMEmailDialog : public QuestionDialog
{
public:
ConfirmKDMEmailDialog (wxWindow* parent, std::list<std::string> addresses);
diff --git a/src/wx/question_dialog.cc b/src/wx/question_dialog.cc
new file mode 100644
index 000000000..5b6c0b414
--- /dev/null
+++ b/src/wx/question_dialog.cc
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2017 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/>.
+
+*/
+
+#include "question_dialog.h"
+
+QuestionDialog::QuestionDialog (wxWindow* parent, wxString title, wxString affirmative, wxString negative)
+ : wxDialog (parent, wxID_ANY, title)
+ , _affirmative (affirmative)
+ , _negative (negative)
+{
+ _sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (_sizer);
+}
+
+void
+QuestionDialog::layout ()
+{
+ wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0);
+ _sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
+ buttons->SetAffirmativeButton (new wxButton (this, wxID_OK, _affirmative));
+ buttons->SetNegativeButton (new wxButton (this, wxID_CANCEL, _negative));
+ buttons->Realize ();
+
+ _sizer->Layout ();
+ _sizer->SetSizeHints (this);
+}
diff --git a/src/wx/question_dialog.h b/src/wx/question_dialog.h
new file mode 100644
index 000000000..a3b05173a
--- /dev/null
+++ b/src/wx/question_dialog.h
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 2017 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/>.
+
+*/
+
+#include <wx/wx.h>
+
+class QuestionDialog : public wxDialog
+{
+public:
+ QuestionDialog (wxWindow* parent, wxString title, wxString affirmative, wxString negative);
+
+protected:
+ void layout ();
+ wxSizer* _sizer;
+ wxString _affirmative;
+ wxString _negative;
+};
diff --git a/src/wx/wscript b/src/wx/wscript
index 142f0a24e..66b928247 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -35,6 +35,7 @@ sources = """
cinema_dialog.cc
colour_conversion_editor.cc
config_dialog.cc
+ config_move_dialog.cc
confirm_kdm_email_dialog.cc
content_colour_conversion_dialog.cc
content_menu.cc
@@ -76,6 +77,7 @@ sources = """
normal_job_view.cc
playhead_to_timecode_dialog.cc
playhead_to_frame_dialog.cc
+ question_dialog.cc
repeat_dialog.cc
report_problem_dialog.cc
rename_template_dialog.cc