Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ModulePrefs Class Referencefinal

A PrefsPanel to enable/disable certain modules. 'Modules' are dynamically linked libraries that modify Audacity. They are plug-ins with names like mod-script-pipe that add NEW features. More...

#include <ModulePrefs.h>

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

Public Member Functions

 ModulePrefs (wxWindow *parent, wxWindowID winid)
 
 ~ModulePrefs ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const 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 bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
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 GetAllModuleStatuses ()
 
void Populate ()
 

Private Attributes

wxArrayString mModules
 
std::vector< int > mStatuses
 
FilePaths mPaths
 

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 to enable/disable certain modules. 'Modules' are dynamically linked libraries that modify Audacity. They are plug-ins with names like mod-script-pipe that add NEW features.

Definition at line 26 of file ModulePrefs.h.

Constructor & Destructor Documentation

◆ ModulePrefs()

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

Definition at line 33 of file ModulePrefs.cpp.

35: PrefsPanel(parent, winid, XO("Modules"))
36{
37 Populate();
38}
XO("Cut/Copy/Paste")
void Populate()
Definition: ModulePrefs.cpp:95
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:94

References Populate().

Here is the call graph for this function:

◆ ~ModulePrefs()

ModulePrefs::~ModulePrefs ( )

Definition at line 40 of file ModulePrefs.cpp.

41{
42}

Member Function Documentation

◆ Commit()

bool ModulePrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 143 of file ModulePrefs.cpp.

144{
147 int i;
148 for(i=0;i<(int)mPaths.size();i++)
150 return true;
151}
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
void PopulateOrExchange(ShuttleGui &S) override
FilePaths mPaths
Definition: ModulePrefs.h:43
std::vector< int > mStatuses
Definition: ModulePrefs.h:42
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
MODULE_MANAGER_API void SetModuleStatus(const FilePath &fname, int iStatus)

References eIsSavingToPrefs, mPaths, mStatuses, PopulateOrExchange(), S, and ModuleSettings::SetModuleStatus().

Here is the call graph for this function:

◆ GetAllModuleStatuses()

void ModulePrefs::GetAllModuleStatuses ( )
private

Definition at line 59 of file ModulePrefs.cpp.

59 {
60 // Modules could for example be:
61 // mod-script-pipe
62 // mod-nyq-bench
63 // mod-menu-munger
64 // mod-theming
65
66 // TODO: On an Audacity upgrade we should (?) actually untick modules.
67 // The old modules might be still around, and we do not want to use them.
68 mModules.clear();
69 mStatuses.clear();
70 mPaths.clear();
71
72
73 // Iterate through all Modules listed in prefs.
74 // Get their names and values.
75 auto moduleGroup = gPrefs->BeginGroup("Module");
76 for(const auto& key : gPrefs->GetChildKeys())
77 {
78 int iStatus;
79 gPrefs->Read( key, &iStatus, static_cast<decltype(iStatus)>(kModuleDisabled) );
80 wxString fname;
81 gPrefs->Read(wxT("/ModulePath/") + key, &fname, {} );
82 if( !fname.empty() && wxFileExists( fname ) ){
83 if( iStatus > kModuleNew ){
84 iStatus = kModuleNew;
85 gPrefs->Write( key, iStatus );
86 }
87 //wxLogDebug( wxT("Entry: %s Value: %i"), str, iStatus );
88 mModules.push_back( key );
89 mStatuses.push_back( iStatus );
90 mPaths.push_back( fname );
91 }
92 }
93}
wxT("CloseDown"))
@ kModuleDisabled
@ kModuleNew
static const AudacityProject::AttachedObjects::RegisteredFactory key
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
wxArrayString mModules
Definition: ModulePrefs.h:41
GroupScope BeginGroup(const wxString &prefix)
Appends a prefix to the current group or sets a new absolute path. Group that was set as current befo...
virtual wxArrayString GetChildKeys() const =0
Returns all child keys within the current group.
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0

References audacity::BasicSettings::BeginGroup(), audacity::BasicSettings::GetChildKeys(), gPrefs, key, kModuleDisabled, kModuleNew, mModules, mPaths, mStatuses, audacity::BasicSettings::Read(), audacity::BasicSettings::Write(), and wxT().

Referenced by Populate().

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

◆ GetDescription()

TranslatableString ModulePrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 49 of file ModulePrefs.cpp.

50{
51 return XO("Preferences for Module");
52}

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol ModulePrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 44 of file ModulePrefs.cpp.

45{
47}
#define MODULE_PREFS_PLUGIN_SYMBOL
Definition: ModulePrefs.h:24

References MODULE_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID ModulePrefs::HelpPageName ( )
overridevirtual

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

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 54 of file ModulePrefs.cpp.

55{
56 return "Modules_Preferences";
57}

◆ Populate()

void ModulePrefs::Populate ( )
private

Definition at line 95 of file ModulePrefs.cpp.

96{
98 //------------------------- Main section --------------------
99 // Now construct the GUI itself.
100 // Use 'eIsCreatingFromPrefs' so that the GUI is
101 // initialised with values from gPrefs.
104 // ----------------------- End of main section --------------
105}
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
void GetAllModuleStatuses()
Definition: ModulePrefs.cpp:59

References eIsCreatingFromPrefs, GetAllModuleStatuses(), PopulateOrExchange(), and S.

Referenced by ModulePrefs().

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

◆ PopulateOrExchange()

void ModulePrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 107 of file ModulePrefs.cpp.

108{
109 S.SetBorder(2);
110 S.StartScroller();
111
112 S.StartStatic( {} );
113 {
114 S.AddFixedText(XO(
115"Modules are optional components of Audacity that enable some functionality, such as importing and exporting. \nIt is generally not necessary to change these settings.") );
116 S.AddFixedText(XO(
117"Changes to these settings only take effect when restarting Audacity.\n") );
118 {
119 S.StartMultiColumn( 2 );
120 int i;
121 for(i=0;i<(int)mModules.size();i++)
122 S.TieChoice( Verbatim( mModules[i] ),
123 mStatuses[i],
124 {
125 XO("Disabled" ) ,
126 XO("Enabled" ) ,
127 XO("Always ask" ) ,
128 XO("Failed" ) ,
129 XO("No choice made" ) ,
130 }
131 );
132 S.EndMultiColumn();
133 }
134 if( mModules.size() < 1 )
135 {
136 S.AddFixedText( XO("Error: No modules were found. This may indicate a faulty installation.") );
137 }
138 }
139 S.EndStatic();
140 S.EndScroller();
141}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.

References mModules, mStatuses, S, Verbatim(), and XO().

Referenced by Commit(), and Populate().

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

Member Data Documentation

◆ mModules

wxArrayString ModulePrefs::mModules
private

Definition at line 41 of file ModulePrefs.h.

Referenced by GetAllModuleStatuses(), and PopulateOrExchange().

◆ mPaths

FilePaths ModulePrefs::mPaths
private

Definition at line 43 of file ModulePrefs.h.

Referenced by Commit(), and GetAllModuleStatuses().

◆ mStatuses

std::vector<int> ModulePrefs::mStatuses
private

Definition at line 42 of file ModulePrefs.h.

Referenced by Commit(), GetAllModuleStatuses(), and PopulateOrExchange().


The documentation for this class was generated from the following files: