Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
AudacityFileConfig Class Referencefinal

Our own specialisation of FileConfig. More...

#include <AudacityFileConfig.h>

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

Public Member Functions

 ~AudacityFileConfig () override
 
- Public Member Functions inherited from FileConfig
 FileConfig (const wxString &appName=wxEmptyString, const wxString &vendorName=wxEmptyString, const wxString &localFilename=wxEmptyString, const wxString &globalFilename=wxEmptyString, long style=wxCONFIG_USE_LOCAL_FILE|wxCONFIG_USE_GLOBAL_FILE, const wxMBConv &conv=wxConvAuto())
 
void Init ()
 
virtual ~FileConfig ()
 
virtual void SetPath (const wxString &strPath) wxOVERRIDE
 
virtual const wxString & GetPath () const wxOVERRIDE
 
virtual bool GetFirstGroup (wxString &str, long &lIndex) const wxOVERRIDE
 
virtual bool GetNextGroup (wxString &str, long &lIndex) const wxOVERRIDE
 
virtual bool GetFirstEntry (wxString &str, long &lIndex) const wxOVERRIDE
 
virtual bool GetNextEntry (wxString &str, long &lIndex) const wxOVERRIDE
 
virtual size_t GetNumberOfEntries (bool bRecursive=false) const wxOVERRIDE
 
virtual size_t GetNumberOfGroups (bool bRecursive=false) const wxOVERRIDE
 
virtual bool HasGroup (const wxString &strName) const wxOVERRIDE
 
virtual bool HasEntry (const wxString &strName) const wxOVERRIDE
 
virtual bool Flush (bool bCurrentOnly=false) wxOVERRIDE
 
virtual bool RenameEntry (const wxString &oldName, const wxString &newName) wxOVERRIDE
 
virtual bool RenameGroup (const wxString &oldName, const wxString &newName) wxOVERRIDE
 
virtual bool DeleteEntry (const wxString &key, bool bDeleteGroupIfEmpty=true) wxOVERRIDE
 
virtual bool DeleteGroup (const wxString &key) wxOVERRIDE
 
virtual bool DeleteAll () wxOVERRIDE
 
void SetVersionKeysInit (int major, int minor, int micro)
 
void GetVersionKeysInit (int &major, int &minor, int &micro) const
 

Static Public Member Functions

static std::unique_ptr< AudacityFileConfigCreate (const wxString &appName={}, const wxString &vendorName={}, const wxString &localFilename={}, const wxString &globalFilename={}, long style=wxCONFIG_USE_LOCAL_FILE|wxCONFIG_USE_GLOBAL_FILE, const wxMBConv &conv=wxConvAuto())
 Require a call to this factory, to guarantee proper two-phase initialization. More...
 

Protected Member Functions

void Warn () override
 Override to notify the user of error conditions involving writability of config files. More...
 
- Protected Member Functions inherited from FileConfig
virtual bool DoReadString (const wxString &key, wxString *pStr) const wxOVERRIDE
 
virtual bool DoReadLong (const wxString &key, long *pl) const wxOVERRIDE
 
virtual bool DoWriteString (const wxString &key, const wxString &szValue) wxOVERRIDE
 
virtual bool DoWriteLong (const wxString &key, long lValue) wxOVERRIDE
 
const FilePathGetFilePath () const
 

Private Member Functions

 AudacityFileConfig (const wxString &appName, const wxString &vendorName, const wxString &localFilename, const wxString &globalFilename, long style, const wxMBConv &conv)
 Disallow direct constructor call, because a two-phase initialization is required. More...
 

Detailed Description

Our own specialisation of FileConfig.

Definition at line 19 of file AudacityFileConfig.h.

Constructor & Destructor Documentation

◆ ~AudacityFileConfig()

AudacityFileConfig::~AudacityFileConfig ( )
overridedefault

◆ AudacityFileConfig()

AudacityFileConfig::AudacityFileConfig ( const wxString &  appName,
const wxString &  vendorName,
const wxString &  localFilename,
const wxString &  globalFilename,
long  style,
const wxMBConv &  conv 
)
private

Disallow direct constructor call, because a two-phase initialization is required.

Definition at line 23 of file AudacityFileConfig.cpp.

31 : FileConfig{ appName, vendorName, localFilename, globalFilename, style, conv }
32 {}

Member Function Documentation

◆ Create()

std::unique_ptr< AudacityFileConfig > AudacityFileConfig::Create ( const wxString &  appName = {},
const wxString &  vendorName = {},
const wxString &  localFilename = {},
const wxString &  globalFilename = {},
long  style = wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_GLOBAL_FILE,
const wxMBConv &  conv = wxConvAuto() 
)
static

Require a call to this factory, to guarantee proper two-phase initialization.

Definition at line 36 of file AudacityFileConfig.cpp.

44 {
45  // Private ctor means make_unique can't compile, so this verbosity:
46  auto result = std::unique_ptr<AudacityFileConfig>{
48  appName, vendorName, localFilename, globalFilename, style, conv } };
49  result->Init();
50  return result;
51 }

References FileConfig::Init(), and safenew.

Referenced by PluginManager::GetSettings(), PluginManager::Load(), AudacityApp::OnInit(), anonymous_namespace{AudacityApp.cpp}::PopulatePreferences(), and PluginManager::Save().

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

◆ Warn()

void AudacityFileConfig::Warn ( )
overrideprotectedvirtual

Override to notify the user of error conditions involving writability of config files.

Implements FileConfig.

Definition at line 53 of file AudacityFileConfig.cpp.

54 {
55  wxDialogWrapper dlg(nullptr, wxID_ANY, XO("Audacity Configuration Error"));
56 
57  ShuttleGui S(&dlg, eIsCreating);
58 
59  wxButton *retryButton;
60  wxButton *quitButton;
61 
62  S.SetBorder(5);
63  S.StartVerticalLay(wxEXPAND, 1);
64  {
65  S.SetBorder(15);
66  S.StartHorizontalLay(wxALIGN_RIGHT, 0);
67  {
68  S.AddFixedText(
69  XO("The following configuration file could not be accessed:\n\n"
70  "\t%s\n\n"
71  "This could be caused by many reasons, but the most likely are that "
72  "the disk is full or you do not have write permissions to the file. "
73  "More information can be obtained by clicking the help button below.\n\n"
74  "You can attempt to correct the issue and then click \"Retry\" to continue.\n\n"
75  "If you choose to \"Quit Audacity\", your project may be left in an unsaved "
76  "state which will be recovered the next time you open it.")
77  .Format(GetFilePath()),
78  false,
79  500);
80  }
81  S.EndHorizontalLay();
82 
83  S.SetBorder(5);
84  S.StartHorizontalLay(wxALIGN_RIGHT, 0);
85  {
86  // Can't use themed bitmap since the theme manager might not be
87  // initialized yet and it requires a configuration file.
88  wxButton *b = S.Id(wxID_HELP).AddBitmapButton(wxBitmap(Help_xpm));
89  b->SetToolTip( XO("Help").Translation() );
90  b->SetLabel(XO("Help").Translation()); // for screen readers
91 
92  b = S.Id(wxID_CANCEL).AddButton(XXO("&Quit Audacity"));
93  b = S.Id(wxID_OK).AddButton(XXO("&Retry"));
94  dlg.SetAffirmativeId(wxID_OK);
95 
96  b->SetDefault();
97  b->SetFocus();
98  }
99  S.EndHorizontalLay();
100  }
101  S.EndVerticalLay();
102 
103  dlg.Layout();
104  dlg.GetSizer()->Fit(&dlg);
105  dlg.SetMinSize(dlg.GetSize());
106  dlg.Center();
107 
108  auto onButton = [&](wxCommandEvent &e)
109  {
110  dlg.EndModal(e.GetId());
111  };
112 
113  dlg.Bind(wxEVT_BUTTON, onButton);
114 
115  switch (dlg.ShowModal())
116  {
117  case wxID_HELP:
118  // Can't use the HelpSystem since the theme manager may not
119  // yet be initialized and it requires a configuration file.
120  OpenInDefaultBrowser("https://" +
123  "Error:_Audacity_settings_file_unwritable");
124  break;
125 
126  case wxID_CANCEL:
127  _exit(-1);
128  break;
129  }
130 
131  dlg.Unbind(wxEVT_BUTTON, onButton);
132 }

References ShuttleGuiBase::AddBitmapButton(), ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddFixedText(), eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndVerticalLay(), FileConfig::GetFilePath(), HelpSystem::HelpHostname, HelpSystem::HelpServerHomeDir, ShuttleGui::Id(), OpenInDefaultBrowser(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartVerticalLay(), XO, and XXO.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
HelpSystem::HelpHostname
static const wxString HelpHostname
Definition: HelpSystem.h:96
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
FileConfig::GetFilePath
const FilePath & GetFilePath() const
Definition: FileConfig.h:80
Format
Abstract base class used in importing a file.
XO
#define XO(s)
Definition: Internat.h:31
HelpSystem::HelpServerHomeDir
static const wxString HelpServerHomeDir
Definition: HelpSystem.h:101
AudacityFileConfig
Our own specialisation of FileConfig.
Definition: AudacityFileConfig.h:20
XXO
#define XXO(s)
Definition: Internat.h:44
FileConfig::Init
void Init()
Definition: FileConfig.cpp:45
FileConfig
Definition: FileConfig.h:21
OpenInDefaultBrowser
void OpenInDefaultBrowser(const URLString &link)
Definition: HelpSystem.cpp:522
wxDialogWrapper
Definition: wxPanelWrapper.h:81
safenew
#define safenew
Definition: MemoryX.h:10
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631