From 4c5913a39926180aacaefd637b6acf2fa4e757c7 Mon Sep 17 00:00:00 2001 From: Dmitry Vedenko Date: Wed, 21 Jul 2021 17:28:34 +0300 Subject: [PATCH] Adds Privacy Policy links to error reporting dialogs. Also, adds ability to disable the comments box --- crashreports/crashreporter/CrashReportApp.cpp | 55 +++++++++++++++++-- src/widgets/ErrorReportDialog.cpp | 34 +++++++++--- 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/crashreports/crashreporter/CrashReportApp.cpp b/crashreports/crashreporter/CrashReportApp.cpp index 16f0a64eb..214181517 100644 --- a/crashreports/crashreporter/CrashReportApp.cpp +++ b/crashreports/crashreporter/CrashReportApp.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/minidump_processor.h" @@ -91,6 +93,8 @@ namespace #endif +constexpr bool CrashReportAppHasUserComment = false; + IMPLEMENT_APP(CrashReportApp); namespace { @@ -287,7 +291,8 @@ namespace auto buttonsLayout = new wxBoxSizer(wxHORIZONTAL); wxTextCtrl* commentCtrl = nullptr; - if (onSend != nullptr) + + if (onSend != nullptr && CrashReportAppHasUserComment) { mainLayout->AddSpacer(10); mainLayout->Add(new wxStaticText(dialog, wxID_ANY, _("Comments")), wxSizerFlags().Border(wxALL)); @@ -298,8 +303,45 @@ namespace mainLayout->Add(commentCtrl, wxSizerFlags().Border(wxALL).Expand()); } - if (onSend != nullptr && commentCtrl != nullptr) + if (onSend != nullptr) { + /* i18n-hint: %s will be replaced with "our Privacy Policy" */ + const wxString translatedText = _("See %s for more info."); + + /* i18n-hint: Title of hyperlink to the privacy policy. This is an + object of "See". */ + const wxString translatedLink = _("our Privacy Policy"); + + const size_t placeholderPosition = translatedText.Find(wxT("%s")); + + if (placeholderPosition != wxString::npos) + { + auto privacyPolicyLayout = new wxWrapSizer(); + + privacyPolicyLayout->Add( + new wxStaticText(dialog, wxID_ANY, translatedText.substr(0, placeholderPosition)), + wxSizerFlags().Proportion(0).Border(wxUP | wxDOWN)); + + privacyPolicyLayout->Add( + new wxHyperlinkCtrl( + dialog, wxID_ANY, translatedLink, + "https://www.audacityteam.org/about/desktop-privacy-notice/"), + wxSizerFlags().Proportion(0).Border(wxUP | wxDOWN)); + + if (placeholderPosition + 2 < translatedText.Length()) + { + privacyPolicyLayout->Add( + new wxStaticText( + dialog, wxID_ANY, + translatedText.substr(placeholderPosition + 2)), + wxSizerFlags().Proportion(1).Border(wxUP | wxDOWN)); + } + + mainLayout->Add( + privacyPolicyLayout, wxSizerFlags().Border(wxALL)); + } + + auto dontSendButton = new wxButton(dialog, wxID_ANY, XC("&Don't send", "crash reporter button")); auto sendButton = new wxButton(dialog, wxID_ANY, XC("&Send", "crash reporter button")); @@ -308,8 +350,13 @@ namespace dialog->Close(true); }); sendButton->Bind(wxEVT_BUTTON, [dialog, commentCtrl, onSend](wxCommandEvent&) - { - if (onSend(commentCtrl->GetValue())) + { + const wxString comment = + commentCtrl != nullptr ? + commentCtrl->GetValue() : + wxString {}; + + if (onSend(comment)) { dialog->Close(true); } diff --git a/src/widgets/ErrorReportDialog.cpp b/src/widgets/ErrorReportDialog.cpp index d8ba15635..c7fc15fff 100644 --- a/src/widgets/ErrorReportDialog.cpp +++ b/src/widgets/ErrorReportDialog.cpp @@ -26,6 +26,7 @@ #include #include +#include "ui/AccessibleLinksFormatter.h" #include "AllThemeResources.h" #include "Theme.h" #include "HelpText.h" @@ -37,6 +38,7 @@ #include "CodeConversions.h" constexpr int MaxUserCommentLength = 2000; +constexpr bool ErrorReportDialogHasUserComment = false; BEGIN_EVENT_TABLE(ErrorReportDialog, wxDialogWrapper) EVT_BUTTON(wxID_YES, ErrorReportDialog::OnSend) @@ -123,18 +125,34 @@ ErrorReportDialog::ErrorReportDialog( S.AddSpace(0, 20); - S.AddVariableText(XO("Comments"))->SetFont(textFont); + if constexpr (ErrorReportDialogHasUserComment) + { + S.AddVariableText(XO("Comments"))->SetFont(textFont); - S.AddSpace(0, 6); + S.AddSpace(0, 6); - mCommentsControl = S.Style(wxTE_MULTILINE) - .MinSize(wxSize(0, 76)) - .Name(XO("Comments")) - .AddTextBox({}, {}, 0); + mCommentsControl = S.Style(wxTE_MULTILINE) + .MinSize(wxSize(0, 76)) + .Name(XO("Comments")) + .AddTextBox({}, {}, 0); - mCommentsControl->SetMaxLength(MaxUserCommentLength); + mCommentsControl->SetMaxLength(MaxUserCommentLength); - S.AddSpace(0, 20); + S.AddSpace(0, 20); + } + + /* i18n-hint: %s will be replaced with "our Privacy Policy" */ + AccessibleLinksFormatter privacyPolicy(XO("See %s for more info.")); + + privacyPolicy.FormatLink( + /* i18n-hint: Title of hyperlink to the privacy policy. This is an + object of "See". */ + wxT("%s"), XO("our Privacy Policy"), + "https://www.audacityteam.org/about/desktop-privacy-notice/"); + + privacyPolicy.Populate(S); + + S.AddSpace(0, 20); S.StartHorizontalLay(wxEXPAND); {