1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

Bug 2527 - Reset Configuration does not reset Project rate or selection timers

This commit is contained in:
Leland Lucius 2021-02-11 15:01:35 -06:00
parent 11076f00e0
commit 9445393876
3 changed files with 26 additions and 12 deletions

View File

@ -91,13 +91,13 @@ double ProjectSelectionManager::AS_GetRate()
return settings.GetRate();
}
// Typically this came from the SelectionToolbar and does not need to
// be communicated back to it.
void ProjectSelectionManager::AS_SetRate(double rate)
{
auto &project = mProject;
auto &settings = ProjectSettings::Get( project );
settings.SetRate( rate );
SelectionBar::Get( project ).SetRate(rate);
}
int ProjectSelectionManager::AS_GetSnapTo()

View File

@ -389,9 +389,7 @@ void OnResetConfig(const CommandContext &context)
// Directory will be reset on next restart.
FileNames::UpdateDefaultPath(FileNames::Operation::Temp, TempDirectory::DefaultTempDir());
gPrefs->Write("/GUI/SyncLockTracks", 0);
gPrefs->Write("/SnapTo", 0 );
ProjectSelectionManager::Get( project ).AS_SetSnapTo( 0 );
// There are many more things we could reset here.
// Beeds discussion as to which make sense to.
// Maybe in future versions?
@ -401,8 +399,9 @@ void OnResetConfig(const CommandContext &context)
// - Reset Play-at-speed speed to x1
// - Stop playback/recording and unapply pause.
// - Set Zoom sensibly.
//ProjectSelectionManager::Get(project).AS_SetRate(44100.0);
gPrefs->Write("/GUI/SyncLockTracks", 0);
gPrefs->Write("/AudioIO/SoundActivatedRecord", 0);
gPrefs->Write("/SelectionToolbarMode", 0);
gPrefs->Flush();
DoReloadPreferences(project);
ToolManager::OnResetToolBars(context);
@ -411,12 +410,18 @@ void OnResetConfig(const CommandContext &context)
// In particular the Device Toolbar ends up short on next restart,
// if they are left out.
gPrefs->Write(wxT("/PrefsVersion"), wxString(wxT(AUDACITY_PREFS_VERSION_STRING)));
// write out the version numbers to the prefs file for future checking
gPrefs->Write(wxT("/Version/Major"), AUDACITY_VERSION);
gPrefs->Write(wxT("/Version/Minor"), AUDACITY_RELEASE);
gPrefs->Write(wxT("/Version/Micro"), AUDACITY_REVISION);
gPrefs->Flush();
ProjectSelectionManager::Get( project )
.AS_SetSnapTo(gPrefs->ReadLong("/SnapTo", SNAP_OFF));
ProjectSelectionManager::Get( project )
.AS_SetRate(gPrefs->ReadDouble("/DefaultProjectSampleRate", 44100.0));
}
void OnManageGenerators(const CommandContext &context)

View File

@ -357,8 +357,18 @@ void SelectionBar::UpdatePrefs()
// As of 13-Sep-2018, changes to the sample rate pref will only affect
// creation of new projects, not the sample rate in existing ones.
// This will only change the selection mode during a "Reset Configuration"
// action since the read value will be the same during a normal preferences
// update.
mSelectionMode = gPrefs->ReadLong(wxT("/SelectionToolbarMode"), 0);
// This will only change the time format during a "Reset Configuration"
// action since the read value will be the same during a normal preferences
// update.
wxCommandEvent e;
e.SetInt(mStartTime->GetFormatIndex());
e.SetString(NumericTextCtrl::LookupFormat(
NumericConverter::TIME,
gPrefs->Read(wxT("/SelectionFormat"), wxT(""))).Internal());
OnUpdate(e);
// Set label to pull in language change
@ -497,7 +507,6 @@ void SelectionBar::OnChangedTime(wxCommandEvent & event)
// Called when one of the format drop downs is changed.
void SelectionBar::OnUpdate(wxCommandEvent &evt)
{
int index = evt.GetInt();
wxWindow *w = FindFocus();
NumericTextCtrl ** Ctrls[5] = { &mStartTime, &mEndTime, &mLengthTime, &mCenterTime, &mAudioTime };
int i;
@ -508,10 +517,11 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
evt.Skip(false);
auto format = NumericTextCtrl::LookupFormat(NumericConverter::TIME, evt.GetString());
// Save format name before recreating the controls so they resize properly
if (mStartTime)
{
auto format = mStartTime->GetBuiltinName(index);
if (mListener)
mListener->AS_SetSelectionFormat(format);
}
@ -530,10 +540,9 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
ValuesToControls();
auto format = mStartTime->GetBuiltinFormat(index);
for( i=0;i<5;i++)
if( *Ctrls[i] )
(*Ctrls[i])->SetFormatString( format );
(*Ctrls[i])->SetFormatName( format );
if( iFocus >=0 )
if( *Ctrls[iFocus] )
@ -712,7 +721,7 @@ void SelectionBar::SetSelectionFormat(const NumericFormatSymbol & format)
// Test first whether changed, to avoid infinite recursion from OnUpdate
if ( changed ) {
wxCommandEvent e;
e.SetInt(mStartTime->GetFormatIndex());
e.SetString(format.Internal());
OnUpdate(e);
}
}