15#include <unordered_set>
16#include <wx/filename.h>
35 static const wxString modulePrefsGroups[] = {
41 for(
const auto& group : modulePrefsGroups)
51 storage.emplace_back(group +
key, value);
61 const auto Do =
finally([=]{
mStorage = std::nullopt; });
73 static std::unordered_set<wxString> modules{
86 "mod-midi-import-export",
98 wxFileName FileName( fname );
99 wxString ShortName = FileName.GetName().Lower();
101 wxString PathPref = wxString(
wxT(
"/ModulePath/") ) + ShortName;
102 wxString StatusPref = wxString(
wxT(
"/Module/") ) + ShortName;
103 wxString DateTimePref = wxString(
wxT(
"/ModuleDateTime/") ) + ShortName;
105 wxString ModulePath =
gPrefs->
Read( PathPref, wxEmptyString );
106 if( ModulePath.IsSameAs( fname ) )
110 wxDateTime DateTime = FileName.GetModificationTime();
111 wxDateTime OldDateTime;
112 OldDateTime.ParseISOCombined(
gPrefs->
Read( DateTimePref, wxEmptyString ) );
115 DateTime.SetMillisecond( 0 );
116 OldDateTime.SetMillisecond( 0 );
119 if( iStatus >
kModuleNew || !OldDateTime.IsEqualTo( DateTime ) )
142 wxFileName FileName( fname );
143 wxDateTime DateTime = FileName.GetModificationTime();
144 wxString ShortName = FileName.GetName().Lower();
146 wxString PrefName = wxString(
wxT(
"/Module/") ) + ShortName;
149 PrefName = wxString(
wxT(
"/ModulePath/") ) + ShortName;
152 PrefName = wxString(
wxT(
"/ModuleDateTime/") ) + ShortName;
153 gPrefs->
Write( PrefName, DateTime.FormatISOCombined() );
static const std::unordered_set< wxString > & autoEnabledModules()
static PreferencesResetHandler::Registration< ModuleSettingsResetHandler > preserveModuleSettings
audacity::BasicSettings * gPrefs
std::optional< KeyValueStorage > mStorage
std::vector< std::pair< wxString, wxString > > KeyValueStorage
void OnSettingResetBegin() override
Happens before preferences reset.
~ModuleSettingsResetHandler() override
void OnSettingResetEnd() override
Happens after preferences reset.
Allows custom logic for preferences reset event.
virtual bool Flush() noexcept=0
virtual bool HasGroup(const wxString &key) const =0
Checks whether specified group exists relative to the current group.
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
bool DeleteEntry(const wxString &key)
Deletes specified entry if exists.
virtual bool Read(const wxString &key, bool *value) const =0
MODULE_MANAGER_API void SetModuleStatus(const FilePath &fname, int iStatus)
MODULE_MANAGER_API int GetModuleStatus(const FilePath &fname)
Performs single-time global handler registration.