Audacity 3.2.0
GUIPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 GUIPrefs.cpp
6
7 Brian Gunlogson
8 Joshua Haberman
9 Dominic Mazzoni
10 James Crook
11
12
13*******************************************************************//*******************************************************************/
19
20
21#include "GUIPrefs.h"
22
23#include <wx/defs.h>
24
25#include "FileNames.h"
26#include "Languages.h"
27#include "Theme.h"
28#include "Prefs.h"
29#include "../ShuttleGui.h"
30
31#include "Decibels.h"
32
33#include "ThemePrefs.h"
34#include "AColor.h"
35#include "GUISettings.h"
36
37GUIPrefs::GUIPrefs(wxWindow * parent, wxWindowID winid)
38/* i18n-hint: refers to Audacity's user interface settings */
39: PrefsPanel(parent, winid, XC("Interface", "GUI"))
40{
41 Populate();
42}
43
45{
46}
47
49{
51}
52
54{
55 return XO("Preferences for GUI");
56}
57
59{
60 return "Interface_Preferences";
61}
62
64 TranslatableStrings *pChoices,
65 wxArrayStringEx *pCodes,
66 int *pDefaultRangeIndex
67)
68{
69 static const auto sCodes = {
70 wxT("36") ,
71 wxT("48") ,
72 wxT("60") ,
73 wxT("72") ,
74 wxT("84") ,
75 wxT("96") ,
76 wxT("120") ,
77 wxT("145") ,
78 };
79 if (pCodes)
80 *pCodes = sCodes;
81
82 static const std::initializer_list<TranslatableString> sChoices = {
83 XO("-36 dB (shallow range for high-amplitude editing)") ,
84 XO("-48 dB (PCM range of 8 bit samples)") ,
85 XO("-60 dB (PCM range of 10 bit samples)") ,
86 XO("-72 dB (PCM range of 12 bit samples)") ,
87 XO("-84 dB (PCM range of 14 bit samples)") ,
88 XO("-96 dB (PCM range of 16 bit samples)") ,
89 XO("-120 dB (approximate limit of human hearing)") ,
90 XO("-145 dB (PCM range of 24 bit samples)") ,
91 };
92
93 if (pChoices)
94 *pChoices = sChoices;
95
96 if (pDefaultRangeIndex)
97 *pDefaultRangeIndex = 2; // 60 == ENV_DB_RANGE
98}
99
101{
102 // First any pre-processing for constructing the GUI.
105
107
108#if 0
110 // only for testing...
111 "kg" ,
112 "ep" ,
113 } );
114
115 mLangNames.insert( mLangNames.end(), {
116 "Klingon" ,
117 "Esperanto" ,
118 } );
119#endif
120
121 //------------------------- Main section --------------------
122 // Now construct the GUI itself.
123 // Use 'eIsCreatingFromPrefs' so that the GUI is
124 // initialised with values from gPrefs.
127 // ----------------------- End of main section --------------
128}
129
131 wxT("/GUI/Help"),
132 {
133 ByColumns,
134 { XO("Local") , XO("From Internet") , },
135 { wxT("Local") , wxT("FromInternet") , }
136 },
137 0 // "Local"
138};
139
141{
142 ChoiceSetting LanguageSetting{ wxT("/Locale/Language"),
144 };
148 };
149
150 S.SetBorder(2);
151 S.StartScroller();
152
153 S.StartStatic(XO("Display"));
154 {
155 S.StartMultiColumn(2);
156 {
157 S.TieChoice( XXO("&Language:"), LanguageSetting);
158 S.TieChoice( XXO("Location of &Manual:"), GUIManualLocation);
159 S.TieChoice( XXO("Th&eme:"), GUITheme());
160 S.TieChoice( XXO("Meter dB &range:"), DBSetting);
161 }
162 S.EndMultiColumn();
163
164 }
165 S.EndStatic();
166
167 S.StartStatic(XO("Options"));
168 {
169 // Start wording of options with a verb, if possible.
170 S.TieCheckBox(XXO("Show 'How to Get &Help' at launch"),
171 {wxT("/GUI/ShowSplashScreen"),
172 true});
173 S.TieCheckBox(XXO("Show e&xtra menus"),
174 {wxT("/GUI/ShowExtraMenus"),
175 false});
176#ifdef EXPERIMENTAL_THEME_PREFS
177 // We do not want to make this option mainstream. It's a
178 // convenience for developers.
179 S.TieCheckBox(XXO("Show alternative &styling (Mac vs PC)"),
180 {wxT("/GUI/ShowMac"),
181 false});
182#endif
183 S.TieCheckBox(XXO("&Beep on completion of longer activities"),
184 {wxT("/GUI/BeepOnCompletion"),
185 false});
186 S.TieCheckBox(XXO("Re&tain labels if selection snaps to a label"),
187 {wxT("/GUI/RetainLabels"),
188 false});
189 S.TieCheckBox(XXO("B&lend system and Audacity theme"),
191#ifndef __WXMAC__
192 /* i18n-hint: RTL stands for 'Right to Left' */
193 S.TieCheckBox(XXO("Use mostly Left-to-Right layouts in RTL languages"),
194 {"/GUI/RtlWorkaround",
195 true});
196#endif
197#ifdef EXPERIMENTAL_CEE_NUMBERS_OPTION
198 S.TieCheckBox(XXO("Never use comma as decimal point"),
199 {wxT("/Locale/CeeNumberFormat"),
200 false});
201#endif
202 }
203 S.EndStatic();
204
205 S.StartStatic(XO("Timeline"));
206 {
207 S.TieCheckBox(XXO("Show Timeline Tooltips"),
208 {wxT("/QuickPlay/ToolTips"),
209 true});
210 S.TieCheckBox(XXO("Show Scrub Ruler"),
211 {wxT("/QuickPlay/ScrubbingEnabled"),
212 false});
213 }
214 S.EndStatic();
215
216 S.EndScroller();
217}
218
220{
223
224 // If language has changed, we want to change it now, not on the next reboot.
225 wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
226 wxString usedLang = GUISettings::SetLang(lang);
227 // Bug 1523: Previously didn't check no-language (=System Language)
228 if (!(lang.empty() || lang == L"System") && (lang != usedLang)) {
229 // lang was not usable and is not system language. We got overridden.
230 gPrefs->Write(wxT("/Locale/Language"), usedLang);
231 gPrefs->Flush();
232 }
233
234 // Reads preference GUITheme
235 {
236 wxBusyCursor busy;
239 }
241
242 return true;
243}
244
246{
247 static int value = wxNewId();
248 return value;
249}
250
252{
253 static int value = wxNewId();
254 return value;
255}
256
257namespace{
259 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
260 {
261 wxASSERT(parent); // to justify safenew
262 return safenew GUIPrefs(parent, winid);
263 }
264};
265}
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
int ShowTrackNameInWaveformPrefsID()
Definition: GUIPrefs.cpp:251
ChoiceSetting GUIManualLocation
Definition: GUIPrefs.cpp:130
int ShowClippingPrefsID()
Definition: GUIPrefs.cpp:245
#define GUI_PREFS_PLUGIN_SYMBOL
Definition: GUIPrefs.h:23
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
#define XC(s, c)
Definition: Internat.h:37
#define safenew
Definition: MemoryX.h:10
FileConfig * gPrefs
Definition: Prefs.cpp:71
ByColumns_t ByColumns
Definition: Prefs.cpp:474
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:48
@ eIsSavingToPrefs
Definition: ShuttleGui.h:49
THEME_API Theme theTheme
Definition: Theme.cpp:82
THEME_API BoolSetting GUIBlendThemes
THEME_API ChoiceSetting & GUITheme()
#define S(N)
Definition: ToChars.cpp:64
std::vector< TranslatableString > TranslatableStrings
static void ApplyUpdatedImages()
Definition: AColor.cpp:849
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
A PrefsPanel for general GUI preferences.
Definition: GUIPrefs.h:26
int mDefaultRangeIndex
Definition: GUIPrefs.h:51
GUIPrefs(wxWindow *parent, wxWindowID winid)
Definition: GUIPrefs.cpp:37
wxArrayStringEx mRangeCodes
Definition: GUIPrefs.h:49
TranslatableString GetDescription() const override
Definition: GUIPrefs.cpp:53
wxArrayStringEx mLangCodes
Definition: GUIPrefs.h:46
void PopulateOrExchange(ShuttleGui &S) override
Definition: GUIPrefs.cpp:140
~GUIPrefs()
Definition: GUIPrefs.cpp:44
ComponentInterfaceSymbol GetSymbol() const override
Definition: GUIPrefs.cpp:48
bool Commit() override
Definition: GUIPrefs.cpp:219
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:63
TranslatableStrings mLangNames
Definition: GUIPrefs.h:47
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
Definition: GUIPrefs.cpp:58
void Populate()
Definition: GUIPrefs.cpp:100
TranslatableStrings mRangeChoices
Definition: GUIPrefs.h:50
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
void DeleteUnusedThemes()
static bool LoadPreferredTheme()
Definition: Theme.cpp:162
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
iterator insert(const_iterator pos, std::initializer_list< T > items)
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...
AUDACITY_DLL_API wxString SetLang(const wxString &lang)
Definition: GUISettings.cpp:19
void GetLanguages(FilePaths pathList, wxArrayString &langCodes, TranslatableStrings &langNames)
Definition: Languages.cpp:140
PrefsPanel::Registration sAttachment
Definition: GUIPrefs.cpp:258