From: Carl Hetherington Date: Sun, 7 Jan 2018 00:02:00 +0000 (+0000) Subject: Make certificate re-creation cancellable and default nags X-Git-Tag: v2.11.38~1 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=1da6ec96a4cdb4915c394bd4c272b6bfcc2033c8 Make certificate re-creation cancellable and default nags to not going away (#1158). --- diff --git a/ChangeLog b/ChangeLog index 809cf7096..565c26763 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-01-07 Carl Hetherington + + * Make certificate re-creation cancellable and default nags + to not going away (#1158). + 2018-01-06 Carl Hetherington * Check that we can decrypt a DKDM when it is loaded into diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 8d10fb9eb..fb80963f4 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -32,10 +32,10 @@ using boost::shared_ptr; using boost::function; static -void +bool do_nothing () { - + return false; } Page::Page (wxSize panel_size, int border) @@ -329,7 +329,7 @@ CertificateChainEditor::CertificateChainEditor ( int border, function)> set, function (void)> get, - function nag_remake + function nag_remake ) : wxDialog (parent, wxID_ANY, title) , _set (set) @@ -604,7 +604,10 @@ CertificateChainEditor::remake_certificates () intermediate_common_name = i->subject_common_name (); } - _nag_remake (); + if (_nag_remake()) { + /* Cancel was clicked */ + return; + } MakeChainDialog* d = new MakeChainDialog ( this, @@ -847,13 +850,14 @@ KeysPage::import_decryption_chain_and_key () d->Destroy (); } -void +bool KeysPage::nag_remake_decryption_chain () { - NagDialog::maybe_nag ( + return NagDialog::maybe_nag ( _panel, Config::NAG_REMAKE_DECRYPTION_CHAIN, - _("If you continue with this operation you will no longer be able to use any DKDMs that you have created. Also, any KDMs that have been sent to you will become useless. Proceed with caution!") + _("If you continue with this operation you will no longer be able to use any DKDMs that you have created. Also, any KDMs that have been sent to you will become useless. Proceed with caution!"), + true ); } diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index 9a73d4e61..b76f8bc35 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -120,7 +120,7 @@ public: int border, boost::function)> set, boost::function (void)> get, - boost::function nag_remake + boost::function nag_remake ); void add_button (wxWindow* button); @@ -149,7 +149,7 @@ private: wxBoxSizer* _button_sizer; boost::function)> _set; boost::function (void)> _get; - boost::function _nag_remake; + boost::function _nag_remake; }; class KeysPage : public StandardPage @@ -176,7 +176,7 @@ private: void export_decryption_certificate (); void export_decryption_chain (); void config_changed () {} - void nag_remake_decryption_chain (); + bool nag_remake_decryption_chain (); void decryption_advanced (); void signing_advanced (); void export_decryption_chain_and_key (); diff --git a/src/wx/nag_dialog.cc b/src/wx/nag_dialog.cc index 69b64cb40..b7efb43db 100644 --- a/src/wx/nag_dialog.cc +++ b/src/wx/nag_dialog.cc @@ -25,7 +25,7 @@ using boost::shared_ptr; -NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message) +NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel) : wxDialog (parent, wxID_ANY, _("Important notice")) , _nag (nag) { @@ -34,15 +34,17 @@ NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message) 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 (); + int flags = wxOK; + if (can_cancel) { + flags |= wxCANCEL; + } + wxSizer* buttons = CreateSeparatedButtonSizer (flags); + if (buttons) { + sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder()); + } SetSizer (sizer); sizer->Layout (); @@ -57,12 +59,17 @@ NagDialog::shut_up (wxCommandEvent& ev) Config::instance()->set_nagged (_nag, ev.IsChecked()); } -void -NagDialog::maybe_nag (wxWindow* parent, Config::Nag nag, wxString message) +/** @return true if the user clicked Cancel */ +bool +NagDialog::maybe_nag (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel) { - if (!Config::instance()->nagged (nag)) { - NagDialog* d = new NagDialog (parent, nag, message); - d->ShowModal (); - d->Destroy (); + if (Config::instance()->nagged(nag)) { + return false; } + + NagDialog* d = new NagDialog (parent, nag, message, can_cancel); + int const r = d->ShowModal(); + d->Destroy (); + + return r == wxID_CANCEL; } diff --git a/src/wx/nag_dialog.h b/src/wx/nag_dialog.h index 06f98d967..83d681fef 100644 --- a/src/wx/nag_dialog.h +++ b/src/wx/nag_dialog.h @@ -26,10 +26,10 @@ class wxRichTextCtrl; class NagDialog : public wxDialog { public: - static void maybe_nag (wxWindow* parent, Config::Nag nag, wxString message); + static bool maybe_nag (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel = false); private: - NagDialog (wxWindow* parent, Config::Nag nag, wxString message); + NagDialog (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel); void shut_up (wxCommandEvent& ev); wxStaticText* _text;