Audacity  3.0.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LibraryPrefs Class Referencefinal

A PrefsPanel used to select manage external libraries like the MP3 and FFmpeg encoding libraries. More...

#include <LibraryPrefs.h>

Inheritance diagram for LibraryPrefs:
[legend]
Collaboration diagram for LibraryPrefs:
[legend]

Public Member Functions

 LibraryPrefs (wxWindow *parent, wxWindowID winid)
 
 ~LibraryPrefs ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool Commit () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void Populate ()
 Creates the dialog and its contents. More...
 
void SetMP3VersionText (bool prompt=false)
 
void SetFFmpegVersionText ()
 
void OnMP3FindButton (wxCommandEvent &e)
 
void OnMP3DownButton (wxCommandEvent &e)
 Opens help on downloading a suitable MP3 library is. More...
 
void OnFFmpegFindButton (wxCommandEvent &e)
 
void OnFFmpegDownButton (wxCommandEvent &e)
 

Private Attributes

ReadOnlyTextmMP3Version
 
ReadOnlyTextmFFmpegVersion
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Detailed Description

A PrefsPanel used to select manage external libraries like the MP3 and FFmpeg encoding libraries.

Definition at line 27 of file LibraryPrefs.h.

Constructor & Destructor Documentation

◆ LibraryPrefs()

LibraryPrefs::LibraryPrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 48 of file LibraryPrefs.cpp.

50 : PrefsPanel(parent, winid, XO("Libraries"))
51 {
52  Populate();
53 }

◆ ~LibraryPrefs()

LibraryPrefs::~LibraryPrefs ( )

Definition at line 55 of file LibraryPrefs.cpp.

56 {
57 }

Member Function Documentation

◆ Commit()

bool LibraryPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 223 of file LibraryPrefs.cpp.

224 {
225  ShuttleGui S(this, eIsSavingToPrefs);
227 
228  return true;
229 }

References eIsSavingToPrefs, and PopulateOrExchange().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString LibraryPrefs::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 64 of file LibraryPrefs.cpp.

65 {
66  return XO("Preferences for Library");
67 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol LibraryPrefs::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 59 of file LibraryPrefs.cpp.

60 {
62 }

References LIBRARY_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID LibraryPrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 69 of file LibraryPrefs.cpp.

70 {
71  return "Libraries_Preferences";
72 }

◆ OnFFmpegDownButton()

void LibraryPrefs::OnFFmpegDownButton ( wxCommandEvent &  e)
private

Definition at line 218 of file LibraryPrefs.cpp.

219 {
220  HelpSystem::ShowHelp(this, L"FAQ:Installing_the_FFmpeg_Import_Export_Library", true);
221 }

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnFFmpegFindButton()

void LibraryPrefs::OnFFmpegFindButton ( wxCommandEvent &  e)
private

Definition at line 179 of file LibraryPrefs.cpp.

180 {
181 #ifdef USE_FFMPEG
183  bool showerrs =
184 #if defined(_DEBUG)
185  true;
186 #else
187  false;
188 #endif
189 
190  FFmpegLibsPtr->FreeLibs();
191  // Load the libs ('true' means that all errors will be shown)
192  bool locate = !LoadFFmpeg(showerrs);
193 
194  // Libs are fine, don't show "locate" dialog unless user really wants it
195  if (!locate) {
196  int response = AudacityMessageBox(
197  XO(
198 "Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"),
199  XO("Success"),
200  wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION);
201  if (response == wxYES) {
202  locate = true;
203  }
204  }
205 
206  if (locate) {
207  // Show "Locate FFmpeg" dialog
208  FFmpegLibsPtr->FindLibs(this);
209  FFmpegLibsPtr->FreeLibs();
210  LoadFFmpeg(showerrs);
211  }
213 
214  DropFFmpegLibs();
215 #endif
216 }

References AudacityMessageBox(), DropFFmpegLibs(), FFmpegLibsPtr, LoadFFmpeg(), PickFFmpegLibs(), SetFFmpegVersionText(), and XO.

Here is the call graph for this function:

◆ OnMP3DownButton()

void LibraryPrefs::OnMP3DownButton ( wxCommandEvent &  e)
private

Opens help on downloading a suitable MP3 library is.

Definition at line 168 of file LibraryPrefs.cpp.

169 {
170  // Modal help dialogue required here
171  HelpSystem::ShowHelp(this, L"FAQ:Installing_the_LAME_MP3_Encoder", true);
172 }

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnMP3FindButton()

void LibraryPrefs::OnMP3FindButton ( wxCommandEvent &  e)
private

Opens a file-finder dialog so that the user can tell us where the MP3 library is.

Definition at line 162 of file LibraryPrefs.cpp.

163 {
164  SetMP3VersionText(true);
165 }

References SetMP3VersionText().

Here is the call graph for this function:

◆ Populate()

void LibraryPrefs::Populate ( )
private

Creates the dialog and its contents.

Definition at line 75 of file LibraryPrefs.cpp.

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 }

References eIsCreatingFromPrefs, PopulateOrExchange(), SetFFmpegVersionText(), and SetMP3VersionText().

Here is the call graph for this function:

◆ PopulateOrExchange()

void LibraryPrefs::PopulateOrExchange ( ShuttleGui S)
override

This PopulateOrExchange function is a good example of mixing the fully automatic style of reading/writing from GUI to prefs with the partial form.

You'll notice that some of the Tie functions have Prefs identifiers in them and others don't.

Definition at line 95 of file LibraryPrefs.cpp.

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 
123  mFFmpegVersion = S
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 }

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddReadOnlyText(), ShuttleGuiBase::AddVariableText(), ShuttleGui::Disable(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndTwoColumn(), ShuttleGui::Id(), ID_FFMPEG_DOWN_BUTTON, ID_FFMPEG_FIND_BUTTON, mFFmpegVersion, mMP3Version, ShuttleGui::Position(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartTwoColumn(), XO, and XXO.

Referenced by Commit(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFFmpegVersionText()

void LibraryPrefs::SetFFmpegVersionText ( )
private

Definition at line 174 of file LibraryPrefs.cpp.

175 {
177 }

References GetFFmpegVersion(), mFFmpegVersion, and ReadOnlyText::SetValue().

Referenced by OnFFmpegFindButton(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMP3VersionText()

void LibraryPrefs::SetMP3VersionText ( bool  prompt = false)
private

Sets the a text area on the dialog to have the name of the MP3 Library version.

Definition at line 155 of file LibraryPrefs.cpp.

156 {
157  mMP3Version->SetValue(GetMP3Version(this, prompt));
158 }

References GetMP3Version(), mMP3Version, and ReadOnlyText::SetValue().

Referenced by OnMP3FindButton(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mFFmpegVersion

ReadOnlyText* LibraryPrefs::mFFmpegVersion
private

Definition at line 50 of file LibraryPrefs.h.

Referenced by PopulateOrExchange(), and SetFFmpegVersionText().

◆ mMP3Version

ReadOnlyText* LibraryPrefs::mMP3Version
private

Definition at line 49 of file LibraryPrefs.h.

Referenced by PopulateOrExchange(), and SetMP3VersionText().


The documentation for this class was generated from the following files:
LibraryPrefs::SetFFmpegVersionText
void SetFFmpegVersionText()
Definition: LibraryPrefs.cpp:174
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
ReadOnlyText::SetValue
void SetValue(const wxString &value)
Definition: ReadOnlyText.h:125
ID_FFMPEG_DOWN_BUTTON
#define ID_FFMPEG_DOWN_BUTTON
Definition: LibraryPrefs.cpp:39
GetMP3Version
TranslatableString GetMP3Version(wxWindow *parent, bool prompt)
Definition: ExportMP3.cpp:2234
XO
#define XO(s)
Definition: Internat.h:31
PickFFmpegLibs
FFmpegLibs * PickFFmpegLibs()
Definition: FFmpeg.cpp:52
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
FFmpegLibs
Class used to dynamically load FFmpeg libraries.
Definition: FFmpeg.h:207
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
LoadFFmpeg
bool LoadFFmpeg(bool showerror)
Definition: FFmpeg.cpp:72
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
ShuttleGui::Disable
ShuttleGui & Disable(bool disabled=true)
Definition: ShuttleGui.h:650
LibraryPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: LibraryPrefs.cpp:95
GetFFmpegVersion
TranslatableString GetFFmpegVersion()
Definition: FFmpeg.cpp:114
LIBRARY_PREFS_PLUGIN_SYMBOL
#define LIBRARY_PREFS_PLUGIN_SYMBOL
Definition: LibraryPrefs.h:25
ID_FFMPEG_FIND_BUTTON
#define ID_FFMPEG_FIND_BUTTON
Definition: LibraryPrefs.cpp:38
ShuttleGuiBase::StartTwoColumn
void StartTwoColumn()
Definition: ShuttleGui.h:366
ShuttleGuiBase::AddReadOnlyText
ReadOnlyText * AddReadOnlyText(const TranslatableString &Caption, const wxString &Value)
Definition: ShuttleGui.cpp:496
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:360
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:48
ShuttleGui::Position
ShuttleGui & Position(int flags)
Definition: ShuttleGui.h:712
LibraryPrefs::mFFmpegVersion
ReadOnlyText * mFFmpegVersion
Definition: LibraryPrefs.h:50
DropFFmpegLibs
void DropFFmpegLibs()
Definition: FFmpeg.cpp:62
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
ShuttleGuiBase::EndTwoColumn
void EndTwoColumn()
Definition: ShuttleGui.h:367
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
ShuttleGuiBase::AddVariableText
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:463
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
LibraryPrefs::mMP3Version
ReadOnlyText * mMP3Version
Definition: LibraryPrefs.h:49
FFmpegLibsPtr
std::unique_ptr< FFmpegLibs > FFmpegLibsPtr
Definition: FFmpeg.cpp:46
LibraryPrefs::Populate
void Populate()
Creates the dialog and its contents.
Definition: LibraryPrefs.cpp:75
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90
LibraryPrefs::SetMP3VersionText
void SetMP3VersionText(bool prompt=false)
Definition: LibraryPrefs.cpp:155