diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index 22bd57b75..b1f2e1319 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -52,6 +52,7 @@ AliasedFile s. #include "blockfile/SimpleBlockFile.h" #include "DirManager.h" +#include "FileFormats.h" #include "Prefs.h" #include "Project.h" #include "ProjectSettings.h" @@ -589,8 +590,7 @@ void DependencyDialog::SaveFutureActionChoice() case 2: savePref = wxT("never"); break; default: savePref = wxT("ask"); } - gPrefs->Write(wxT("/FileFormats/SaveProjectWithDependencies"), - savePref); + FileFormatsSaveWithDependenciesSetting.Write( savePref ); gPrefs->Flush(); } } @@ -632,9 +632,7 @@ New projects will be self-contained and are less risky."); { #ifdef EXPERIMENTAL_OD_DATA wxString action = - gPrefs->Read( - wxT("/FileFormats/SaveProjectWithDependencies"), - wxT("ask")); + FileFormatsSaveWithDependenciesSetting.Read(); if (action == wxT("copy")) { // User always wants to remove dependencies diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 48092e191..5f8177a19 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -360,7 +360,7 @@ void MixerTrackCluster::UpdatePrefs() { this->SetBackgroundColour( theTheme.Colour( clrMedium ) ); mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText)); - HandleResize(); // in case prefs "/GUI/Solo" changed + HandleResize(); // in case TracksBehaviorsSolo changed } #endif diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index ded22a58c..7c0754420 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -22,6 +22,7 @@ Paul Licameli split from AudacityProject.cpp #include "AutoRecovery.h" #include "Dependencies.h" #include "DirManager.h" +#include "FileFormats.h" #include "FileNames.h" #include "Legacy.h" #include "PlatformCompatibility.h" @@ -122,13 +123,12 @@ auto ProjectFileManager::ReadProjectFile( const FilePath &fileName ) #ifdef EXPERIMENTAL_OD_DATA // 'Lossless copy' projects have dependencies. We need to always copy-in // these dependencies when converting to a normal project. - wxString oldAction = - gPrefs->Read(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy")); + auto oldAction = FileFormatsCopyOrEditSetting.Read(); bool oldAsk = gPrefs->ReadBool(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), true); if (oldAction != wxT("copy")) - gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy")); + FileFormatsCopyOrEditSetting.Write( wxT("copy") ); if (oldAsk) gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), (long) false); gPrefs->Flush(); @@ -136,7 +136,7 @@ auto ProjectFileManager::ReadProjectFile( const FilePath &fileName ) auto cleanup = finally( [&] { // and restore old settings if necessary. if (oldAction != wxT("copy")) - gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), oldAction); + FileFormatsCopyOrEditSetting.Write( oldAction ); if (oldAsk) gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), (long) true); gPrefs->Flush(); diff --git a/src/ProjectSettings.cpp b/src/ProjectSettings.cpp index 579a47622..51df8c82e 100644 --- a/src/ProjectSettings.cpp +++ b/src/ProjectSettings.cpp @@ -16,6 +16,7 @@ Paul Licameli split from AudacityProject.cpp #include "Project.h" #include "prefs/QualityPrefs.h" #include "widgets/NumericTextCtrl.h" +#include "prefs/TracksBehaviorsPrefs.h" wxDEFINE_EVENT(EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent); @@ -91,7 +92,7 @@ void ProjectSettings::UpdatePrefs() gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true); gPrefs->Read(wxT("/GUI/EmptyCanBeDirty"), &mEmptyCanBeDirty, true ); gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &mShowSplashScreen, true); - gPrefs->Read(wxT("/GUI/Solo"), &mSoloPref, wxT("Simple")); + mSoloPref = TracksBehaviorsSolo.Read(); // Update the old default to the NEW default. if (mSoloPref == wxT("Standard")) mSoloPref = wxT("Simple"); diff --git a/src/Theme.cpp b/src/Theme.cpp index dd371ad46..ffe913ef2 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -77,6 +77,7 @@ can't be. #include "Prefs.h" #include "ImageManipulation.h" #include "Internat.h" +#include "prefs/GUIPrefs.h" #include "widgets/AudacityMessageBox.h" // JKC: First get the MAC specific images. @@ -234,11 +235,7 @@ void Theme::EnsureInitialised() bool ThemeBase::LoadPreferredTheme() { // DA: Default themes differ. -#ifdef EXPERIMENTAL_DA - wxString theme = gPrefs->Read(wxT("/GUI/Theme"), wxT("dark")); -#else - wxString theme = gPrefs->Read(wxT("/GUI/Theme"), wxT("light")); -#endif + auto theme = GUITheme.Read(); theTheme.LoadTheme( theTheme.ThemeTypeOfTypeName( theme ) ); return true; diff --git a/src/TrackInfo.cpp b/src/TrackInfo.cpp index d2787cb86..4929d25ec 100644 --- a/src/TrackInfo.cpp +++ b/src/TrackInfo.cpp @@ -40,9 +40,9 @@ Paul Licameli split from TrackPanel.cpp #include "Track.h" #include "TrackPanelDrawingContext.h" #include "ViewInfo.h" +#include "prefs/TracksBehaviorsPrefs.h" #include "tracks/ui/TrackView.h" - // Subscribe to preference changes to update static variables struct Settings : PrefsListener { wxString gSoloPref; @@ -52,7 +52,7 @@ struct Settings : PrefsListener { void UpdatePrefs() override { - gPrefs->Read(wxT("/GUI/Solo"), &gSoloPref, wxT("Simple")); + gSoloPref = TracksBehaviorsSolo.Read(); // Calculation of best font size depends on language, so it should be redone in case // the language preference changed. diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index f4559cabd..21e3f9807 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -264,11 +264,10 @@ ProgressResult ExportFLAC::Export(AudacityProject *project, wxLogNull logNo; // temporarily disable wxWidgets error messages auto updateResult = ProgressResult::Success; - int levelPref; - gPrefs->Read(wxT("/FileFormats/FLACLevel"), &levelPref, 5); + long levelPref; + FLACLevel.Read().ToLong( &levelPref ); - wxString bitDepthPref = - gPrefs->Read(wxT("/FileFormats/FLACBitDepth"), wxT("16")); + auto bitDepthPref = FLACBitDepth.Read(); FLAC::Encoder::File encoder; diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index bd46b3814..71ef00553 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -236,7 +236,7 @@ auto PCMImportFileHandle::GetFileUncompressedBytes() -> ByteCount static wxString AskCopyOrEdit() { - wxString oldCopyPref = gPrefs->Read(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy")); + auto oldCopyPref = FileFormatsCopyOrEditSetting.Read(); bool firstTimeAsk = gPrefs->Read(wxT("/Warnings/CopyOrEditUncompressedDataFirstAsk"), true)?true:false; bool oldAskPref = gPrefs->Read(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), true)?true:false; @@ -245,7 +245,7 @@ static wxString AskCopyOrEdit() // This effectively does a one-time change to the preferences. if (firstTimeAsk) { if (oldCopyPref != wxT("copy")) { - gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy")); + FileFormatsCopyOrEditSetting.Write( wxT("copy") ); oldCopyPref = wxT("copy"); } gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataFirstAsk"), (long) false); @@ -338,7 +338,7 @@ static wxString AskCopyOrEdit() // if the preference changed, save it. if (newCopyPref != oldCopyPref) { - gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), newCopyPref); + FileFormatsCopyOrEditSetting.Write( newCopyPref ); gPrefs->Flush(); } oldCopyPref = newCopyPref; diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index fb4a77ebd..59e60baea 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -18,6 +18,7 @@ #include "../effects/Contrast.h" #include "../effects/EffectManager.h" #include "../effects/RealtimeEffectManager.h" +#include "../prefs/EffectsPrefs.h" // private helper classes and functions namespace { @@ -195,7 +196,7 @@ void AddEffectMenuItems( { size_t pluginCnt = plugs.size(); - wxString groupBy = gPrefs->Read(wxT("/Effects/GroupBy"), wxT("sortby:name")); + auto groupBy = EffectsGroupBy.Read(); bool grouped = false; if (groupBy.StartsWith(wxT("groupby"))) @@ -382,7 +383,7 @@ MenuTable::BaseItemPtrs PopulateEffectsMenu( plug = pm.GetNextPluginForEffectType(type); } - wxString groupby = gPrefs->Read(wxT("/Effects/GroupBy"), wxT("sortby:name")); + wxString groupby = EffectsGroupBy.Read(); using Comparator = bool(*)(const PluginDescriptor*, const PluginDescriptor*); Comparator comp1, comp2; diff --git a/src/prefs/EffectsPrefs.h b/src/prefs/EffectsPrefs.h index 6c5ba3a6d..4159e45e6 100644 --- a/src/prefs/EffectsPrefs.h +++ b/src/prefs/EffectsPrefs.h @@ -17,6 +17,7 @@ #include "PrefsPanel.h" +class ChoiceSetting; class ShuttleGui; #define EFFECTS_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Effects") } @@ -39,4 +40,7 @@ class EffectsPrefs final : public PrefsPanel /// A PrefsPanel::Factory that creates one EffectsPrefs panel. extern PrefsPanel::Factory EffectsPrefsFactory; + +extern ChoiceSetting EffectsGroupBy; + #endif diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index e494b1e67..92bcdc087 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -275,7 +275,7 @@ bool GUIPrefs::Commit() gPrefs->Flush(); } - // Reads preference /GUI/Theme + // Reads preference GUITheme theTheme.LoadPreferredTheme(); ThemePrefs::ApplyUpdatedImages(); diff --git a/src/prefs/GUIPrefs.h b/src/prefs/GUIPrefs.h index 0606c9f4e..3e2eac313 100644 --- a/src/prefs/GUIPrefs.h +++ b/src/prefs/GUIPrefs.h @@ -17,6 +17,7 @@ #include "PrefsPanel.h" +class ChoiceSetting; class ShuttleGui; class wxArrayStringEx; @@ -69,4 +70,9 @@ extern PrefsPanel::Factory GUIPrefsFactory; int ShowClippingPrefsID(); +extern ChoiceSetting + GUIManualLocation + , GUITheme +; + #endif diff --git a/src/prefs/TracksBehaviorsPrefs.h b/src/prefs/TracksBehaviorsPrefs.h index 0d6027f79..9e4c0b9ab 100644 --- a/src/prefs/TracksBehaviorsPrefs.h +++ b/src/prefs/TracksBehaviorsPrefs.h @@ -16,6 +16,7 @@ #include "PrefsPanel.h" +class ChoiceSetting; class ShuttleGui; class wxArrayStringEx; @@ -42,4 +43,7 @@ class TracksBehaviorsPrefs final : public PrefsPanel /// A PrefsPanel::Factory that creates one TracksBehaviorsPrefs panel. extern PrefsPanel::Factory TracksBehaviorsPrefsFactory; + +extern ChoiceSetting TracksBehaviorsSolo; + #endif diff --git a/src/widgets/HelpSystem.cpp b/src/widgets/HelpSystem.cpp index b4ea91ee3..2dba92d16 100644 --- a/src/widgets/HelpSystem.cpp +++ b/src/widgets/HelpSystem.cpp @@ -46,6 +46,7 @@ #include "../HelpText.h" #include "../Prefs.h" #include "../wxFileNameWrapper.h" +#include "../prefs/GUIPrefs.h" #ifdef USE_ALPHA_MANUAL const wxString HelpSystem::HelpHostname = wxT("alphamanual.audacityteam.org"); @@ -248,8 +249,8 @@ void HelpSystem::ShowHelp(wxWindow *parent, // these next lines are for legacy cfg files (pre 2.0) where we had different modes if( (HelpMode == wxT("Standard")) || (HelpMode == wxT("InBrowser")) ) { - HelpMode = wxT("Local"); - gPrefs->Write(wxT("/GUI/Help"), HelpMode); + HelpMode = GUIManualLocation.Default().Internal(); + GUIManualLocation.Write(HelpMode); gPrefs->Flush(); } }