Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
GUIPrefs Class Referencefinal

A PrefsPanel for general GUI preferences. More...

#include <GUIPrefs.h>

Inheritance diagram for GUIPrefs:
[legend]
Collaboration diagram for GUIPrefs:
[legend]

Public Member Functions

 GUIPrefs (wxWindow *parent, wxWindowID winid)
 
 ~GUIPrefs ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool Commit () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static void GetRangeChoices (TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
 
static wxString SetLang (const wxString &lang)
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Private Member Functions

void Populate ()
 

Private Attributes

wxArrayStringEx mLangCodes
 
TranslatableStrings mLangNames
 
wxArrayStringEx mRangeCodes
 
TranslatableStrings mRangeChoices
 
int mDefaultRangeIndex
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 

Detailed Description

A PrefsPanel for general GUI preferences.

Definition at line 25 of file GUIPrefs.h.

Constructor & Destructor Documentation

◆ GUIPrefs()

GUIPrefs::GUIPrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 38 of file GUIPrefs.cpp.

40 : PrefsPanel(parent, winid, XC("Interface", "GUI"))
41 {
42  Populate();
43 }

References Populate().

Here is the call graph for this function:

◆ ~GUIPrefs()

GUIPrefs::~GUIPrefs ( )

Definition at line 45 of file GUIPrefs.cpp.

46 {
47 }

Member Function Documentation

◆ Commit()

bool GUIPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 234 of file GUIPrefs.cpp.

235 {
236  ShuttleGui S(this, eIsSavingToPrefs);
238 
239  // If language has changed, we want to change it now, not on the next reboot.
240  wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
241  wxString usedLang = SetLang(lang);
242  // Bug 1523: Previously didn't check no-language (=System Language)
243  if (!(lang.empty() || lang == L"System") && (lang != usedLang)) {
244  // lang was not usable and is not system language. We got overridden.
245  gPrefs->Write(wxT("/Locale/Language"), usedLang);
246  gPrefs->Flush();
247  }
248 
249  // Reads preference GUITheme
252 
253  return true;
254 }

References ThemePrefs::ApplyUpdatedImages(), eIsSavingToPrefs, FileConfig::Flush(), gPrefs, ThemeBase::LoadPreferredTheme(), PopulateOrExchange(), SetLang(), and theTheme.

Here is the call graph for this function:

◆ GetDescription()

TranslatableString GUIPrefs::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 54 of file GUIPrefs.cpp.

55 {
56  return XO("Preferences for GUI");
57 }

References XO.

◆ GetRangeChoices()

void GUIPrefs::GetRangeChoices ( TranslatableStrings pChoices,
wxArrayStringEx pCodes,
int *  pDefaultRangeIndex = nullptr 
)
static

Definition at line 64 of file GUIPrefs.cpp.

69 {
70  static const auto sCodes = {
71  wxT("36") ,
72  wxT("48") ,
73  wxT("60") ,
74  wxT("72") ,
75  wxT("84") ,
76  wxT("96") ,
77  wxT("120") ,
78  wxT("145") ,
79  };
80  if (pCodes)
81  *pCodes = sCodes;
82 
83  static const std::initializer_list<TranslatableString> sChoices = {
84  XO("-36 dB (shallow range for high-amplitude editing)") ,
85  XO("-48 dB (PCM range of 8 bit samples)") ,
86  XO("-60 dB (PCM range of 10 bit samples)") ,
87  XO("-72 dB (PCM range of 12 bit samples)") ,
88  XO("-84 dB (PCM range of 14 bit samples)") ,
89  XO("-96 dB (PCM range of 16 bit samples)") ,
90  XO("-120 dB (approximate limit of human hearing)") ,
91  XO("-145 dB (PCM range of 24 bit samples)") ,
92  };
93 
94  if (pChoices)
95  *pChoices = sChoices;
96 
97  if (pDefaultRangeIndex)
98  *pDefaultRangeIndex = 2; // 60 == ENV_DB_RANGE
99 }

References XO.

Referenced by WaveformSettings::ConvertToActualDBRange(), WaveformSettings::ConvertToEnumeratedDBRange(), Populate(), and WaveformPrefs::Populate().

Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol GUIPrefs::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 49 of file GUIPrefs.cpp.

50 {
52 }

References GUI_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID GUIPrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 59 of file GUIPrefs.cpp.

60 {
61  return "Interface_Preferences";
62 }

◆ Populate()

void GUIPrefs::Populate ( )
private

Definition at line 101 of file GUIPrefs.cpp.

102 {
103  // First any pre-processing for constructing the GUI.
106 
108 
109 #if 0
110  mLangCodes.insert( mLangCodes.end(), {
111  // only for testing...
112  "kg" ,
113  "ep" ,
114  } );
115 
116  mLangNames.insert( mLangNames.end(), {
117  "Klingon" ,
118  "Esperanto" ,
119  } );
120 #endif
121 
122  //------------------------- Main section --------------------
123  // Now construct the GUI itself.
124  // Use 'eIsCreatingFromPrefs' so that the GUI is
125  // initialised with values from gPrefs.
128  // ----------------------- End of main section --------------
129 }

References FileNames::AudacityPathList(), eIsCreatingFromPrefs, Languages::GetLanguages(), GetRangeChoices(), wxArrayStringEx::insert(), mDefaultRangeIndex, mLangCodes, mLangNames, mRangeChoices, mRangeCodes, and PopulateOrExchange().

Referenced by GUIPrefs().

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

◆ PopulateOrExchange()

void GUIPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 141 of file GUIPrefs.cpp.

142 {
143  S.SetBorder(2);
144  S.StartScroller();
145 
146  S.StartStatic(XO("Display"));
147  {
148  S.StartMultiColumn(2);
149  {
150 
151  S.TieChoice( XXO("&Language:"),
152  {
153  wxT("/Locale/Language"),
155  }
156  );
157 
158  S.TieChoice( XXO("Location of &Manual:"), GUIManualLocation);
159 
160  S.TieChoice( XXO("Th&eme:"), GUITheme);
161 
162  S.TieChoice( XXO("Meter dB &range:"),
163  {
167  }
168  );
169  }
170  S.EndMultiColumn();
171 // S.AddSpace(10);
172 // JKC: This is a silly preference. Kept here as a reminder that we may
173 // later want to have configurable button order.
174 // S.TieCheckBox(XXO("&Ergonomic order of Transport Toolbar buttons"),
175 // wxT("/GUI/ErgonomicTransportButtons"),
176 // true);
177 
178  }
179  S.EndStatic();
180 
181  S.StartStatic(XO("Options"));
182  {
183  // Start wording of options with a verb, if possible.
184  S.TieCheckBox(XXO("Show 'How to Get &Help' at launch"),
185  {wxT("/GUI/ShowSplashScreen"),
186  true});
187  S.TieCheckBox(XXO("Show e&xtra menus"),
188  {wxT("/GUI/ShowExtraMenus"),
189  false});
190 #ifdef EXPERIMENTAL_THEME_PREFS
191  // We do not want to make this option mainstream. It's a
192  // convenience for developers.
193  S.TieCheckBox(XXO("Show alternative &styling (Mac vs PC)"),
194  {wxT("/GUI/ShowMac"),
195  false});
196 #endif
197  S.TieCheckBox(XXO("&Beep on completion of longer activities"),
198  {wxT("/GUI/BeepOnCompletion"),
199  false});
200  S.TieCheckBox(XXO("Re&tain labels if selection snaps to a label"),
201  {wxT("/GUI/RetainLabels"),
202  false});
203  S.TieCheckBox(XXO("B&lend system and Audacity theme"),
204  {wxT("/GUI/BlendThemes"),
205  true});
206 #ifndef __WXMAC__
207  /* i18n-hint: RTL stands for 'Right to Left' */
208  S.TieCheckBox(XXO("Use mostly Left-to-Right layouts in RTL languages"),
209  {"/GUI/RtlWorkaround",
210  true});
211 #endif
212 #ifdef EXPERIMENTAL_CEE_NUMBERS_OPTION
213  S.TieCheckBox(XXO("Never use comma as decimal point"),
214  {wxT("/Locale/CeeNumberFormat"),
215  false});
216 #endif
217  }
218  S.EndStatic();
219 
220  S.StartStatic(XO("Timeline"));
221  {
222  S.TieCheckBox(XXO("Show Timeline Tooltips"),
223  {wxT("/QuickPlay/ToolTips"),
224  true});
225  S.TieCheckBox(XXO("Show Scrub Ruler"),
226  {wxT("/QuickPlay/ScrubbingEnabled"),
227  false});
228  }
229  S.EndStatic();
230 
231  S.EndScroller();
232 }

References ByColumns, DecibelScaleCutoff, ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), SettingBase::GetPath(), GUIManualLocation, GUITheme, mDefaultRangeIndex, mLangCodes, mLangNames, mRangeChoices, mRangeCodes, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::TieCheckBox(), ShuttleGuiBase::TieChoice(), XO, and XXO.

Referenced by Commit(), and Populate().

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

◆ SetLang()

wxString GUIPrefs::SetLang ( const wxString &  lang)
static

Definition at line 256 of file GUIPrefs.cpp.

257 {
258  auto result = Languages::SetLang(FileNames::AudacityPathList(), lang);
259  if (!(lang.empty() || lang == L"System") && result != lang)
261  XO("Language \"%s\" is unknown").Format( lang ) );
262 
263 #ifdef EXPERIMENTAL_CEE_NUMBERS_OPTION
264  bool forceCeeNumbers;
265  gPrefs->Read(wxT("/Locale/CeeNumberFormat"), &forceCeeNumbers, false);
266  if( forceCeeNumbers )
268 #endif
269 
270 #ifdef __WXMAC__
271  wxApp::s_macHelpMenuTitleName = _("&Help");
272 #endif
273 
274  return result;
275 }

References _, AudacityMessageBox(), FileNames::AudacityPathList(), gPrefs, Internat::SetCeeNumberFormat(), Languages::SetLang(), and XO.

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

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

Member Data Documentation

◆ mDefaultRangeIndex

int GUIPrefs::mDefaultRangeIndex
private

Definition at line 55 of file GUIPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

◆ mLangCodes

wxArrayStringEx GUIPrefs::mLangCodes
private

Definition at line 50 of file GUIPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

◆ mLangNames

TranslatableStrings GUIPrefs::mLangNames
private

Definition at line 51 of file GUIPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

◆ mRangeChoices

TranslatableStrings GUIPrefs::mRangeChoices
private

Definition at line 54 of file GUIPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

◆ mRangeCodes

wxArrayStringEx GUIPrefs::mRangeCodes
private

Definition at line 53 of file GUIPrefs.h.

Referenced by Populate(), and PopulateOrExchange().


The documentation for this class was generated from the following files:
GUIPrefs::mLangNames
TranslatableStrings mLangNames
Definition: GUIPrefs.h:51
GUIPrefs::mDefaultRangeIndex
int mDefaultRangeIndex
Definition: GUIPrefs.h:55
GUITheme
ChoiceSetting GUITheme
Definition: Theme.cpp:1314
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
GUIPrefs::mRangeCodes
wxArrayStringEx mRangeCodes
Definition: GUIPrefs.h:53
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
SettingBase::GetPath
const wxString & GetPath() const
Definition: Prefs.h:75
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
Format
Abstract base class used in importing a file.
GUI_PREFS_PLUGIN_SYMBOL
#define GUI_PREFS_PLUGIN_SYMBOL
Definition: GUIPrefs.h:23
XO
#define XO(s)
Definition: Internat.h:31
XC
#define XC(s, c)
Definition: Internat.h:37
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
GUIPrefs::SetLang
static wxString SetLang(const wxString &lang)
Definition: GUIPrefs.cpp:256
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
wxArrayStringEx::insert
iterator insert(const_iterator pos, std::initializer_list< T > items)
Definition: wxArrayStringEx.h:58
GUIPrefs::GetRangeChoices
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:64
GUIPrefs::mRangeChoices
TranslatableStrings mRangeChoices
Definition: GUIPrefs.h:54
DecibelScaleCutoff
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
GUIPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: GUIPrefs.cpp:141
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:48
GUIPrefs::mLangCodes
wxArrayStringEx mLangCodes
Definition: GUIPrefs.h:50
Languages::GetLanguages
void GetLanguages(FilePaths pathList, wxArrayString &langCodes, TranslatableStrings &langNames)
Definition: Languages.cpp:137
ThemePrefs::ApplyUpdatedImages
static void ApplyUpdatedImages()
Definition: ThemePrefs.cpp:215
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
GUIPrefs::Populate
void Populate()
Definition: GUIPrefs.cpp:101
FileNames::AudacityPathList
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...
GUIManualLocation
ChoiceSetting GUIManualLocation
Definition: GUIPrefs.cpp:131
_
#define _(s)
Definition: Internat.h:75
Internat::SetCeeNumberFormat
static void SetCeeNumberFormat()
Definition: Internat.cpp:122
theTheme
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:203
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
ByColumns
ByColumns_t ByColumns
Definition: Prefs.cpp:420
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
ThemeBase::LoadPreferredTheme
static bool LoadPreferredTheme()
Definition: Theme.cpp:231
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
Languages::SetLang
wxString SetLang(const FilePaths &pathList, const wxString &lang)
Definition: Languages.cpp:324
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1727
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90