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#include <mutex> // once_flag
25
26#include "FileNames.h"
27#include "Languages.h"
28#include "Theme.h"
29#include "Prefs.h"
30#include "ShuttleGui.h"
31
32#include "Decibels.h"
33#include "Beats.h"
34
35#include "ThemePrefs.h"
36#include "AColor.h"
37#include "GUISettings.h"
38
39GUIPrefs::GUIPrefs(wxWindow * parent, wxWindowID winid)
40/* i18n-hint: refers to Audacity's user interface settings */
41: PrefsPanel(parent, winid, XC("Interface", "GUI"))
42{
43 Populate();
44}
45
47{
48}
49
51{
53}
54
56{
57 return XO("Preferences for GUI");
58}
59
61{
62 return "Interface_Preferences";
63}
64
66 TranslatableStrings *pChoices,
67 wxArrayStringEx *pCodes,
68 int *pDefaultRangeIndex
69)
70{
71 static const wxArrayStringEx sCodes = {
72 wxT("36") ,
73 wxT("48") ,
74 wxT("60") ,
75 wxT("72") ,
76 wxT("84") ,
77 wxT("96") ,
78 wxT("120") ,
79 wxT("145") ,
80 };
81 if (pCodes)
82 *pCodes = sCodes;
83
84 static const std::initializer_list<TranslatableString> sChoices = {
85 XO("-36 dB (shallow range for high-amplitude editing)") ,
86 XO("-48 dB (PCM range of 8 bit samples)") ,
87 XO("-60 dB (PCM range of 10 bit samples)") ,
88 XO("-72 dB (PCM range of 12 bit samples)") ,
89 XO("-84 dB (PCM range of 14 bit samples)") ,
90 XO("-96 dB (PCM range of 16 bit samples)") ,
91 XO("-120 dB (approximate limit of human hearing)") ,
92 XO("-145 dB (PCM range of 24 bit samples)") ,
93 };
94
95 if (pChoices)
96 *pChoices = sChoices;
97
98 if (pDefaultRangeIndex)
99 *pDefaultRangeIndex = 2; // 60 == ENV_DB_RANGE
100}
101
103{
104 // First any pre-processing for constructing the GUI.
107
109
110#if 0
112 // only for testing...
113 "kg" ,
114 "ep" ,
115 } );
116
117 mLangNames.insert( mLangNames.end(), {
118 "Klingon" ,
119 "Esperanto" ,
120 } );
121#endif
122
123 //------------------------- Main section --------------------
124 // Now construct the GUI itself.
125 // Use 'eIsCreatingFromPrefs' so that the GUI is
126 // initialised with values from gPrefs.
129 // ----------------------- End of main section --------------
130}
131
133{
134 ChoiceSetting LanguageSetting{ wxT("/Locale/Language"),
136 };
140 };
141
142 S.SetBorder(2);
143 S.StartScroller();
144
145 S.StartStatic(XO("Display"));
146 {
147 S.StartMultiColumn(2);
148 {
149 S.TieChoice( XXO("&Language:"), LanguageSetting);
150 // S.TieChoice( XXO("Location of &Manual:"), GUIManualLocation);
151 S.TieChoice( XXO("Th&eme:"), GUITheme());
152 S.TieChoice( XXO("Meter dB &range:"), DBSetting);
153 }
154 S.EndMultiColumn();
155 }
156 S.EndStatic();
157
158 S.StartStatic(XO("Options"));
159 {
160 // Start wording of options with a verb, if possible.
161 S.TieCheckBox(XXO("Show 'How to Get &Help' at launch"),
162 {wxT("/GUI/ShowSplashScreen"),
163 true});
164 S.TieCheckBox(XXO("Show e&xtra menus"),
165 {wxT("/GUI/ShowExtraMenus"),
166 false});
167#ifdef EXPERIMENTAL_THEME_PREFS
168 // We do not want to make this option mainstream. It's a
169 // convenience for developers.
170 S.TieCheckBox(XXO("Show alternative &styling (Mac vs PC)"),
171 {wxT("/GUI/ShowMac"),
172 false});
173#endif
174 S.TieCheckBox(XXO("&Beep on completion of longer activities"),
175 {wxT("/GUI/BeepOnCompletion"),
176 false});
177 S.TieCheckBox(XXO("Re&tain labels if selection snaps to a label"),
178 {wxT("/GUI/RetainLabels"),
179 false});
180 S.TieCheckBox(XXO("B&lend system and Audacity theme"),
182#ifndef __WXMAC__
183 /* i18n-hint: RTL stands for 'Right to Left' */
184 S.TieCheckBox(XXO("Use mostly Left-to-Right layouts in RTL languages"),
185 {"/GUI/RtlWorkaround",
186 true});
187#endif
188#ifdef EXPERIMENTAL_CEE_NUMBERS_OPTION
189 S.TieCheckBox(XXO("Never use comma as decimal point"),
190 {wxT("/Locale/CeeNumberFormat"),
191 false});
192#endif
193 }
194 S.EndStatic();
195
196 S.EndScroller();
197}
198
200{
203
204 // If language has changed, we want to change it now, not on the next reboot.
205 wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
206 wxString usedLang = GUISettings::SetLang(lang);
207 // Bug 1523: Previously didn't check no-language (=System Language)
208 if (!(lang.empty() || lang == L"System") && (lang != usedLang)) {
209 // lang was not usable and is not system language. We got overridden.
210 gPrefs->Write(wxT("/Locale/Language"), usedLang);
211 gPrefs->Flush();
212 }
213
214 // Reads preference GUITheme
215 {
216 wxBusyCursor busy;
219 }
221
224
225 return true;
226}
227
229{
230 static int value = wxNewId();
231 return value;
232}
233
235{
236 static int value = wxNewId();
237 return value;
238}
239
240namespace{
242 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
243 {
244 wxASSERT(parent); // to justify safenew
245 return safenew GUIPrefs(parent, winid);
246 }
247};
248}
wxT("CloseDown"))
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
int ShowTrackNameInWaveformPrefsID()
Definition: GUIPrefs.cpp:234
int ShowClippingPrefsID()
Definition: GUIPrefs.cpp:228
#define GUI_PREFS_PLUGIN_SYMBOL
Definition: GUIPrefs.h:23
#define XC(s, c)
Definition: Internat.h:37
#define safenew
Definition: MemoryX.h:9
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
ByColumns_t ByColumns
Definition: Prefs.cpp:515
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
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:860
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
A PrefsPanel for general GUI preferences.
Definition: GUIPrefs.h:26
int mDefaultRangeIndex
Definition: GUIPrefs.h:51
GUIPrefs(wxWindow *parent, wxWindowID winid)
Definition: GUIPrefs.cpp:39
wxArrayStringEx mRangeCodes
Definition: GUIPrefs.h:49
TranslatableString GetDescription() const override
Definition: GUIPrefs.cpp:55
wxArrayStringEx mLangCodes
Definition: GUIPrefs.h:46
void PopulateOrExchange(ShuttleGui &S) override
Definition: GUIPrefs.cpp:132
~GUIPrefs()
Definition: GUIPrefs.cpp:46
ComponentInterfaceSymbol GetSymbol() const override
Definition: GUIPrefs.cpp:50
bool Commit() override
Definition: GUIPrefs.cpp:199
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:65
TranslatableStrings mLangNames
Definition: GUIPrefs.h:47
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
Definition: GUIPrefs.cpp:60
void Populate()
Definition: GUIPrefs.cpp:102
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
void Invalidate() override
Definition: Prefs.h:289
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
void DeleteUnusedThemes()
static bool LoadPreferredTheme()
Definition: Theme.cpp:162
Holds a msgid for the translation catalog; may also bind format arguments.
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
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:241