1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 08:29:27 +02:00

Adds Privacy Policy links to error reporting dialogs.

Also, adds ability to disable the comments box
This commit is contained in:
Dmitry Vedenko 2021-07-21 17:28:34 +03:00
parent 186df73482
commit 4c5913a399
2 changed files with 77 additions and 12 deletions

View File

@ -8,6 +8,8 @@
#include <wx/artprov.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>
#include <wx/wrapsizer.h>
#include <wx/hyperlink.h>
#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);
}

View File

@ -26,6 +26,7 @@
#include <wx/textctrl.h>
#include <wx/bmpbuttn.h>
#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);
{