mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 16:49:41 +02:00
Define ChoiceSetting::ReadWithDefault ...
... because some calls might not have used the same defaults as in the Tie... functions
This commit is contained in:
parent
bc08f571dc
commit
85b06fe6d0
@ -287,6 +287,11 @@ const EnumValueSymbol &ChoiceSetting::Default() const
|
||||
wxString ChoiceSetting::Read() const
|
||||
{
|
||||
const auto &defaultValue = Default().Internal();
|
||||
return ReadWithDefault( defaultValue );
|
||||
}
|
||||
|
||||
wxString ChoiceSetting::ReadWithDefault( const wxString &defaultValue ) const
|
||||
{
|
||||
wxString value;
|
||||
if ( !gPrefs->Read(mKey, &value, defaultValue) )
|
||||
if (!mMigrated) {
|
||||
@ -356,10 +361,26 @@ void ChoiceSetting::SetDefault( long value )
|
||||
int EnumSetting::ReadInt() const
|
||||
{
|
||||
auto index = Find( Read() );
|
||||
|
||||
wxASSERT( index < mIntValues.size() );
|
||||
return mIntValues[ index ];
|
||||
}
|
||||
|
||||
int EnumSetting::ReadIntWithDefault( int defaultValue ) const
|
||||
{
|
||||
wxString defaultString;
|
||||
auto index0 = FindInt( defaultValue );
|
||||
if ( index0 < mSymbols.size() )
|
||||
defaultString = mSymbols[ index0 ].Internal();
|
||||
else
|
||||
wxASSERT( false );
|
||||
|
||||
auto index = Find( ReadWithDefault( defaultString ) );
|
||||
|
||||
wxASSERT( index < mSymbols.size() );
|
||||
return mIntValues[ index ];
|
||||
}
|
||||
|
||||
size_t EnumSetting::FindInt( int code ) const
|
||||
{
|
||||
const auto start = mIntValues.begin();
|
||||
|
14
src/Prefs.h
14
src/Prefs.h
@ -143,6 +143,12 @@ public:
|
||||
const EnumValueSymbols &GetSymbols() const { return mSymbols; }
|
||||
|
||||
wxString Read() const;
|
||||
|
||||
// new direct use is discouraged but it may be needed in legacy code:
|
||||
// use a default in case the preference is not defined, which may not be
|
||||
// the default-default stored in this object.
|
||||
wxString ReadWithDefault( const wxString & ) const;
|
||||
|
||||
bool Write( const wxString &value ); // you flush gPrefs afterward
|
||||
|
||||
void SetDefault( long value );
|
||||
@ -178,7 +184,13 @@ public:
|
||||
);
|
||||
|
||||
// Read and write the encoded values
|
||||
virtual int ReadInt() const;
|
||||
int ReadInt() const;
|
||||
|
||||
// new direct use is discouraged but it may be needed in legacy code:
|
||||
// use a default in case the preference is not defined, which may not be
|
||||
// the default-default stored in this object.
|
||||
int ReadIntWithDefault( int defaultValue ) const;
|
||||
|
||||
bool WriteInt( int code ); // you flush gPrefs afterward
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user