Audacity 3.2.0
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
20#include "LibraryPrefs.h"
21
22#include <wx/defs.h>
23#include <wx/button.h>
24#include <wx/stattext.h>
25
26#include "../FFmpeg.h"
27#include "../export/ExportMP3.h"
28#include "../widgets/HelpSystem.h"
29#include "../widgets/AudacityMessageBox.h"
30#include "../widgets/ReadOnlyText.h"
31#include "../widgets/wxTextCtrlWrapper.h"
32
33
35
36#define ID_MP3_FIND_BUTTON 7001
37#define ID_MP3_DOWN_BUTTON 7002
38#define ID_FFMPEG_FIND_BUTTON 7003
39#define ID_FFMPEG_DOWN_BUTTON 7004
40
41BEGIN_EVENT_TABLE(LibraryPrefs, PrefsPanel)
47
48LibraryPrefs::LibraryPrefs(wxWindow * parent, wxWindowID winid)
49/* i18-hint: refers to optional plug-in software libraries */
50: PrefsPanel(parent, winid, XO("Libraries"))
51{
52 Populate();
53}
54
56{
57}
58
60{
62}
63
65{
66 return XO("Preferences for Library");
67}
68
70{
71 return "Libraries_Preferences";
72}
73
76{
77 //------------------------- Main section --------------------
78 // Now construct the GUI itself.
79 // Use 'eIsCreatingFromPrefs' so that the GUI is
80 // initialised with values from gPrefs.
83 // ----------------------- End of main section --------------
84
85 // Set the MP3 Version string.
88}
89
96{
97 S.SetBorder(2);
98 S.StartScroller();
99
100 S.StartStatic(XO("LAME MP3 Export Library"));
101 {
102 S.StartTwoColumn();
103 {
104 mMP3Version = S
105 .Position(wxALIGN_CENTRE_VERTICAL)
106 .AddReadOnlyText(XO("MP3 Library Version:"), "");
107 }
108 S.EndTwoColumn();
109 }
110 S.EndStatic();
111
112 S.StartStatic(XO("FFmpeg Import/Export Library"));
113 {
114 S.StartTwoColumn();
115 {
116 auto version =
117#if defined(USE_FFMPEG)
118 XO("No compatible FFmpeg library was found");
119#else
120 XO("FFmpeg support is not compiled in");
121#endif
122
124 .Position(wxALIGN_CENTRE_VERTICAL)
125 .AddReadOnlyText(XO("FFmpeg Library Version:"), version.Translation());
126
127 S.AddVariableText(XO("FFmpeg Library:"),
128 true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
130 S
131#if !defined(USE_FFMPEG) || defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
132 .Disable()
133#endif
134 .AddButton(XXO("Loca&te..."),
135 wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
136 S.AddVariableText(XO("FFmpeg Library:"),
137 true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
139 S
140#if !defined(USE_FFMPEG) || defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
141 .Disable()
142#endif
143 .AddButton(XXO("Dow&nload"),
144 wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
145 }
146 S.EndTwoColumn();
147 }
148 S.EndStatic();
149 S.EndScroller();
150
151}
152
156{
157 mMP3Version->SetValue(GetMP3Version(this, prompt));
158}
159
162void LibraryPrefs::OnMP3FindButton(wxCommandEvent & WXUNUSED(event))
163{
164 SetMP3VersionText(true);
165}
166
168void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
169{
170 // Modal help dialogue required here
171 HelpSystem::ShowHelp(this, L"FAQ:Installing_the_LAME_MP3_Encoder", true);
172}
173
175{
177}
178
179void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
180{
181#ifdef USE_FFMPEG
182 bool showerrs =
183#if defined(_DEBUG)
184 true;
185#else
186 false;
187#endif
188 // Load the libs ('true' means that all errors will be shown)
189 bool locate = !LoadFFmpeg(showerrs);
190
191 // Libs are fine, don't show "locate" dialog unless user really wants it
192 if (!locate) {
193 int response = AudacityMessageBox(
194 XO(
195"Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"),
196 XO("Success"),
197 wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION);
198 if (response == wxYES) {
199 locate = true;
200 }
201 }
202
203 if (locate) {
204 // Show "Locate FFmpeg" dialog
205 FindFFmpegLibs(this);
206 LoadFFmpeg(showerrs);
207 }
208
210#endif
211}
212
213void LibraryPrefs::OnFFmpegDownButton(wxCommandEvent & WXUNUSED(event))
214{
215 HelpSystem::ShowHelp(this, L"FAQ:Installing_the_FFmpeg_Import_Export_Library", true);
216}
217
219{
222
223 return true;
224}
225
226#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
227namespace{
229 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
230 {
231 wxASSERT(parent); // to justify safenew
232 return safenew LibraryPrefs(parent, winid);
233 },
234 false,
235 // Register with an explicit ordering hint because this one is
236 // only conditionally compiled
237 { "", { Registry::OrderingHint::Before, "Directories" } }
238};
239}
240#endif
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
TranslatableString GetMP3Version(wxWindow *parent, bool prompt)
Definition: ExportMP3.cpp:2255
TranslatableString GetFFmpegVersion()
Definition: FFmpeg.cpp:82
bool FindFFmpegLibs(wxWindow *parent)
Definition: FFmpeg.cpp:310
bool LoadFFmpeg(bool showerror)
Definition: FFmpeg.cpp:46
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
#define ID_MP3_FIND_BUTTON
#define ID_FFMPEG_FIND_BUTTON
#define ID_FFMPEG_DOWN_BUTTON
#define ID_MP3_DOWN_BUTTON
#define LIBRARY_PREFS_PLUGIN_SYMBOL
Definition: LibraryPrefs.h:25
#define safenew
Definition: MemoryX.h:10
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:48
@ eIsSavingToPrefs
Definition: ShuttleGui.h:49
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
A PrefsPanel used to select manage external libraries like the MP3 and FFmpeg encoding libraries.
Definition: LibraryPrefs.h:28
bool Commit() override
void OnFFmpegFindButton(wxCommandEvent &e)
ComponentInterfaceSymbol GetSymbol() const override
ReadOnlyText * mMP3Version
Definition: LibraryPrefs.h:49
void SetFFmpegVersionText()
TranslatableString GetDescription() const override
void SetMP3VersionText(bool prompt=false)
void Populate()
Creates the dialog and its contents.
void PopulateOrExchange(ShuttleGui &S) override
ReadOnlyText * mFFmpegVersion
Definition: LibraryPrefs.h:50
void OnMP3DownButton(wxCommandEvent &e)
Opens help on downloading a suitable MP3 library is.
void OnMP3FindButton(wxCommandEvent &e)
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
void OnFFmpegDownButton(wxCommandEvent &e)
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
void SetValue(const wxString &value)
Definition: ReadOnlyText.h:125
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
Holds a msgid for the translation catalog; may also bind format arguments.
PrefsPanel::Registration sAttachment