diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-05-04 10:55:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-05-04 10:55:53 +0100 |
| commit | bb80004d3201047a33dd251ea6c3f6de2b47cb3b (patch) | |
| tree | 8b2520011c7d5f346c2725bb23a551b872850050 | |
| parent | 9b1fb6530563dfd8f32a8568d26c768b1006de90 (diff) | |
Nag users to backup config.xml if they make a DKDM.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | src/lib/config.cc | 21 | ||||
| -rw-r--r-- | src/lib/config.h | 15 | ||||
| -rw-r--r-- | src/tools/dcpomatic.cc | 12 | ||||
| -rw-r--r-- | src/wx/nag_dialog.cc | 68 | ||||
| -rw-r--r-- | src/wx/nag_dialog.h | 37 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
7 files changed, 158 insertions, 0 deletions
@@ -1,3 +1,7 @@ +2017-05-04 Carl Hetherington <cth@carlh.net> + + * Nag users to backup config.xml if they make a DKDM. + 2017-05-03 Carl Hetherington <cth@carlh.net> * Version 2.11.3 released. diff --git a/src/lib/config.cc b/src/lib/config.cc index 9fdf57207..c0ab44923 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -117,6 +117,9 @@ Config::set_defaults () _dcp_metadata_filename_format = dcp::NameFormat ("%t"); _dcp_asset_filename_format = dcp::NameFormat ("%t"); _jump_to_selected = true; + for (int i = 0; i < NAG_COUNT; ++i) { + _nagged[i] = false; + } _preview_sound = false; _preview_sound_output = optional<string> (); @@ -318,6 +321,12 @@ try _dcp_metadata_filename_format = dcp::NameFormat (f.optional_string_child("DCPMetadataFilenameFormat").get_value_or ("%t")); _dcp_asset_filename_format = dcp::NameFormat (f.optional_string_child("DCPAssetFilenameFormat").get_value_or ("%t")); _jump_to_selected = f.optional_bool_child("JumpToSelected").get_value_or (true); + BOOST_FOREACH (cxml::NodePtr i, f.node_children("Nagged")) { + int const id = i->number_attribute<int>("Id"); + if (id >= 0 && id < NAG_COUNT) { + _nagged[id] = raw_convert<int>(i->content()); + } + } _preview_sound = f.optional_bool_child("PreviewSound").get_value_or (false); _preview_sound_output = f.optional_string_child("PreviewSoundOutput"); @@ -496,6 +505,11 @@ Config::write_config () const root->add_child("DCPMetadataFilenameFormat")->add_child_text (_dcp_metadata_filename_format.specification ()); root->add_child("DCPAssetFilenameFormat")->add_child_text (_dcp_asset_filename_format.specification ()); root->add_child("JumpToSelected")->add_child_text (_jump_to_selected ? "1" : "0"); + for (int i = 0; i < NAG_COUNT; ++i) { + xmlpp::Element* e = root->add_child ("Nagged"); + e->set_attribute ("Id", raw_convert<string>(i)); + e->add_child_text (_nagged[i] ? "1" : "0"); + } root->add_child("PreviewSound")->add_child_text (_preview_sound ? "1" : "0"); if (_preview_sound_output) { root->add_child("PreviewSoundOutput")->add_child_text (_preview_sound_output.get()); @@ -686,3 +700,10 @@ Config::delete_template (string name) const { boost::filesystem::remove (template_path (name)); } + +/** @return Path to the config.xml, for telling the user what it is */ +boost::filesystem::path +Config::config_path () +{ + return path("config.xml", false); +} diff --git a/src/lib/config.h b/src/lib/config.h index 40380f825..f2d224898 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -313,6 +313,15 @@ public: return _jump_to_selected; } + enum Nag { + NAG_DKDM_CONFIG, + NAG_COUNT + }; + + bool nagged (Nag nag) const { + return _nagged[nag]; + } + bool preview_sound () const { return _preview_sound; } @@ -585,6 +594,10 @@ public: maybe_set (_jump_to_selected, j); } + void set_nagged (Nag nag, bool nagged) { + maybe_set (_nagged[nag], nagged); + } + void changed (Property p = OTHER); boost::signals2::signal<void (Property)> Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -607,6 +620,7 @@ public: static void drop (); static void restore_defaults (); static bool have_existing (std::string); + static boost::filesystem::path config_path (); private: Config (); @@ -718,6 +732,7 @@ private: dcp::NameFormat _dcp_metadata_filename_format; dcp::NameFormat _dcp_asset_filename_format; bool _jump_to_selected; + bool _nagged[NAG_COUNT]; bool _preview_sound; /** name of a specific sound output stream to use for preview, or empty to use the default */ boost::optional<std::string> _preview_sound_output; diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index e9a1f652c..1ced8923b 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -40,6 +40,7 @@ #include "wx/video_waveform_dialog.h" #include "wx/save_template_dialog.h" #include "wx/templates_dialog.h" +#include "wx/nag_dialog.h" #include "lib/film.h" #include "lib/config.h" #include "lib/util.h" @@ -597,6 +598,17 @@ private: return; } + NagDialog::maybe_nag ( + this, + Config::NAG_DKDM_CONFIG, + wxString::Format ( + _("You are making a DKDM which is encrypted by a private key held in" + "\n\n<tt>%s</tt>\n\nIt is <span weight=\"bold\" size=\"larger\">VITALLY IMPORTANT</span> " + "that you <span weight=\"bold\" size=\"larger\">BACK UP THIS FILE</span> since if it is lost " + "your DKDMs (and the DCPs they protect) will become useless."), std_to_wx(Config::config_path().string()).data() + ) + ); + optional<dcp::EncryptedKDM> kdm; try { kdm = _film->make_kdm ( diff --git a/src/wx/nag_dialog.cc b/src/wx/nag_dialog.cc new file mode 100644 index 000000000..69b64cb40 --- /dev/null +++ b/src/wx/nag_dialog.cc @@ -0,0 +1,68 @@ +/* + 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 "nag_dialog.h" +#include "wx_util.h" +#include <wx/richtext/richtextctrl.h> +#include <boost/foreach.hpp> + +using boost::shared_ptr; + +NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message) + : wxDialog (parent, wxID_ANY, _("Important notice")) + , _nag (nag) +{ + wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + _text = new wxStaticText (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (400, 300)); + sizer->Add (_text, 1, wxEXPAND | wxALL, 6); + + wxCheckBox* b = new wxCheckBox (this, wxID_ANY, _("Don't show this message again")); + b->SetValue (true); + Config::instance()->set_nagged (_nag, true); + sizer->Add (b, 0, wxALL, 6); + b->Bind (wxEVT_CHECKBOX, bind (&NagDialog::shut_up, this, _1)); + + wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0); + sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder()); + buttons->SetAffirmativeButton (new wxButton (this, wxID_OK)); + buttons->Realize (); + + SetSizer (sizer); + sizer->Layout (); + sizer->SetSizeHints (this); + + _text->SetLabelMarkup (message); +} + +void +NagDialog::shut_up (wxCommandEvent& ev) +{ + Config::instance()->set_nagged (_nag, ev.IsChecked()); +} + +void +NagDialog::maybe_nag (wxWindow* parent, Config::Nag nag, wxString message) +{ + if (!Config::instance()->nagged (nag)) { + NagDialog* d = new NagDialog (parent, nag, message); + d->ShowModal (); + d->Destroy (); + } +} diff --git a/src/wx/nag_dialog.h b/src/wx/nag_dialog.h new file mode 100644 index 000000000..06f98d967 --- /dev/null +++ b/src/wx/nag_dialog.h @@ -0,0 +1,37 @@ +/* + 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 "lib/config.h" +#include <wx/wx.h> + +class wxRichTextCtrl; + +class NagDialog : public wxDialog +{ +public: + static void maybe_nag (wxWindow* parent, Config::Nag nag, wxString message); + +private: + NagDialog (wxWindow* parent, Config::Nag nag, wxString message); + void shut_up (wxCommandEvent& ev); + + wxStaticText* _text; + Config::Nag _nag; +}; diff --git a/src/wx/wscript b/src/wx/wscript index c545bf482..332a04ac5 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -68,6 +68,7 @@ sources = """ key_dialog.cc make_chain_dialog.cc move_to_dialog.cc + nag_dialog.cc name_format_editor.cc new_film_dialog.cc normal_job_view.cc |
