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

A dialog used (at start up) to present the user with a choice of languages for Audacity. More...

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

Public Member Functions

 LangChoiceDialog (wxWindow *parent, wxWindowID id, const TranslatableString &title)
 
wxString GetLang ()
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void OnOk (wxCommandEvent &event)
 

Private Attributes

wxChoice * mChoice
 
wxString mLang
 
int mNumLangs
 
wxArrayString mLangCodes
 
TranslatableStrings mLangNames
 

Detailed Description

A dialog used (at start up) to present the user with a choice of languages for Audacity.

Definition at line 33 of file LangChoice.cpp.

Constructor & Destructor Documentation

◆ LangChoiceDialog()

LangChoiceDialog::LangChoiceDialog ( wxWindow *  parent,
wxWindowID  id,
const TranslatableString title 
)

Definition at line 72 of file LangChoice.cpp.

74  :
75  wxDialogWrapper(parent, id, title)
76 {
77  SetName();
78  const auto &paths = FileNames::AudacityPathList();
80  int lang = make_iterator_range( mLangCodes )
81  .index( Languages::GetSystemLanguageCode(paths) );
82 
83  ShuttleGui S(this, eIsCreating);
84 
85  S.StartVerticalLay(false);
86  {
87  S.StartHorizontalLay();
88  {
89  S.SetBorder(15);
90  mChoice = S.AddChoice(XXO("Choose Language for Audacity to use:"),
91  mLangNames,
92  lang);
93  }
94  S.EndVerticalLay();
95 
96  S.SetBorder(0);
97  S.AddStandardButtons(eOkButton);
98  }
99  S.EndVerticalLay();
100 
101  Fit();
102 }

References ShuttleGuiBase::AddChoice(), ShuttleGui::AddStandardButtons(), FileNames::AudacityPathList(), eIsCreating, ShuttleGuiBase::EndVerticalLay(), eOkButton, Languages::GetLanguages(), Languages::GetSystemLanguageCode(), make_iterator_range(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartVerticalLay(), and XXO.

Here is the call graph for this function:

Member Function Documentation

◆ GetLang()

wxString LangChoiceDialog::GetLang ( )
inline

Definition at line 39 of file LangChoice.cpp.

39 { return mLang; }

References mLang.

Referenced by ChooseLanguage().

Here is the caller graph for this function:

◆ OnOk()

void LangChoiceDialog::OnOk ( wxCommandEvent &  event)
private

Definition at line 104 of file LangChoice.cpp.

105 {
106  int ndx = mChoice->GetSelection();
107  mLang = mLangCodes[ndx];
108 
109  auto slang =
111  int sndx = make_iterator_range( mLangCodes ).index( slang );
112  wxString sname;
113 
114  if (sndx == wxNOT_FOUND) {
115  const wxLanguageInfo *sinfo = wxLocale::FindLanguageInfo(slang);
116  if (sinfo) {
117  sname = sinfo->Description;
118  }
119  }
120  else {
121  sname = mLangNames[sndx].Translation();
122  }
123 
124  if (mLang.Left(2) != slang.Left(2)) {
125  /* i18n-hint: The %s's are replaced by translated and untranslated
126  * versions of language names. */
127  auto msg = XO("The language you have chosen, %s (%s), is not the same as the system language, %s (%s).")
128  .Format(mLangNames[ndx],
129  mLang,
130  sname,
131  slang);
132  if ( wxNO == AudacityMessageBox( msg, XO("Confirm"), wxYES_NO ) ) {
133  return;
134  }
135  }
136 
137  EndModal(true);
138 }

References AudacityMessageBox(), FileNames::AudacityPathList(), Languages::GetSystemLanguageCode(), make_iterator_range(), mChoice, mLang, mLangCodes, mLangNames, and XO.

Here is the call graph for this function:

Member Data Documentation

◆ mChoice

wxChoice* LangChoiceDialog::mChoice
private

Definition at line 44 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLang

wxString LangChoiceDialog::mLang
private

Definition at line 45 of file LangChoice.cpp.

Referenced by GetLang(), and OnOk().

◆ mLangCodes

wxArrayString LangChoiceDialog::mLangCodes
private

Definition at line 48 of file LangChoice.cpp.

Referenced by OnOk().

◆ mLangNames

TranslatableStrings LangChoiceDialog::mLangNames
private

Definition at line 49 of file LangChoice.cpp.

Referenced by OnOk().

◆ mNumLangs

int LangChoiceDialog::mNumLangs
private

Definition at line 47 of file LangChoice.cpp.


The documentation for this class was generated from the following file:
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
make_iterator_range
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:549
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
XO
#define XO(s)
Definition: Internat.h:31
XXO
#define XXO(s)
Definition: Internat.h:44
LangChoiceDialog::mLangCodes
wxArrayString mLangCodes
Definition: LangChoice.cpp:48
LangChoiceDialog::mChoice
wxChoice * mChoice
Definition: LangChoice.cpp:44
LangChoiceDialog::mLangNames
TranslatableStrings mLangNames
Definition: LangChoice.cpp:49
title
static const auto title
Definition: UpdateNoticeDialog.cpp:23
Languages::GetLanguages
void GetLanguages(FilePaths pathList, wxArrayString &langCodes, TranslatableStrings &langNames)
Definition: Languages.cpp:137
eOkButton
@ eOkButton
Definition: ShuttleGui.h:600
FileNames::AudacityPathList
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...
wxDialogWrapper::wxDialogWrapper
wxDialogWrapper()
Definition: wxPanelWrapper.h:84
Languages::GetSystemLanguageCode
wxString GetSystemLanguageCode(const FilePaths &pathList)
Definition: Languages.cpp:83
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
LangChoiceDialog::mLang
wxString mLang
Definition: LangChoice.cpp:45
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631