1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-17 09:07:41 +02:00

Use global ChoiceSettings variables, not coincidental string literals

This commit is contained in:
Paul Licameli 2019-04-02 18:40:42 -04:00
parent 9b41741074
commit 87a9e7ccbb
14 changed files with 41 additions and 30 deletions

View File

@ -52,6 +52,7 @@ AliasedFile s.
#include "blockfile/SimpleBlockFile.h" #include "blockfile/SimpleBlockFile.h"
#include "DirManager.h" #include "DirManager.h"
#include "FileFormats.h"
#include "Prefs.h" #include "Prefs.h"
#include "Project.h" #include "Project.h"
#include "ProjectSettings.h" #include "ProjectSettings.h"
@ -589,8 +590,7 @@ void DependencyDialog::SaveFutureActionChoice()
case 2: savePref = wxT("never"); break; case 2: savePref = wxT("never"); break;
default: savePref = wxT("ask"); default: savePref = wxT("ask");
} }
gPrefs->Write(wxT("/FileFormats/SaveProjectWithDependencies"), FileFormatsSaveWithDependenciesSetting.Write( savePref );
savePref);
gPrefs->Flush(); gPrefs->Flush();
} }
} }
@ -632,9 +632,7 @@ New projects will be self-contained and are less risky.");
{ {
#ifdef EXPERIMENTAL_OD_DATA #ifdef EXPERIMENTAL_OD_DATA
wxString action = wxString action =
gPrefs->Read( FileFormatsSaveWithDependenciesSetting.Read();
wxT("/FileFormats/SaveProjectWithDependencies"),
wxT("ask"));
if (action == wxT("copy")) if (action == wxT("copy"))
{ {
// User always wants to remove dependencies // User always wants to remove dependencies

View File

@ -360,7 +360,7 @@ void MixerTrackCluster::UpdatePrefs()
{ {
this->SetBackgroundColour( theTheme.Colour( clrMedium ) ); this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText)); mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
HandleResize(); // in case prefs "/GUI/Solo" changed HandleResize(); // in case TracksBehaviorsSolo changed
} }
#endif #endif

View File

@ -22,6 +22,7 @@ Paul Licameli split from AudacityProject.cpp
#include "AutoRecovery.h" #include "AutoRecovery.h"
#include "Dependencies.h" #include "Dependencies.h"
#include "DirManager.h" #include "DirManager.h"
#include "FileFormats.h"
#include "FileNames.h" #include "FileNames.h"
#include "Legacy.h" #include "Legacy.h"
#include "PlatformCompatibility.h" #include "PlatformCompatibility.h"
@ -122,13 +123,12 @@ auto ProjectFileManager::ReadProjectFile( const FilePath &fileName )
#ifdef EXPERIMENTAL_OD_DATA #ifdef EXPERIMENTAL_OD_DATA
// 'Lossless copy' projects have dependencies. We need to always copy-in // 'Lossless copy' projects have dependencies. We need to always copy-in
// these dependencies when converting to a normal project. // these dependencies when converting to a normal project.
wxString oldAction = auto oldAction = FileFormatsCopyOrEditSetting.Read();
gPrefs->Read(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy"));
bool oldAsk = bool oldAsk =
gPrefs->ReadBool(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), true); gPrefs->ReadBool(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), true);
if (oldAction != wxT("copy")) if (oldAction != wxT("copy"))
gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy")); FileFormatsCopyOrEditSetting.Write( wxT("copy") );
if (oldAsk) if (oldAsk)
gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), (long) false); gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), (long) false);
gPrefs->Flush(); gPrefs->Flush();
@ -136,7 +136,7 @@ auto ProjectFileManager::ReadProjectFile( const FilePath &fileName )
auto cleanup = finally( [&] { auto cleanup = finally( [&] {
// and restore old settings if necessary. // and restore old settings if necessary.
if (oldAction != wxT("copy")) if (oldAction != wxT("copy"))
gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), oldAction); FileFormatsCopyOrEditSetting.Write( oldAction );
if (oldAsk) if (oldAsk)
gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), (long) true); gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), (long) true);
gPrefs->Flush(); gPrefs->Flush();

View File

@ -16,6 +16,7 @@ Paul Licameli split from AudacityProject.cpp
#include "Project.h" #include "Project.h"
#include "prefs/QualityPrefs.h" #include "prefs/QualityPrefs.h"
#include "widgets/NumericTextCtrl.h" #include "widgets/NumericTextCtrl.h"
#include "prefs/TracksBehaviorsPrefs.h"
wxDEFINE_EVENT(EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent); wxDEFINE_EVENT(EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent);
@ -91,7 +92,7 @@ void ProjectSettings::UpdatePrefs()
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true); gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true);
gPrefs->Read(wxT("/GUI/EmptyCanBeDirty"), &mEmptyCanBeDirty, true ); gPrefs->Read(wxT("/GUI/EmptyCanBeDirty"), &mEmptyCanBeDirty, true );
gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &mShowSplashScreen, 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. // Update the old default to the NEW default.
if (mSoloPref == wxT("Standard")) if (mSoloPref == wxT("Standard"))
mSoloPref = wxT("Simple"); mSoloPref = wxT("Simple");

View File

@ -77,6 +77,7 @@ can't be.
#include "Prefs.h" #include "Prefs.h"
#include "ImageManipulation.h" #include "ImageManipulation.h"
#include "Internat.h" #include "Internat.h"
#include "prefs/GUIPrefs.h"
#include "widgets/AudacityMessageBox.h" #include "widgets/AudacityMessageBox.h"
// JKC: First get the MAC specific images. // JKC: First get the MAC specific images.
@ -234,11 +235,7 @@ void Theme::EnsureInitialised()
bool ThemeBase::LoadPreferredTheme() bool ThemeBase::LoadPreferredTheme()
{ {
// DA: Default themes differ. // DA: Default themes differ.
#ifdef EXPERIMENTAL_DA auto theme = GUITheme.Read();
wxString theme = gPrefs->Read(wxT("/GUI/Theme"), wxT("dark"));
#else
wxString theme = gPrefs->Read(wxT("/GUI/Theme"), wxT("light"));
#endif
theTheme.LoadTheme( theTheme.ThemeTypeOfTypeName( theme ) ); theTheme.LoadTheme( theTheme.ThemeTypeOfTypeName( theme ) );
return true; return true;

View File

@ -40,9 +40,9 @@ Paul Licameli split from TrackPanel.cpp
#include "Track.h" #include "Track.h"
#include "TrackPanelDrawingContext.h" #include "TrackPanelDrawingContext.h"
#include "ViewInfo.h" #include "ViewInfo.h"
#include "prefs/TracksBehaviorsPrefs.h"
#include "tracks/ui/TrackView.h" #include "tracks/ui/TrackView.h"
// Subscribe to preference changes to update static variables // Subscribe to preference changes to update static variables
struct Settings : PrefsListener { struct Settings : PrefsListener {
wxString gSoloPref; wxString gSoloPref;
@ -52,7 +52,7 @@ struct Settings : PrefsListener {
void UpdatePrefs() override 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 // Calculation of best font size depends on language, so it should be redone in case
// the language preference changed. // the language preference changed.

View File

@ -264,11 +264,10 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
wxLogNull logNo; // temporarily disable wxWidgets error messages wxLogNull logNo; // temporarily disable wxWidgets error messages
auto updateResult = ProgressResult::Success; auto updateResult = ProgressResult::Success;
int levelPref; long levelPref;
gPrefs->Read(wxT("/FileFormats/FLACLevel"), &levelPref, 5); FLACLevel.Read().ToLong( &levelPref );
wxString bitDepthPref = auto bitDepthPref = FLACBitDepth.Read();
gPrefs->Read(wxT("/FileFormats/FLACBitDepth"), wxT("16"));
FLAC::Encoder::File encoder; FLAC::Encoder::File encoder;

View File

@ -236,7 +236,7 @@ auto PCMImportFileHandle::GetFileUncompressedBytes() -> ByteCount
static wxString AskCopyOrEdit() 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 firstTimeAsk = gPrefs->Read(wxT("/Warnings/CopyOrEditUncompressedDataFirstAsk"), true)?true:false;
bool oldAskPref = gPrefs->Read(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), 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. // This effectively does a one-time change to the preferences.
if (firstTimeAsk) { if (firstTimeAsk) {
if (oldCopyPref != wxT("copy")) { if (oldCopyPref != wxT("copy")) {
gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy")); FileFormatsCopyOrEditSetting.Write( wxT("copy") );
oldCopyPref = wxT("copy"); oldCopyPref = wxT("copy");
} }
gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataFirstAsk"), (long) false); gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataFirstAsk"), (long) false);
@ -338,7 +338,7 @@ static wxString AskCopyOrEdit()
// if the preference changed, save it. // if the preference changed, save it.
if (newCopyPref != oldCopyPref) { if (newCopyPref != oldCopyPref) {
gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), newCopyPref); FileFormatsCopyOrEditSetting.Write( newCopyPref );
gPrefs->Flush(); gPrefs->Flush();
} }
oldCopyPref = newCopyPref; oldCopyPref = newCopyPref;

View File

@ -18,6 +18,7 @@
#include "../effects/Contrast.h" #include "../effects/Contrast.h"
#include "../effects/EffectManager.h" #include "../effects/EffectManager.h"
#include "../effects/RealtimeEffectManager.h" #include "../effects/RealtimeEffectManager.h"
#include "../prefs/EffectsPrefs.h"
// private helper classes and functions // private helper classes and functions
namespace { namespace {
@ -195,7 +196,7 @@ void AddEffectMenuItems(
{ {
size_t pluginCnt = plugs.size(); size_t pluginCnt = plugs.size();
wxString groupBy = gPrefs->Read(wxT("/Effects/GroupBy"), wxT("sortby:name")); auto groupBy = EffectsGroupBy.Read();
bool grouped = false; bool grouped = false;
if (groupBy.StartsWith(wxT("groupby"))) if (groupBy.StartsWith(wxT("groupby")))
@ -382,7 +383,7 @@ MenuTable::BaseItemPtrs PopulateEffectsMenu(
plug = pm.GetNextPluginForEffectType(type); 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*); using Comparator = bool(*)(const PluginDescriptor*, const PluginDescriptor*);
Comparator comp1, comp2; Comparator comp1, comp2;

View File

@ -17,6 +17,7 @@
#include "PrefsPanel.h" #include "PrefsPanel.h"
class ChoiceSetting;
class ShuttleGui; class ShuttleGui;
#define EFFECTS_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Effects") } #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. /// A PrefsPanel::Factory that creates one EffectsPrefs panel.
extern PrefsPanel::Factory EffectsPrefsFactory; extern PrefsPanel::Factory EffectsPrefsFactory;
extern ChoiceSetting EffectsGroupBy;
#endif #endif

View File

@ -275,7 +275,7 @@ bool GUIPrefs::Commit()
gPrefs->Flush(); gPrefs->Flush();
} }
// Reads preference /GUI/Theme // Reads preference GUITheme
theTheme.LoadPreferredTheme(); theTheme.LoadPreferredTheme();
ThemePrefs::ApplyUpdatedImages(); ThemePrefs::ApplyUpdatedImages();

View File

@ -17,6 +17,7 @@
#include "PrefsPanel.h" #include "PrefsPanel.h"
class ChoiceSetting;
class ShuttleGui; class ShuttleGui;
class wxArrayStringEx; class wxArrayStringEx;
@ -69,4 +70,9 @@ extern PrefsPanel::Factory GUIPrefsFactory;
int ShowClippingPrefsID(); int ShowClippingPrefsID();
extern ChoiceSetting
GUIManualLocation
, GUITheme
;
#endif #endif

View File

@ -16,6 +16,7 @@
#include "PrefsPanel.h" #include "PrefsPanel.h"
class ChoiceSetting;
class ShuttleGui; class ShuttleGui;
class wxArrayStringEx; class wxArrayStringEx;
@ -42,4 +43,7 @@ class TracksBehaviorsPrefs final : public PrefsPanel
/// A PrefsPanel::Factory that creates one TracksBehaviorsPrefs panel. /// A PrefsPanel::Factory that creates one TracksBehaviorsPrefs panel.
extern PrefsPanel::Factory TracksBehaviorsPrefsFactory; extern PrefsPanel::Factory TracksBehaviorsPrefsFactory;
extern ChoiceSetting TracksBehaviorsSolo;
#endif #endif

View File

@ -46,6 +46,7 @@
#include "../HelpText.h" #include "../HelpText.h"
#include "../Prefs.h" #include "../Prefs.h"
#include "../wxFileNameWrapper.h" #include "../wxFileNameWrapper.h"
#include "../prefs/GUIPrefs.h"
#ifdef USE_ALPHA_MANUAL #ifdef USE_ALPHA_MANUAL
const wxString HelpSystem::HelpHostname = wxT("alphamanual.audacityteam.org"); 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 // these next lines are for legacy cfg files (pre 2.0) where we had different modes
if( (HelpMode == wxT("Standard")) || (HelpMode == wxT("InBrowser")) ) if( (HelpMode == wxT("Standard")) || (HelpMode == wxT("InBrowser")) )
{ {
HelpMode = wxT("Local"); HelpMode = GUIManualLocation.Default().Internal();
gPrefs->Write(wxT("/GUI/Help"), HelpMode); GUIManualLocation.Write(HelpMode);
gPrefs->Flush(); gPrefs->Flush();
} }
} }