Audacity 3.2.0
Classes | Namespaces | Typedefs | Functions | Variables
Prefs.cpp File Reference

Utility functions for working with our wxConf (gPrefs) More...

#include "Prefs.h"
#include <wx/defs.h>
#include <wx/app.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>
#include "Internat.h"
#include "MemoryX.h"
#include "BasicUI.h"
#include "Observer.h"
#include <set>
Include dependency graph for Prefs.cpp:

Go to the source code of this file.

Classes

struct  PrefsListener::Impl
 
struct  anonymous_namespace{Prefs.cpp}::Hub
 

Namespaces

namespace  anonymous_namespace{Prefs.cpp}
 

Typedefs

using anonymous_namespace{Prefs.cpp}::PreferenceInitializers = std::set< PreferenceInitializer * >
 

Functions

static Hub & anonymous_namespace{Prefs.cpp}::hub ()
 
void InitPreferences (std::unique_ptr< FileConfig > uPrefs)
 
void ResetPreferences ()
 Call this to reset preferences to an (almost)-"new" default state. More...
 
void FinishPreferences ()
 
wxString WarningDialogKey (const wxString &internalDialogName)
 
PreferenceInitializers & anonymous_namespace{Prefs.cpp}::allInitializers ()
 

Variables

BoolSetting DefaultUpdatesCheckingFlag
 
std::unique_ptr< FileConfigugPrefs {}
 
FileConfiggPrefs = nullptr
 
int gMenusDirty = 0
 
std::vector< SettingScope * > anonymous_namespace{Prefs.cpp}::sScopes
 
ByColumns_t ByColumns {}
 

Detailed Description

Utility functions for working with our wxConf (gPrefs)

Audacity uses wxWidgets' wxConfig class to handle preferences. See Prefs.h for more information on how it works...

  Note: The info below is very outdated and incomplete

  Preference field specification:
   /
      Version              - Audacity Version that created these prefs
      DefaultOpenPath         - Default directory for NEW file selector
   /FileFormats
      CopyOrEditUncompressedData - Copy data from uncompressed files or
         [ "copy", "edit"]   - edit in place?
      ExportFormat_SF1        - Format to export PCM data in
                             (this number is a libsndfile1.0 format)
   /SamplingRate
      DefaultProjectSampleRate- New projects will have this rate
         [ 8000, 11025, 16000, 22050, 44100, 48000 ]
   /AudioIO
      PlaybackDevice       - device to use for playback
      RecordingDevice         - device to use for recording
         (these are device names understood by PortAudio)
   /Display
      WaveformColor        - 0xRRGGBB  --since it will be stored in
      ShadowColor          -          decimal, it will be somewhat
      SpectrumLowColor     -          non-intuitive to edit, but
      SpectrumHighColor    -          much easier to parse.
   /Locale
      Language          - two-letter language code for translations

   (*): wxGTK
   (+): wxWin
   ($): wxMac

Definition in file Prefs.cpp.

Function Documentation

◆ FinishPreferences()

void FinishPreferences ( )

Definition at line 227 of file Prefs.cpp.

228{
229 if (gPrefs) {
230 wxConfigBase::Set(NULL);
231 ugPrefs.reset();
232 gPrefs = NULL;
233 }
234}
std::unique_ptr< FileConfig > ugPrefs
Definition: Prefs.cpp:68
FileConfig * gPrefs
Definition: Prefs.cpp:70

References gPrefs, and ugPrefs.

Referenced by AudacityApp::InitPart2(), AudacityApp::OnExit(), and AudacityApp::OnInit().

Here is the caller graph for this function:

◆ InitPreferences()

void InitPreferences ( std::unique_ptr< FileConfig uPrefs)

Definition at line 200 of file Prefs.cpp.

201{
202 gPrefs = uPrefs.get();
203 ugPrefs = std::move(uPrefs);
204 wxConfigBase::Set(gPrefs);
206}
static void Broadcast(int id=0)
Call this static function to notify all PrefsListener objects.
Definition: Prefs.cpp:97

References PrefsListener::Broadcast(), gPrefs, and ugPrefs.

Referenced by AudacityApp::OnInit(), and PluginHost::PluginHost().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetPreferences()

void ResetPreferences ( )

Call this to reset preferences to an (almost)-"new" default state.

There is at least one exception to that: user preferences we want to make more "sticky." Notably, whether automatic update checking is preferred.

Definition at line 208 of file Prefs.cpp.

209{
210 // Future: make this a static registry table, so the settings objects
211 // don't need to be defined in this source code file to avoid dependency
212 // cycles
213 std::pair<BoolSetting &, bool> stickyBoolSettings[] {
215 // ... others?
216 };
217 for (auto &pair : stickyBoolSettings)
218 pair.second = pair.first.Read();
219
220 bool savedValue = DefaultUpdatesCheckingFlag.Read();
221 gPrefs->DeleteAll();
222
223 for (auto &pair : stickyBoolSettings)
224 pair.first.Write(pair.second);
225}
BoolSetting DefaultUpdatesCheckingFlag
Definition: Prefs.cpp:65
virtual bool DeleteAll() wxOVERRIDE
Definition: FileConfig.cpp:229
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200

References DefaultUpdatesCheckingFlag, FileConfig::DeleteAll(), gPrefs, and Setting< T >::Read().

Referenced by anonymous_namespace{PluginMenus.cpp}::OnResetConfig(), and anonymous_namespace{AudacityApp.cpp}::PopulatePreferences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WarningDialogKey()

wxString WarningDialogKey ( const wxString &  internalDialogName)

Return the config file key associated with a warning dialog identified by internalDialogName. When the box is checked, the value at the key becomes false.

Definition at line 469 of file Prefs.cpp.

470{
471 return wxT("/Warnings/") + internalDialogName;
472}
wxT("CloseDown"))

References wxT().

Referenced by RecordingPrefs::PopulateOrExchange(), ShowWarningDialog(), and AudioIO::StartStream().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ByColumns

ByColumns_t ByColumns {}

◆ DefaultUpdatesCheckingFlag

BoolSetting DefaultUpdatesCheckingFlag

◆ gMenusDirty

int gMenusDirty = 0

Definition at line 71 of file Prefs.cpp.

◆ gPrefs

FileConfig* gPrefs = nullptr

Definition at line 70 of file Prefs.cpp.

Referenced by AdornedRulerPanel::AdornedRulerPanel(), PluginManager::Iterator::Advance(), EffectTruncSilence::Analyze(), GetPreferenceCommand::Apply(), SetPreferenceCommand::Apply(), MacroCommands::ApplyMacro(), ApplyMacroDialog::ApplyMacroToProject(), ProjectSelectionManager::AS_SetSelectionFormat(), ProjectSelectionManager::AS_SetSnapTo(), AudacityApp::AssociateFileTypes(), ProgressDialog::Beep(), ScreenshotCommand::CapturePreferences(), DeviceToolBar::ChangeHost(), AudioSetupToolBar::ChangeHost(), ExportMP3::CheckFileName(), cloud::audiocom::UserService::ClearUserData(), SettingTransaction::Commit(), GUIPrefs::Commit(), KeyConfigPrefs::Commit(), QualityPrefs::Commit(), RecordingPrefs::Commit(), TracksPrefs::Commit(), LabelTrackView::ComputeLayout(), ControlToolBar::ControlToolBar(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), cloud::audiocom::OAuthService::DoAuthorise(), LabelTrackView::DoCaptureKey(), LabelTrackView::DoChar(), TagsEditorDialog::DoEditMetadata(), ProjectAudioManager::DoRecord(), WaveTrackVZoomHandle::DoRelease(), SpectrumView::DoSetMinimized(), WaveformView::DoSetMinimized(), ToolsToolBar::DoToolChanged(), cloud::audiocom::UserService::DownloadAvatar(), EffectNoiseRemoval::EffectNoiseRemoval(), Exporter::ExamineTracks(), ExportFFmpeg::Export(), ExportMP3::Export(), ExportOGG::Export(), ExportCLOptions::ExportCLOptions(), ExportFFmpegOptions::ExportFFmpegOptions(), ExportMP3Options::ExportMP3Options(), ExportMultipleDialog::ExportMultipleByLabel(), ExportMultipleDialog::ExportMultipleByTrack(), ExportOGGOptions::ExportOGGOptions(), anonymous_namespace{ExtraMenus.cpp}::ExtraMenu(), AudioSetupToolBar::FillHostDevices(), DeviceToolBar::FillHostDevices(), MP3Exporter::FindLibrary(), FinishPreferences(), anonymous_namespace{Registry.cpp}::ItemOrdering::Get(), ModulePrefs::GetAllModuleStatuses(), SettingBase::GetConfig(), Exporter::GetFilename(), ModuleSettings::GetModuleStatus(), TracksPrefs::GetPinnedHeadPositionPreference(), TracksPrefs::GetPinnedHeadPreference(), GlobalPrefsDialog::GetPreferredPage(), ExportCL::GetSettings(), PlaybackPrefs::GetUnpinnedScrubbingPreference(), FileHistory::Global(), NoteTrackVZoomHandle::HitPreview(), WaveTrackVZoomHandle::HitPreview(), Importer::Import(), AudioIO::Init(), EffectNoiseRemoval::Init(), ExportFFmpeg::InitCodecs(), AudacityApp::InitPart2(), InitPreferences(), anonymous_namespace{NoteTrackVZoomHandle.cpp}::IsDragZooming(), WaveTrackVZoomHandle::IsDragZooming(), UpdateManager::IsTimeForUpdatesChecking(), EQCurveReader::LoadCurves(), Tags::LoadDefaults(), LoadEncoding(), LoadFFmpeg(), LoadOtherFormat(), ToolBar::MakeButtonBackgroundsLarge(), ToolBar::MakeButtonBackgroundsSmall(), CommandManager::Options::MakeCheckFn(), EnumSettingBase::Migrate(), SpectrogramSettings::ColorSchemeEnumSetting::Migrate(), TracksViewModeEnumSetting::Migrate(), MP3Exporter::MP3Exporter(), CommandManager::NewIdentifier(), FileHistory::NotifyMenus(), NyqBench::NyqBench(), ViewActions::Handler::OnAdvancedVZoom(), anonymous_namespace{TrackMenus.cpp}::OnAlign(), ApplyMacroDialog::OnApplyToFiles(), AdornedRulerPanel::OnAutoScroll(), PrefsDialog::OnCancel(), BrowserDialog::OnClose(), ScreenshotBigDialog::OnClose(), FrequencyPlotDialog::OnCloseButton(), ScreenshotBigDialog::OnCloseWindow(), AudioPasteDialog::OnContinue(), anonymous_namespace{EditMenus.cpp}::OnCut(), anonymous_namespace{LabelMenus.cpp}::OnCutLabels(), ScreenshotBigDialog::OnDirChoose(), SplashDialog::OnDontShow(), TagsEditorDialog::OnDontShow(), AudacityApp::OnExit(), ExportMultipleDialog::OnExport(), ExportFFmpegOptions::OnExportPresets(), NyqBench::OnFind(), NyqBench::OnFindDialog(), KeyConfigPrefs::OnImportDefaults(), ExportFFmpegOptions::OnImportPresets(), ExportMP3Options::OnMono(), anonymous_namespace{TrackMenus.cpp}::OnMoveSelectionWithTracks(), PrefsDialog::OnOK(), ExportFFmpegOptions::OnOK(), SoundActivatedRecordDialog::OnOK(), TagsEditorDialog::OnOk(), TimerRecordDialog::OnOK(), FFmpegNotFoundDialog::OnOk(), NyqBench::OnOpen(), anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionStart(), MeterPanel::OnPreferences(), ProjectAudioManager::OnRecord(), anonymous_namespace{PluginMenus.cpp}::OnResetConfig(), NyqBench::OnSaveAs(), TagsEditorDialog::OnSaveDefaults(), LabelTrackMenuTable::OnSetFont(), ViewActions::Handler::OnShowClipping(), ViewActions::Handler::OnShowExtraMenus(), ViewActions::Handler::OnShowNameOverlay(), anonymous_namespace{TrackMenus.cpp}::OnSyncLock(), AdornedRulerPanel::OnSyncSelToQuickPlay(), DirectoriesPrefs::OnTempBrowse(), anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord(), anonymous_namespace{TransportMenus.cpp}::OnTogglePlayRecording(), anonymous_namespace{TransportMenus.cpp}::OnToggleSoundActivated(), anonymous_namespace{TransportMenus.cpp}::OnToggleSWPlaythrough(), anonymous_namespace{LabelMenus.cpp}::OnToggleTypeToCreateLabel(), FFmpegImportPlugin::Open(), Registry::OrderingPreferenceInitializer::operator()(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayPlayRegion(), ApplyMacroDialog::Populate(), MacrosWindow::Populate(), ControlToolBar::Populate(), SplashDialog::Populate(), cloud::audiocom::ShareAudioDialog::InitialStatePanel::PopulateFirstTimeNotice(), ExportFFmpegOptions::PopulateOrExchange(), ExportMP3Options::PopulateOrExchange(), ExportMultipleDialog::PopulateOrExchange(), anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::PopulateOrExchange(), ScreenshotBigDialog::PopulateOrExchange(), TagsEditorDialog::PopulateOrExchange(), TimerRecordDialog::PopulateOrExchange(), anonymous_namespace{AudacityApp.cpp}::PopulatePreferences(), PrefsDialog::PrefsDialog(), EffectNoiseReduction::Settings::PrefsIO(), EffectBase::Preview(), Exporter::Process(), NyquistEffect::Process(), EffectPaulstretch::ProcessOne(), PerTrackEffect::ProcessPass(), ProjectRate::ProjectRate(), ProjectSettings::ProjectSettings(), ToolBarConfiguration::Read(), ToolManager::ReadConfig(), Importer::ReadImportItems(), anonymous_namespace{NoiseReduction.cpp}::readPrefs(), LabelDialog::ReadSize(), ChoiceSetting::ReadWithDefault(), RecordingPrefs::RecordingPrefs(), ControlToolBar::RegenerateTooltips(), LabelStruct::RegionRelation(), NoteTrackVZoomHandle::Release(), CommandManager::RemoveDuplicateShortcuts(), MacroCommands::ReportAndSkip(), LabelTrackView::ResetFont(), ResetPreferences(), MacrosWindow::SaveChanges(), SaveEncoding(), DependencyDialog::SaveFutureActionChoice(), SaveOtherFormat(), GlobalPrefsDialog::SavePreferredPage(), NyqBench::SavePrefs(), SelectUtilities::SelectAllIfNoneAndAllowed(), Importer::SelectDefaultOpenType(), SelectionBar::SelectionBar(), SelectionBar::SelectionModeUpdated(), Importer::SetDefaultOpenType(), AudioSetupToolBar::SetDevices(), DeviceToolBar::SetDevices(), GUISettings::SetLang(), Importer::SetLastOpenType(), CommandManager::SetMaxList(), ModuleSettings::SetModuleStatus(), ExportMP3::SetNumExportChannels(), TracksPrefs::SetPinnedHeadPositionPreference(), TracksPrefs::SetPinnedHeadPreference(), Journal::SetRecordEnabled(), HelpSystem::ShowHelp(), EffectNoiseRemoval::ShowHostInterface(), ShowWarningDialog(), ProjectSelectionManager::SSBL_SetBandwidthSelectionFormatName(), ProjectSelectionManager::SSBL_SetFrequencySelectionFormatName(), UpdateManager::Start(), WaveTrackAffordanceControls::StartEditClipName(), AudioIO::StartMonitoring(), ControlToolBar::StartScrolling(), AudioIO::StartStream(), TagsEditorDialog::TagsEditorDialog(), TempDirectory::TempDir(), ToolsToolBar::ToolsToolBar(), ShuttlePrefs::TransferBool(), ExportCLOptions::TransferDataFromWindow(), ExportFFmpegAC3Options::TransferDataFromWindow(), ExportFFmpegAACOptions::TransferDataFromWindow(), ExportFFmpegAMRNBOptions::TransferDataFromWindow(), ExportFFmpegOPUSOptions::TransferDataFromWindow(), ExportFFmpegWMAOptions::TransferDataFromWindow(), ExportFLACOptions::TransferDataFromWindow(), ExportMP3Options::TransferDataFromWindow(), ExportOGGOptions::TransferDataFromWindow(), ExportWavPackOptions::TransferDataFromWindow(), TimerRecordDialog::TransferDataFromWindow(), ExportFFmpegCustomOptions::TransferDataToWindow(), ShuttlePrefs::TransferDouble(), ShuttlePrefs::TransferInt(), ShuttlePrefs::TransferString(), anonymous_namespace{TransportMenus.cpp}::TransportMenu(), ProjectSelectionManager::TT_SetAudioTimeFormat(), cloud::audiocom::OAuthService::UnlinkAccount(), EQCurveReader::UpdateDefaultCurves(), ViewInfo::UpdatePrefs(), AdornedRulerPanel::UpdatePrefs(), MenuManager::UpdatePrefs(), NavigationActions::Handler::UpdatePrefs(), SelectActions::Handler::UpdatePrefs(), ProjectSettings::UpdatePrefs(), ControlToolBar::UpdatePrefs(), SelectionBar::UpdatePrefs(), MeterPanel::UpdatePrefs(), cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::UpdatePublicity(), ViewInfo::UpdateSelectedPrefs(), TrackArtist::UpdateSelectedPrefs(), cloud::audiocom::UserService::UpdateUserData(), ProjectAudioManager::UseDuplex(), Registry::Visit(), anonymous_namespace{Registry.cpp}::VisitItems(), FileNames::WithDefaultPath(), ToolBarConfiguration::Write(), ChoiceSetting::Write(), ToolManager::WriteConfig(), Importer::WriteImportItems(), anonymous_namespace{NoiseReduction.cpp}::writePrefs(), and LabelDialog::WriteSize().

◆ ugPrefs

std::unique_ptr<FileConfig> ugPrefs {}

Definition at line 68 of file Prefs.cpp.

Referenced by FinishPreferences(), and InitPreferences().