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 "BasicUI.h"
#include "Internat.h"
#include "IteratorX.h"
#include "Observer.h"
#include <set>
Include dependency graph for Prefs.cpp:

Go to the source code of this file.

Classes

struct  PrefsListener::Impl
 
class  anonymous_namespace{Prefs.cpp}::PreferencesResetHandlerRegistry
 
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< audacity::BasicSettings > uPrefs)
 
void GetPreferencesVersion (int &vMajor, int &vMinor, int &vMicro)
 
void SetPreferencesVersion (int vMajor, int vMinor, int vMicro)
 
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

StickySetting< BoolSettingDefaultUpdatesCheckingFlag
 
std::unique_ptr< audacity::BasicSettingsugPrefs {}
 
audacity::BasicSettingsgPrefs = nullptr
 
int gMenusDirty = 0
 
int gVersionMajorKeyInit {}
 
int gVersionMinorKeyInit {}
 
int gVersionMicroKeyInit {}
 
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
      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 262 of file Prefs.cpp.

263{
264 if (gPrefs) {
265 ugPrefs.reset();
266 gPrefs = nullptr;
267 }
268}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
std::unique_ptr< audacity::BasicSettings > ugPrefs
Definition: Prefs.cpp:66

References gPrefs, and ugPrefs.

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

Here is the caller graph for this function:

◆ GetPreferencesVersion()

void GetPreferencesVersion ( int &  vMajor,
int &  vMinor,
int &  vMicro 
)

Definition at line 239 of file Prefs.cpp.

240{
241 vMajor = gVersionMajorKeyInit;
242 vMinor = gVersionMinorKeyInit;
243 vMicro = gVersionMicroKeyInit;
244}
int gVersionMinorKeyInit
Definition: Prefs.cpp:72
int gVersionMicroKeyInit
Definition: Prefs.cpp:73
int gVersionMajorKeyInit
Definition: Prefs.cpp:71

References gVersionMajorKeyInit, gVersionMicroKeyInit, and gVersionMinorKeyInit.

Referenced by AudacityApp::InitPart2(), and ToolManager::ReadConfig().

Here is the caller graph for this function:

◆ InitPreferences()

void InitPreferences ( std::unique_ptr< audacity::BasicSettings uPrefs)

Definition at line 231 of file Prefs.cpp.

232{
233 gPrefs = uPrefs.get();
234 ugPrefs = std::move(uPrefs);
235 //wxConfigBase::Set(gPrefs);
237}
static void Broadcast(int id=0)
Call this static function to notify all PrefsListener objects.
Definition: Prefs.cpp:128

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 253 of file Prefs.cpp.

254{
256
257 gPrefs->Clear();
258
260}
virtual void Clear()=0
Remove all groups and keys.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202

References audacity::BasicSettings::Clear(), BasicUI::Get(), and gPrefs.

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:

◆ SetPreferencesVersion()

void SetPreferencesVersion ( int  vMajor,
int  vMinor,
int  vMicro 
)

Definition at line 246 of file Prefs.cpp.

247{
248 gVersionMajorKeyInit = vMajor;
249 gVersionMinorKeyInit = vMinor;
250 gVersionMicroKeyInit = vMicro;
251}

References gVersionMajorKeyInit, gVersionMicroKeyInit, and gVersionMinorKeyInit.

Referenced by anonymous_namespace{AudacityApp.cpp}::PopulatePreferences().

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 510 of file Prefs.cpp.

511{
512 return wxT("/Warnings/") + internalDialogName;
513}
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

StickySetting<BoolSetting> DefaultUpdatesCheckingFlag

◆ gMenusDirty

int gMenusDirty = 0

Definition at line 69 of file Prefs.cpp.

◆ gPrefs

audacity::BasicSettings* gPrefs = nullptr

Definition at line 68 of file Prefs.cpp.

Referenced by AdornedRulerPanel::AdornedRulerPanel(), PluginManager::Iterator::Advance(), TruncSilenceBase::Analyze(), ExportCommand::Apply(), GetPreferenceCommand::Apply(), SetPreferenceCommand::Apply(), MacroCommands::ApplyMacro(), ApplyMacroDialog::ApplyMacroToProject(), AudacityApp::AssociateFileTypes(), audacity::cloud::audiocom::sync::AudioComDialogBase::AudioComDialogBase(), ProgressDialog::Beep(), DeviceToolBar::ChangeHost(), AudioSetupToolBar::ChangeHost(), ExportMP3::CheckFileName(), audacity::cloud::audiocom::UserService::ClearUserData(), SettingTransaction::Commit(), DevicePrefs::Commit(), GUIPrefs::Commit(), KeyConfigPrefs::Commit(), MidiIOPrefs::Commit(), RecordingPrefs::Commit(), TracksPrefs::Commit(), ControlToolBar::ControlToolBar(), DeduceSnapTo(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), LabelTrackView::DoCaptureKey(), LabelTrackView::DoChar(), anonymous_namespace{FileMenus.cpp}::DoExport(), ProjectAudioManager::DoRecord(), SpectrumView::DoSetMinimized(), WaveformView::DoSetMinimized(), ToolsToolBar::DoToolChanged(), audacity::cloud::audiocom::UserService::DownloadAvatar(), EffectPreview(), ExportFFmpegOptions::ExportFFmpegOptions(), ExportOptionsHandler::ExportOptionsHandler(), anonymous_namespace{ExtraMenus.cpp}::ExtraMenu(), AudioSetupToolBar::FillHostDevices(), DeviceToolBar::FillHostDevices(), MP3Exporter::FindLibrary(), FinishPreferences(), anonymous_namespace{Registry.cpp}::ItemOrdering::Get(), ModulePrefs::GetAllModuleStatuses(), SettingBase::GetConfig(), ExportPCM::GetFormatInfo(), anonymous_namespace{TimeAndPitchExperimentalSettings.cpp}::GetFromFile(), ModuleSettings::GetModuleStatus(), TracksPrefs::GetPinnedHeadPositionPreference(), TracksPrefs::GetPinnedHeadPreference(), GlobalPrefsDialog::GetPreferredPage(), PlaybackPrefs::GetUnpinnedScrubbingPreference(), FileHistory::Global(), Importer::Import(), AudioIO::Init(), MP3ExportProcessor::Initialize(), AudacityApp::InitPart2(), InitPreferences(), UpdateManager::IsTimeForUpdatesChecking(), EQCurveReader::LoadCurves(), Tags::LoadDefaults(), LoadFFmpeg(), MenuRegistry::Options::MakeCheckFn(), EnumSettingBase::Migrate(), SpectrogramSettings::ColorSchemeEnumSetting::Migrate(), TracksViewModeEnumSetting::Migrate(), MP3Exporter::MP3Exporter(), CommandManager::Populator::NewIdentifier(), FileHistory::NotifyMenus(), NyqBench::NyqBench(), anonymous_namespace{TrackMenus.cpp}::OnAlign(), ApplyMacroDialog::OnApplyToFiles(), AdornedRulerPanel::OnAutoScroll(), PrefsDialog::OnCancel(), SpectralSelectionBar::OnChoice(), BrowserDialog::OnClose(), FrequencyPlotDialog::OnCloseButton(), AudioPasteDialog::OnContinue(), anonymous_namespace{EditMenus.cpp}::OnCut(), anonymous_namespace{LabelMenus.cpp}::OnCutLabels(), AudacityApp::OnExit(), ExportFFmpegOptions::OnExportPresets(), NyqBench::OnFind(), NyqBench::OnFindDialog(), KeyConfigPrefs::OnImportDefaults(), ExportFFmpegOptions::OnImportPresets(), anonymous_namespace{TrackMenus.cpp}::OnMoveSelectionWithTracks(), WhatsNewDialog::OnOK(), PrefsDialog::OnOK(), ExportFFmpegOptions::OnOK(), SoundActivatedRecordDialog::OnOK(), TagsEditorDialog::OnOk(), TimerRecordDialog::OnOK(), FFmpegNotFoundDialog::OnOk(), anonymous_namespace{ExportFFmpeg.cpp}::ExportOptionsFFmpegCustomEditor::OnOpen(), NyqBench::OnOpen(), anonymous_namespace{EditMenus.cpp}::OnPaste(), 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(), anonymous_namespace{TransportMenus.cpp}::OnPunchAndRoll(), ProjectAudioManager::OnRecord(), anonymous_namespace{PluginMenus.cpp}::OnResetConfig(), NyqBench::OnSaveAs(), TagsEditorDialog::OnSaveDefaults(), LabelTrackMenuTable::OnSetFont(), ModuleSettingsResetHandler::OnSettingResetBegin(), ModuleSettingsResetHandler::OnSettingResetEnd(), anonymous_namespace{ViewMenus.cpp}::OnShowClipping(), anonymous_namespace{ViewMenus.cpp}::OnShowExtraMenus(), anonymous_namespace{ViewMenus.cpp}::OnShowRMS(), anonymous_namespace{TrackMenus.cpp}::OnSyncLock(), AdornedRulerPanel::OnSyncSelToQuickPlay(), DirectoriesPrefs::OnTempBrowse(), anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord(), anonymous_namespace{TransportMenus.cpp}::OnTogglePlayRecording(), Scrubber::OnToggleScrubRuler(), anonymous_namespace{TransportMenus.cpp}::OnToggleSoundActivated(), anonymous_namespace{TransportMenus.cpp}::OnToggleSWPlaythrough(), anonymous_namespace{LabelMenus.cpp}::OnToggleTypeToCreateLabel(), FFmpegImportPlugin::Open(), Registry::OrderingPreferenceInitializer::operator()(), audacity::cloud::audiocom::OAuthService::ParseTokenResponse(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayPlayRegion(), PlotSpectrumBase::PlotSpectrumBase(), ApplyMacroDialog::Populate(), MacrosWindow::Populate(), ControlToolBar::Populate(), SpectralSelectionBar::Populate(), WhatsNewDialog::Populate(), ExportFFmpegOptions::PopulateOrExchange(), anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::PopulateOrExchange(), TimerRecordDialog::PopulateOrExchange(), anonymous_namespace{AudacityApp.cpp}::PopulatePreferences(), ExportOptionsCLEditor::PopulateUI(), PrefsDialog::PrefsDialog(), NoiseReductionBase::Settings::PrefsIO(), NyquistBase::Process(), PaulstretchBase::ProcessOne(), PerTrackEffect::ProcessPass(), ProjectRate::ProjectRate(), ProjectSettings::ProjectSettings(), ToolBarConfiguration::Read(), ToolManager::ReadConfig(), Importer::ReadImportItems(), anonymous_namespace{NoiseReductionBase.cpp}::readPrefs(), anonymous_namespace{Scrubbing.cpp}::ReadScrubEnabledPref(), LabelDialog::ReadSize(), ReadSnapMode(), ReadSnapTo(), ChoiceSetting::ReadWithDefault(), RecordingPrefs::RecordingPrefs(), ControlToolBar::RegenerateTooltips(), LabelStruct::RegionRelation(), MenuCreator::RemoveDuplicateShortcuts(), MacroCommands::ReportAndSkip(), CommandManager::ReportDuplicateShortcuts(), LabelTrackView::ResetFont(), ResetPreferences(), MacrosWindow::SaveChanges(), DependencyDialog::SaveFutureActionChoice(), GlobalPrefsDialog::SavePreferredPage(), NyqBench::SavePrefs(), SelectUtilities::SelectAllIfNoneAndAllowed(), Importer::SelectDefaultOpenType(), ProjectSelectionManager::SetAudioTimeFormat(), ProjectSelectionManager::SetBandwidthSelectionFormatName(), Importer::SetDefaultOpenType(), AudioSetupToolBar::SetDevices(), DeviceToolBar::SetDevices(), ProjectSelectionManager::SetFrequencySelectionFormatName(), GUISettings::SetLang(), Importer::SetLastOpenType(), ProjectTimeSignature::SetLowerTimeSignature(), CommandManager::Populator::SetMaxList(), ModuleSettings::SetModuleStatus(), TracksPrefs::SetPinnedHeadPositionPreference(), TracksPrefs::SetPinnedHeadPreference(), Journal::SetRecordEnabled(), ProjectSelectionManager::SetSelectionFormat(), ProjectSnap::SetSnapMode(), ProjectSnap::SetSnapTo(), ProjectTimeSignature::SetTempo(), ProjectTimeSignature::SetUpperTimeSignature(), anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::SetValue(), audacity::cloud::audiocom::sync::CloudLocationDialog::ShowDialog(), audacity::cloud::audiocom::sync::AudioComDialogBase::ShowDialog(), HelpSystem::ShowHelp(), ShowWarningDialog(), UpdateManager::Start(), WaveTrackAffordanceControls::StartEditClipName(), AudioIO::StartMonitoring(), ControlToolBar::StartScrolling(), AudioIO::StartStream(), TagsEditorDialog::TagsEditorDialog(), TempDirectory::TempDir(), ToolsToolBar::ToolsToolBar(), ShuttlePrefs::TransferBool(), ExportOptionsHandler::TransferDataFromEditor(), ExportOptionsCLEditor::TransferDataFromWindow(), anonymous_namespace{ExportFFmpeg.cpp}::ExportOptionsFFmpegCustomEditor::TransferDataFromWindow(), TimerRecordDialog::TransferDataFromWindow(), ShuttlePrefs::TransferDouble(), ShuttlePrefs::TransferInt(), ShuttlePrefs::TransferString(), anonymous_namespace{TransportMenus.cpp}::TransportMenu(), audacity::cloud::audiocom::OAuthService::UnlinkAccount(), anonymous_namespace{ExportFFmpeg.cpp}::ExportOptionsFFmpegCustomEditor::UpdateCodecAndFormat(), EQCurveReader::UpdateDefaultCurves(), CommandManager::UpdatePrefs(), NavigationActions::Handler::UpdatePrefs(), SelectActions::Handler::UpdatePrefs(), ProjectSettings::UpdatePrefs(), ControlToolBar::UpdatePrefs(), SelectionBar::UpdatePrefs(), MeterPanel::UpdatePrefs(), ViewInfo::UpdateSelectedPrefs(), anonymous_namespace{SelectionBar.cpp}::UpdateSelectionMode(), audacity::cloud::audiocom::UserService::UpdateUserData(), ProjectAudioManager::UseDuplex(), Registry::detail::Visit(), anonymous_namespace{Registry.cpp}::VisitItems(), FileNames::WithDefaultPath(), ToolBarConfiguration::Write(), ChoiceSetting::Write(), ToolManager::WriteConfig(), Importer::WriteImportItems(), anonymous_namespace{NoiseReductionBase.cpp}::writePrefs(), anonymous_namespace{Scrubbing.cpp}::WriteScrubEnabledPref(), and LabelDialog::WriteSize().

◆ gVersionMajorKeyInit

int gVersionMajorKeyInit {}

Definition at line 71 of file Prefs.cpp.

Referenced by GetPreferencesVersion(), and SetPreferencesVersion().

◆ gVersionMicroKeyInit

int gVersionMicroKeyInit {}

Definition at line 73 of file Prefs.cpp.

Referenced by GetPreferencesVersion(), and SetPreferencesVersion().

◆ gVersionMinorKeyInit

int gVersionMinorKeyInit {}

Definition at line 72 of file Prefs.cpp.

Referenced by GetPreferencesVersion(), and SetPreferencesVersion().

◆ ugPrefs

std::unique_ptr<audacity::BasicSettings> ugPrefs {}

Definition at line 66 of file Prefs.cpp.

Referenced by FinishPreferences(), and InitPreferences().