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

A dialog, that has "Send", "Don't send" and help buttons. More...

#include <ErrorReportDialog.h>

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

Public Member Functions

 ErrorReportDialog (wxWindow *parent, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpUrl, const wxString &log, const bool modal)
 
 ~ErrorReportDialog ()
 
- 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 OnSend (wxCommandEvent &event)
 
void OnDontSend (wxCommandEvent &event)
 
void OnHelp (wxCommandEvent &event)
 

Private Attributes

std::unique_ptr< audacity::sentry::ReportmReport
 
ManualPageID mHelpUrl
 
wxTextCtrl * mCommentsControl { nullptr }
 
bool mIsModal
 

Detailed Description

A dialog, that has "Send", "Don't send" and help buttons.

This dialog is used in place of error dialogs for Audacity errors when Sentry reporting is enabled.

Definition at line 35 of file ErrorReportDialog.h.

Constructor & Destructor Documentation

◆ ErrorReportDialog()

ErrorReportDialog::ErrorReportDialog ( wxWindow *  parent,
const TranslatableString dlogTitle,
const TranslatableString message,
const ManualPageID helpUrl,
const wxString &  log,
const bool  modal 
)

Definition at line 49 of file ErrorReportDialog.cpp.

54  parent, wxID_ANY, dlogTitle, wxDefaultPosition, wxDefaultSize,
55  wxDEFAULT_DIALOG_STYLE)
56  , mHelpUrl(helpUrl)
57  , mIsModal(modal)
58 {
60  audacity::ToUTF8(dlogTitle.Debug()),message.Debug());
61 
62  if (!log.empty())
63  ex.AddData("log", log);
64 
65  mReport = std::make_unique<audacity::sentry::Report> (ex);
66 
67  ShuttleGui S(this, eIsCreating);
68 
69  const wxFont headingFont = wxFont(wxFontInfo(12).Bold());
70  const wxFont textFont = wxFont(wxFontInfo(10));
71 
72  S.SetBorder(0);
73 
74  S.StartHorizontalLay(wxEXPAND, 0);
75  {
76  S.AddSpace(40, 0);
77  S.StartVerticalLay(wxEXPAND, 0);
78  {
79  S.AddSpace(0, 32);
80 
81  S.StartHorizontalLay(wxEXPAND, 1);
82  {
83  S.StartVerticalLay(0);
84  {
85  wxBitmap bitmap = wxArtProvider::GetBitmap(
86  wxART_WARNING, wxART_MESSAGE_BOX, wxSize(24, 24));
87 
88  S.Prop(0).AddWindow(
89  safenew wxStaticBitmap(S.GetParent(), -1, bitmap));
90 
91  S.AddSpace(0, 0, 1);
92  }
93  S.EndVerticalLay();
94 
95  S.AddSpace(10, 0);
96 
97  S.StartVerticalLay(0);
98  {
99  S.AddSpace(0, 7);
100 
101  S.Prop(1)
102  .AddVariableText(message, false, 0, 560)
103  ->SetFont(headingFont);
104  }
105  S.EndVerticalLay();
106  }
107  S.EndHorizontalLay();
108 
109  S.AddSpace(0, 20);
110 
111  S.AddVariableText(XO(
112  "Click \"Send\" to submit the report to Audacity. This information is collected anonymously."))
113  ->SetFont(textFont);
114 
115  S.AddSpace(0, 20);
116 
117  S.AddVariableText(XO("Problem details"))->SetFont(textFont);
118 
119  S.AddSpace(0, 6);
120 
121  S.Style(wxTE_RICH | wxTE_READONLY | wxTE_MULTILINE | wxTE_DONTWRAP)
122  .MinSize(wxSize(0, 152))
123  .Name(XO("Problem details"))
124  .AddTextBox({}, mReport->GetReportPreview(), 0);
125 
126  S.AddSpace(0, 20);
127 
128  if constexpr (ErrorReportDialogHasUserComment)
129  {
130  S.AddVariableText(XO("Comments"))->SetFont(textFont);
131 
132  S.AddSpace(0, 6);
133 
134  mCommentsControl = S.Style(wxTE_MULTILINE)
135  .MinSize(wxSize(0, 76))
136  .Name(XO("Comments"))
137  .AddTextBox({}, {}, 0);
138 
139  mCommentsControl->SetMaxLength(MaxUserCommentLength);
140 
141  S.AddSpace(0, 20);
142  }
143 
144  /* i18n-hint: %s will be replaced with "our Privacy Policy" */
145  AccessibleLinksFormatter privacyPolicy(XO("See %s for more info."));
146 
147  privacyPolicy.FormatLink(
148  /* i18n-hint: Title of hyperlink to the privacy policy. This is an
149  object of "See". */
150  wxT("%s"), XO("our Privacy Policy"),
151  "https://www.audacityteam.org/about/desktop-privacy-notice/");
152 
153  privacyPolicy.Populate(S);
154 
155  S.AddSpace(0, 20);
156 
157  S.StartHorizontalLay(wxEXPAND);
158  {
159  if (!mHelpUrl.empty())
160  {
161  wxBitmapButton* helpButton =
162  S.Id(wxID_HELP).AddBitmapButton(theTheme.Bitmap(bmpHelpIcon));
163  // For screen readers
164  helpButton->SetToolTip(XO("Help").Translation());
165  helpButton->SetLabel(XO("Help").Translation());
166  }
167 
168  S.AddSpace(0, 0, 1);
169 
170  S.Id(wxID_NO).AddButton(XC("&Don't send", "crash reporter button"));
171 
172  S.AddSpace(13, 0);
173 
174  S.Id(wxID_YES).AddButton(XC("&Send", "crash reporter button"));
175  }
176  S.EndHorizontalLay();
177 
178  S.AddSpace(0, 20);
179  }
180  S.EndVerticalLay();
181 
182  S.AddSpace(28, 0);
183  }
184  S.EndHorizontalLay();
185 
186  S.SetBorder(2);
187 
188  Layout();
189  GetSizer()->Fit(this);
190  SetMinSize(GetSize());
191  Center();
192 }

References ShuttleGuiBase::AddBitmapButton(), ShuttleGuiBase::AddButton(), audacity::sentry::Exception::AddData(), ShuttleGui::AddSpace(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddVariableText(), ShuttleGuiBase::AddWindow(), ThemeBase::Bitmap(), audacity::sentry::Exception::Create(), eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndVerticalLay(), ErrorReportDialogHasUserComment, AccessibleLinksFormatter::FormatLink(), ShuttleGuiBase::GetParent(), ShuttleGui::Id(), MaxUserCommentLength, ShuttleGui::MinSize(), ShuttleGui::Name(), AccessibleLinksFormatter::Populate(), ShuttleGui::Prop(), safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartVerticalLay(), ShuttleGui::Style(), theTheme, audacity::ToUTF8(), XC, and XO.

Here is the call graph for this function:

◆ ~ErrorReportDialog()

ErrorReportDialog::~ErrorReportDialog ( )

Definition at line 194 of file ErrorReportDialog.cpp.

195 {
196 }

Member Function Documentation

◆ OnDontSend()

void ErrorReportDialog::OnDontSend ( wxCommandEvent &  event)
private

Definition at line 213 of file ErrorReportDialog.cpp.

214 {
215  EndModal(true);
216 }

◆ OnHelp()

void ErrorReportDialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 218 of file ErrorReportDialog.cpp.

219 {
220  const auto &helpUrl = mHelpUrl.GET();
221  if (helpUrl.StartsWith(wxT("innerlink:")))
222  {
224  this, TitleText(helpUrl.Mid(10)), HelpText(helpUrl.Mid(10)), false,
225  true);
226  return;
227  }
228 
229  HelpSystem::ShowHelp(this, mHelpUrl, false);
230 }

References Identifier::GET(), HelpText(), mHelpUrl, HelpSystem::ShowHelp(), HelpSystem::ShowHtmlText(), and TitleText().

Here is the call graph for this function:

◆ OnSend()

void ErrorReportDialog::OnSend ( wxCommandEvent &  event)
private

Definition at line 198 of file ErrorReportDialog.cpp.

199 {
200  Disable();
201 
202  if (mCommentsControl != nullptr)
203  mReport->AddUserComment(audacity::ToUTF8(mCommentsControl->GetValue()));
204 
205  mReport->Send(
206  [this](int code, std::string body) {
207  CallAfter([this]() {
208  EndModal(true);
209  });
210  });
211 }

References BasicUI::CallAfter(), mCommentsControl, mReport, and audacity::ToUTF8().

Here is the call graph for this function:

Member Data Documentation

◆ mCommentsControl

wxTextCtrl* ErrorReportDialog::mCommentsControl { nullptr }
private

Definition at line 55 of file ErrorReportDialog.h.

Referenced by OnSend().

◆ mHelpUrl

ManualPageID ErrorReportDialog::mHelpUrl
private

Definition at line 53 of file ErrorReportDialog.h.

Referenced by OnHelp().

◆ mIsModal

bool ErrorReportDialog::mIsModal
private

Definition at line 57 of file ErrorReportDialog.h.

◆ mReport

std::unique_ptr<audacity::sentry::Report> ErrorReportDialog::mReport
private

Definition at line 51 of file ErrorReportDialog.h.

Referenced by OnSend().


The documentation for this class was generated from the following files:
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
XO
#define XO(s)
Definition: Internat.h:31
XC
#define XC(s, c)
Definition: Internat.h:37
TranslatableString::Debug
wxString Debug() const
Format as an English string for debugging logs and developers' eyes, not for end users.
Definition: TranslatableString.h:82
BasicUI::CallAfter
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:38
ErrorReportDialog::mCommentsControl
wxTextCtrl * mCommentsControl
Definition: ErrorReportDialog.h:55
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
ErrorReportDialog::mIsModal
bool mIsModal
Definition: ErrorReportDialog.h:57
ThemeBase::Bitmap
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1209
ErrorReportDialog::mHelpUrl
ManualPageID mHelpUrl
Definition: ErrorReportDialog.h:53
HelpSystem::ShowHtmlText
static void ShowHtmlText(wxWindow *pParent, const TranslatableString &Title, const wxString &HtmlText, bool bIsFile=false, bool bModal=false)
Definition: HelpSystem.cpp:125
ErrorReportDialog::mReport
std::unique_ptr< audacity::sentry::Report > mReport
Definition: ErrorReportDialog.h:51
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
Identifier::GET
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
MaxUserCommentLength
constexpr int MaxUserCommentLength
Definition: ErrorReportDialog.cpp:40
audacity::sentry::Exception::Create
static Exception Create(std::string type, AnonymizedMessage value)
Create a new exception.
Definition: SentryReport.cpp:224
wxDialogWrapper::wxDialogWrapper
wxDialogWrapper()
Definition: wxPanelWrapper.h:84
audacity::sentry::Exception
A DTO for the Sentry Exception interface.
Definition: SentryReport.h:31
HelpText
AUDACITY_DLL_API wxString HelpText(const wxString &Key)
safenew
#define safenew
Definition: MemoryX.h:10
audacity::ToUTF8
std::string ToUTF8(const std::wstring &wstr)
Definition: CodeConversions.cpp:19
TitleText
AUDACITY_DLL_API TranslatableString TitleText(const wxString &Key)
audacity::sentry::Exception::AddData
Exception & AddData(std::string key, AnonymizedMessage value)
Add a payload to the exception.
Definition: SentryReport.cpp:238
Identifier::empty
bool empty() const
Definition: Identifier.h:61
ErrorReportDialogHasUserComment
constexpr bool ErrorReportDialogHasUserComment
Definition: ErrorReportDialog.cpp:41
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631