From: Carl Hetherington Date: Thu, 7 Jan 2016 16:02:33 +0000 (+0000) Subject: Factor out some common stuff and give a better tooltip on the 'refer' buttons when... X-Git-Tag: v2.6.14~5 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=f61777543c611ed3ba818bf1c564322cb71b3009 Factor out some common stuff and give a better tooltip on the 'refer' buttons when no DCP is selected. --- diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index ff62acc67..34d6ac885 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -245,16 +245,7 @@ AudioPanel::setup_sensitivity () list why_not; bool const can_reference = dcp && dcp->can_reference_audio (why_not); - _reference->Enable (can_reference); - - wxString s; - if (!can_reference) { - s = _("Cannot reference this DCP. "); - BOOST_FOREACH (string i, why_not) { - s += std_to_wx(i) + wxT(" "); - } - } - _reference->SetToolTip (s); + setup_refer_button (_reference, dcp, can_reference, why_not); if (_reference->GetValue ()) { _gain->wrapped()->Enable (false); diff --git a/src/wx/content_sub_panel.cc b/src/wx/content_sub_panel.cc index 7ea17c15c..780f31efb 100644 --- a/src/wx/content_sub_panel.cc +++ b/src/wx/content_sub_panel.cc @@ -17,10 +17,14 @@ */ -#include #include "content_sub_panel.h" #include "content_panel.h" +#include "wx_util.h" +#include +#include +using std::list; +using std::string; using boost::shared_ptr; ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name) @@ -32,3 +36,19 @@ ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name) SetSizer (_sizer); } +void +ContentSubPanel::setup_refer_button (wxCheckBox* button, shared_ptr dcp, bool can_reference, list why_not) const +{ + button->Enable (can_reference); + + wxString s; + if (!dcp) { + s = _("No DCP selected."); + } else if (!can_reference) { + s = _("Cannot reference this DCP. "); + BOOST_FOREACH (string i, why_not) { + s += std_to_wx(i) + wxT(" "); + } + } + button->SetToolTip (s); +} diff --git a/src/wx/content_sub_panel.h b/src/wx/content_sub_panel.h index 5a1b739ef..0ad628f0c 100644 --- a/src/wx/content_sub_panel.h +++ b/src/wx/content_sub_panel.h @@ -26,6 +26,7 @@ class ContentPanel; class Content; +class DCPContent; class ContentSubPanel : public wxPanel { @@ -39,6 +40,9 @@ public: virtual void content_selection_changed () = 0; protected: + + void setup_refer_button (wxCheckBox* button, boost::shared_ptr dcp, bool can_reference, std::list why_not) const; + ContentPanel* _parent; wxSizer* _sizer; }; diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index 74a110349..591166a9e 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -270,16 +270,7 @@ SubtitlePanel::setup_sensitivity () list why_not; bool const can_reference = dcp && dcp->can_reference_subtitle (why_not); - _reference->Enable (can_reference); - - wxString s; - if (!can_reference) { - s = _("Cannot reference this DCP. "); - BOOST_FOREACH (string i, why_not) { - s += std_to_wx(i) + wxT(" "); - } - } - _reference->SetToolTip (s); + setup_refer_button (_reference, dcp, can_reference, why_not); bool const reference = _reference->GetValue (); diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 5c6658888..fa791550c 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -440,17 +440,8 @@ VideoPanel::setup_sensitivity () } list why_not; - bool const can_reference = dcp && dcp->can_reference_video(why_not); - _reference->Enable (can_reference); - - wxString s; - if (!can_reference) { - s = _("Cannot reference this DCP. "); - BOOST_FOREACH (string i, why_not) { - s += std_to_wx(i) + wxT(" "); - } - } - _reference->SetToolTip (s); + bool const can_reference = dcp && dcp->can_reference_video (why_not); + setup_refer_button (_reference, dcp, can_reference, why_not); if (_reference->GetValue ()) { _frame_type->wrapped()->Enable (false);