Audacity  2.2.2
LibraryPrefs.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  LibraryPrefs.cpp
6 
7  Joshua Haberman
8  Dominic Mazzoni
9  James Crook
10 
11 *******************************************************************//*******************************************************************/
18 
19 #include "../Audacity.h"
20 
21 #include <wx/defs.h>
22 #include <wx/button.h>
23 
24 #include "../FFmpeg.h"
25 #include "../ShuttleGui.h"
26 #include "../export/ExportMP3.h"
27 #include "../widgets/LinkingHtmlWindow.h"
28 #include "../widgets/HelpSystem.h"
29 #include "../widgets/ErrorDialog.h"
30 
31 #include "LibraryPrefs.h"
32 
33 #include "../Experimental.h"
34 
36 
37 #define ID_MP3_FIND_BUTTON 7001
38 #define ID_MP3_DOWN_BUTTON 7002
39 #define ID_FFMPEG_FIND_BUTTON 7003
40 #define ID_FFMPEG_DOWN_BUTTON 7004
41 
42 BEGIN_EVENT_TABLE(LibraryPrefs, PrefsPanel)
43  EVT_BUTTON(ID_MP3_FIND_BUTTON, LibraryPrefs::OnMP3FindButton)
44  EVT_BUTTON(ID_MP3_DOWN_BUTTON, LibraryPrefs::OnMP3DownButton)
45  EVT_BUTTON(ID_FFMPEG_FIND_BUTTON, LibraryPrefs::OnFFmpegFindButton)
46  EVT_BUTTON(ID_FFMPEG_DOWN_BUTTON, LibraryPrefs::OnFFmpegDownButton)
48 
49 LibraryPrefs::LibraryPrefs(wxWindow * parent, wxWindowID winid)
50 /* i18-hint: refers to optional plug-in software libraries */
51 : PrefsPanel(parent, winid, _("Libraries"))
52 {
53  Populate();
54 }
55 
57 {
58 }
59 
62 {
63  //------------------------- Main section --------------------
64  // Now construct the GUI itself.
65  // Use 'eIsCreatingFromPrefs' so that the GUI is
66  // initialised with values from gPrefs.
69  // ----------------------- End of main section --------------
70 
71  // Set the MP3 Version string.
74 }
75 
82 {
83  S.SetBorder(2);
84  S.StartScroller();
85 
86  S.StartStatic(_("MP3 Export Library"));
87  {
88  S.StartTwoColumn();
89  {
90  S.AddVariableText(_("MP3 Library Version:"),
91  true,
92  wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
93  mMP3Version = S.AddVariableText(wxT("9.99"),
94  true,
95  wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
96  S.AddVariableText(_("MP3 Library:"),
97  true,
98  wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
99  wxButton *locate_button = S.Id(ID_MP3_FIND_BUTTON).AddButton(_("&Locate..."),
100  wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
101  S.AddVariableText(_("LAME MP3 Library:"),
102  true,
103  wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
104  wxButton *download_button = S.Id(ID_MP3_DOWN_BUTTON).AddButton(_("&Download"),
105  wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
106 #ifdef DISABLE_DYNAMIC_LOADING_LAME
107  locate_button->Enable(FALSE);
108  download_button->Enable(FALSE);
109 #else
110  (void)locate_button;
111  (void)download_button;
112 #endif // DISABLE_DYNAMIC_LOADING_LAME
113  }
114  S.EndTwoColumn();
115  }
116  S.EndStatic();
117 
118  S.StartStatic(_("FFmpeg Import/Export Library"));
119  {
120  S.StartTwoColumn();
121  {
122  S.AddVariableText(_("FFmpeg Library Version:"),
123  true,
124  wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
125 #if defined(USE_FFMPEG)
126  mFFmpegVersion = S.AddVariableText(_("No compatible FFmpeg library was found"),
127  true,
128  wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
129 #else
130  mFFmpegVersion = S.AddVariableText(wxT("FFmpeg support is not compiled in"),
131  true,
132  wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
133 #endif
134  S.AddVariableText(_("FFmpeg Library:"),
135  true,
136  wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
138  wxButton *bfnd = S.AddButton(_("Loca&te..."),
139  wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
140  S.AddVariableText(_("FFmpeg Library:"),
141  true,
142  wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
144  wxButton *bdwn = S.AddButton(_("Dow&nload"),
145  wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
146 #if !defined(USE_FFMPEG) || defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
147  bdwn->Enable(FALSE);
148  bfnd->Enable(FALSE);
149 #else
150  // fix compilation warnings about unused variables
151  wxUnusedVar(bfnd);
152  wxUnusedVar(bdwn);
153 #endif
154  }
155  S.EndTwoColumn();
156 #ifdef EXPERIMENTAL_OD_FFMPEG
157  wxCheckBox* checkbox = S.TieCheckBox(_("Allow &background on-demand loading"),
158  wxT("/Library/FFmpegOnDemand"),
159  false);
160 #if !defined(USE_FFMPEG)
161  if( checkbox ) checkbox->Enable(FALSE);
162 #endif
163 #endif
164  }
165  S.EndStatic();
166  S.EndScroller();
167 
168 }
169 
173 {
174  mMP3Version->SetLabel(GetMP3Version(this, prompt));
175  mMP3Version->SetName(mMP3Version->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
176 }
177 
180 void LibraryPrefs::OnMP3FindButton(wxCommandEvent & WXUNUSED(event))
181 {
182  SetMP3VersionText(true);
183 }
184 
186 void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
187 {
188  // Modal help dialogue required here
189  HelpSystem::ShowHelp(this, wxT("FAQ:Installing_the_LAME_MP3_Encoder"), true);
190 }
191 
193 {
194  mFFmpegVersion->SetLabel(GetFFmpegVersion(this));
195  mFFmpegVersion->SetName(mFFmpegVersion->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
196 }
197 
198 void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
199 {
200 #ifdef USE_FFMPEG
201  FFmpegLibs* FFmpegLibsPtr = PickFFmpegLibs();
202  bool showerrs =
203 #if defined(__WXDEBUG__)
204  true;
205 #else
206  false;
207 #endif
208 
209  FFmpegLibsPtr->FreeLibs();
210  // Load the libs ('true' means that all errors will be shown)
211  bool locate = !LoadFFmpeg(showerrs);
212 
213  // Libs are fine, don't show "locate" dialog unless user really wants it
214  if (!locate) {
215  int response = AudacityMessageBox(_("Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"),
216  wxT("Success"),
217  wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION);
218  if (response == wxYES) {
219  locate = true;
220  }
221  }
222 
223  if (locate) {
224  // Show "Locate FFmpeg" dialog
225  FFmpegLibsPtr->FindLibs(this);
226  FFmpegLibsPtr->FreeLibs();
227  LoadFFmpeg(showerrs);
228  }
230 
231  DropFFmpegLibs();
232 #endif
233 }
234 
235 void LibraryPrefs::OnFFmpegDownButton(wxCommandEvent & WXUNUSED(event))
236 {
237  HelpSystem::ShowHelp(this, wxT("FAQ:Installing_the_FFmpeg_Import_Export_Library"), true);
238 }
239 
241 {
242  ShuttleGui S(this, eIsSavingToPrefs);
244 
245  return true;
246 }
247 
249 {
250  return "Libraries_Preferences";
251 }
252 
253 PrefsPanel *LibraryPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
254 {
255  wxASSERT(parent); // to justify safenew
256  return safenew LibraryPrefs(parent, winid);
257 }
void PopulateOrExchange(ShuttleGui &S) override
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
wxStaticText * mMP3Version
Definition: LibraryPrefs.h:44
void OnFFmpegDownButton(wxCommandEvent &e)
wxString HelpPageName() override
#define ID_MP3_DOWN_BUTTON
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
void EndScroller()
Definition: ShuttleGui.cpp:828
#define safenew
Definition: Audacity.h:230
bool Commit() override
#define ID_FFMPEG_DOWN_BUTTON
void OnMP3FindButton(wxCommandEvent &e)
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:795
void StartTwoColumn()
Definition: ShuttleGui.h:136
ShuttleGui & Id(int id)
void SetMP3VersionText(bool prompt=false)
static void ShowHelp(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:194
#define ID_FFMPEG_FIND_BUTTON
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
PrefsPanel * operator()(wxWindow *parent, wxWindowID winid) override
void OnFFmpegFindButton(wxCommandEvent &e)
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:45
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
#define ID_MP3_FIND_BUTTON
void SetFFmpegVersionText()
wxString GetMP3Version(wxWindow *parent, bool prompt)
Definition: ExportMP3.cpp:2170
wxStaticText * AddVariableText(const wxString &Str, bool bCenter=false, int PositionFlags=0)
Definition: ShuttleGui.cpp:414
wxString GetFFmpegVersion(wxWindow *parent)
Definition: FFmpeg.cpp:35
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
void Populate()
Creates the dialog and its contents.
Class used to dynamically load FFmpeg libraries.
END_EVENT_TABLE()
void SetBorder(int Border)
Definition: ShuttleGui.h:286
void EndTwoColumn()
Definition: ShuttleGui.h:137
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:341
A PrefsPanel used to select manage external libraries like the MP3 and FFmpeg encoding libraries...
Definition: LibraryPrefs.h:25
void OnMP3DownButton(wxCommandEvent &e)
Opens help on downloading a suitable MP3 library is.
wxStaticText * mFFmpegVersion
Definition: LibraryPrefs.h:45