mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Class AudacityPrefs renamed, moved, reused in PluginManager...
... And construction of the main instance is hoisted into AudacityApp
This commit is contained in:
@@ -71,6 +71,7 @@ It handles initialization and termination by subclassing wxApp.
|
||||
#include "AudacityLogger.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "AColor.h"
|
||||
#include "AudacityFileConfig.h"
|
||||
#include "AudioIO.h"
|
||||
#include "Benchmark.h"
|
||||
#include "Clipboard.h"
|
||||
@@ -188,7 +189,7 @@ void PopulatePreferences()
|
||||
{
|
||||
const wxString fullPath{fn.GetFullPath()};
|
||||
|
||||
FileConfig ini(wxEmptyString,
|
||||
AudacityFileConfig ini(wxEmptyString,
|
||||
wxEmptyString,
|
||||
fullPath,
|
||||
wxEmptyString,
|
||||
@@ -1245,9 +1246,15 @@ bool AudacityApp::OnInit()
|
||||
#endif
|
||||
|
||||
// Initialize preferences and language
|
||||
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
||||
InitPreferences( configFileName );
|
||||
PopulatePreferences();
|
||||
{
|
||||
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
||||
auto appName = wxTheApp->GetAppName();
|
||||
InitPreferences( std::make_unique<AudacityFileConfig>(
|
||||
appName, wxEmptyString,
|
||||
configFileName.GetFullPath(),
|
||||
wxEmptyString, wxCONFIG_USE_LOCAL_FILE) );
|
||||
PopulatePreferences();
|
||||
}
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
|
||||
this->AssociateFileTypes();
|
||||
|
||||
13
src/AudacityFileConfig.cpp
Normal file
13
src/AudacityFileConfig.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
AudacityFileConfig.cpp
|
||||
|
||||
Paul Licameli split from Prefs.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "AudacityFileConfig.h"
|
||||
|
||||
AudacityFileConfig::~AudacityFileConfig() = default;
|
||||
25
src/AudacityFileConfig.h
Normal file
25
src/AudacityFileConfig.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
@file AudacityFileConfig.h
|
||||
@brief Extend FileConfig with application-specific behavior
|
||||
|
||||
Paul Licameli split from Prefs.h
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_FILE_CONFIG__
|
||||
#define __AUDACITY_FILE_CONFIG__
|
||||
|
||||
#include "widgets/FileConfig.h" // to inherit
|
||||
|
||||
/// \brief Our own specialisation of FileConfig. It is essentially a renaming.
|
||||
class AUDACITY_DLL_API AudacityFileConfig final : public FileConfig
|
||||
{
|
||||
public:
|
||||
using FileConfig::FileConfig;
|
||||
|
||||
~AudacityFileConfig() override;
|
||||
};
|
||||
#endif
|
||||
@@ -78,6 +78,8 @@ list( APPEND SOURCES
|
||||
$<$<BOOL:${wxIS_MAC}>:AudacityApp.mm>
|
||||
AudacityException.cpp
|
||||
AudacityException.h
|
||||
AudacityFileConfig.cpp
|
||||
AudacityFileConfig.h
|
||||
AudacityHeaders.cpp
|
||||
AudacityHeaders.h
|
||||
AudacityLogger.cpp
|
||||
|
||||
@@ -42,6 +42,7 @@ for shared and private configs - which need to move out.
|
||||
#include "audacity/EffectInterface.h"
|
||||
#include "audacity/ModuleInterface.h"
|
||||
|
||||
#include "AudacityFileConfig.h"
|
||||
#include "FileNames.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "PlatformCompatibility.h"
|
||||
@@ -1929,7 +1930,8 @@ bool PluginManager::DropFile(const wxString &fileName)
|
||||
void PluginManager::Load()
|
||||
{
|
||||
// Create/Open the registry
|
||||
FileConfig registry(wxEmptyString, wxEmptyString, FileNames::PluginRegistry());
|
||||
AudacityFileConfig registry(
|
||||
{}, {}, FileNames::PluginRegistry());
|
||||
|
||||
// If this group doesn't exist then we have something that's not a registry.
|
||||
// We should probably warn the user, but it's pretty unlikely that this will happen.
|
||||
@@ -2270,7 +2272,8 @@ void PluginManager::LoadGroup(FileConfig *pRegistry, PluginType type)
|
||||
void PluginManager::Save()
|
||||
{
|
||||
// Create/Open the registry
|
||||
FileConfig registry(wxEmptyString, wxEmptyString, FileNames::PluginRegistry());
|
||||
AudacityFileConfig registry(
|
||||
{}, {}, FileNames::PluginRegistry());
|
||||
|
||||
// Clear it out
|
||||
registry.DeleteAll();
|
||||
@@ -2777,7 +2780,7 @@ FileConfig *PluginManager::GetSettings()
|
||||
{
|
||||
if (!mSettings)
|
||||
{
|
||||
mSettings = std::make_unique<FileConfig>(wxEmptyString, wxEmptyString, FileNames::PluginSettings());
|
||||
mSettings = std::make_unique<AudacityFileConfig>(wxEmptyString, wxEmptyString, FileNames::PluginSettings());
|
||||
|
||||
// Check for a settings version that we can understand
|
||||
if (mSettings->HasEntry(SETVERKEY))
|
||||
@@ -2805,7 +2808,7 @@ FileConfig *PluginManager::GetSettings()
|
||||
|
||||
bool PluginManager::HasGroup(const RegistryPath & group)
|
||||
{
|
||||
FileConfig *settings = GetSettings();
|
||||
auto settings = GetSettings();
|
||||
|
||||
bool res = settings->HasGroup(group);
|
||||
if (res)
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
#include "Internat.h"
|
||||
#include "MemoryX.h"
|
||||
|
||||
std::unique_ptr<AudacityPrefs> ugPrefs {};
|
||||
std::unique_ptr<FileConfig> ugPrefs {};
|
||||
|
||||
AudacityPrefs *gPrefs = NULL;
|
||||
FileConfig *gPrefs = nullptr;
|
||||
int gMenusDirty = 0;
|
||||
|
||||
wxDEFINE_EVENT(EVT_PREFS_UPDATE, wxCommandEvent);
|
||||
@@ -171,33 +171,10 @@ static void CopyEntriesRecursive(wxString path, wxConfigBase *src, wxConfigBase
|
||||
}
|
||||
#endif
|
||||
|
||||
AudacityPrefs::AudacityPrefs(const wxString& appName,
|
||||
const wxString& vendorName,
|
||||
const wxString& localFilename,
|
||||
const wxString& globalFilename,
|
||||
long style,
|
||||
const wxMBConv& conv) :
|
||||
FileConfig(appName,
|
||||
vendorName,
|
||||
localFilename,
|
||||
globalFilename,
|
||||
style,
|
||||
conv)
|
||||
void InitPreferences( std::unique_ptr<FileConfig> uPrefs )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void InitPreferences( const wxFileName &configFileName )
|
||||
{
|
||||
wxString appName = wxTheApp->GetAppName();
|
||||
|
||||
ugPrefs = std::make_unique<AudacityPrefs>
|
||||
(appName, wxEmptyString,
|
||||
configFileName.GetFullPath(),
|
||||
wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
|
||||
gPrefs = ugPrefs.get();
|
||||
|
||||
gPrefs = uPrefs.get();
|
||||
ugPrefs = std::move(uPrefs);
|
||||
wxConfigBase::Set(gPrefs);
|
||||
}
|
||||
|
||||
|
||||
19
src/Prefs.h
19
src/Prefs.h
@@ -40,28 +40,13 @@
|
||||
|
||||
class wxFileName;
|
||||
|
||||
void InitPreferences( const wxFileName &configFileName );
|
||||
void InitPreferences( std::unique_ptr<FileConfig> uPrefs );
|
||||
void FinishPreferences();
|
||||
|
||||
class AudacityPrefs;
|
||||
|
||||
|
||||
extern AUDACITY_DLL_API AudacityPrefs *gPrefs;
|
||||
extern AUDACITY_DLL_API FileConfig *gPrefs;
|
||||
extern int gMenusDirty;
|
||||
|
||||
|
||||
/// \brief Our own specialisation of wxFileConfig. It is essentially a renaming.
|
||||
class AUDACITY_DLL_API AudacityPrefs : public FileConfig
|
||||
{
|
||||
public:
|
||||
AudacityPrefs(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());
|
||||
};
|
||||
|
||||
struct ByColumns_t{};
|
||||
extern ByColumns_t ByColumns;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user