Audacity 3.2.0
|
A class that allows translatable text to have accessible links in it in a way that is friendly to translators. More...
#include <AccessibleLinksFormatter.h>
Classes | |
struct | FormatArgument |
struct | ProcessedArgument |
Public Types | |
using | LinkClickedHandler = std::function< void()> |
Handler to be called, when the Link is activated. More... | |
Public Member Functions | |
AccessibleLinksFormatter (TranslatableString message) | |
Create AccessibleLinksFormatter using a TranslatableString. More... | |
AccessibleLinksFormatter & | FormatLink (wxString placeholder, TranslatableString value, std::string targetURL) |
Replace placeholder with a link, that will open URL in default browser. More... | |
AccessibleLinksFormatter & | FormatLink (wxString placeholder, TranslatableString value, LinkClickedHandler handler) |
Replace placeholder with a link, that will call a callback provided. More... | |
void | Populate (ShuttleGui &S) const |
Generate the UI. More... | |
Private Member Functions | |
std::vector< ProcessedArgument > | ProcessArguments (wxString translatedMessage) const |
Private Attributes | |
TranslatableString | mMessage |
std::vector< FormatArgument > | mFormatArguments |
A class that allows translatable text to have accessible links in it in a way that is friendly to translators.
This class allows to replace arbitrary placeholders (like s, url, {} or anything of the choice) with links, that are accessible from the keyboard.
In case there are multiple placeholders with the same name - they will be replaced in order they appear in the message.
Definition at line 29 of file AccessibleLinksFormatter.h.
using AccessibleLinksFormatter::LinkClickedHandler = std::function<void()> |
Handler to be called, when the Link is activated.
Definition at line 33 of file AccessibleLinksFormatter.h.
|
explicit |
Create AccessibleLinksFormatter using a TranslatableString.
TranslatableString may have the formatting options attached. TranslatableString copy will be stored, so formatting options that are appended after AccessibleLinksFormatter is created won't have any effect on the AccessibleLinksFormatter instance.
Definition at line 38 of file AccessibleLinksFormatter.cpp.
AccessibleLinksFormatter & AccessibleLinksFormatter::FormatLink | ( | wxString | placeholder, |
TranslatableString | value, | ||
LinkClickedHandler | handler | ||
) |
Replace placeholder with a link, that will call a callback provided.
Definition at line 56 of file AccessibleLinksFormatter.cpp.
References audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, and mFormatArguments.
AccessibleLinksFormatter & AccessibleLinksFormatter::FormatLink | ( | wxString | placeholder, |
TranslatableString | value, | ||
std::string | targetURL | ||
) |
Replace placeholder with a link, that will open URL in default browser.
Definition at line 43 of file AccessibleLinksFormatter.cpp.
References mFormatArguments.
Referenced by ErrorReportDialog::ErrorReportDialog(), MissingPluginsErrorDialog::MissingPluginsErrorDialog(), NoUpdatesAvailableDialog::NoUpdatesAvailableDialog(), audacity::cloud::audiocom::ShareAudioDialog::InitialStatePanel::PopulateInitialStatePanel(), AboutDialog::PopulateLicensePage(), ApplicationPrefs::PopulateOrExchange(), UnwritableLocationErrorDialog::UnwritableLocationErrorDialog(), and UpdateNoticeDialog::UpdateNoticeDialog().
void AccessibleLinksFormatter::Populate | ( | ShuttleGui & | S | ) | const |
Generate the UI.
Definition at line 70 of file AccessibleLinksFormatter.cpp.
References anonymous_namespace{DynamicRangeProcessorEditor.cpp}::borderSize, currentPosition, AccessibleLinksFormatter::FormatArgument::Handler, audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, mFormatArguments, mMessage, anonymous_namespace{AccessibleLinksFormatter.cpp}::OffsetPosition(), AccessibleLinksFormatter::FormatArgument::Placeholder, ProcessArguments(), S, safenew, AccessibleLinksFormatter::FormatArgument::TargetURL, TranslatableString::Translation(), AccessibleLinksFormatter::FormatArgument::Value, Verbatim(), and wxT().
Referenced by ErrorReportDialog::ErrorReportDialog(), MissingPluginsErrorDialog::MissingPluginsErrorDialog(), NoUpdatesAvailableDialog::NoUpdatesAvailableDialog(), audacity::cloud::audiocom::ShareAudioDialog::InitialStatePanel::PopulateInitialStatePanel(), AboutDialog::PopulateLicensePage(), ApplicationPrefs::PopulateOrExchange(), UnwritableLocationErrorDialog::UnwritableLocationErrorDialog(), and UpdateNoticeDialog::UpdateNoticeDialog().
|
private |
Definition at line 187 of file AccessibleLinksFormatter.cpp.
References mFormatArguments, Tuple::detail::npos(), and anonymous_namespace{AccessibleLinksFormatter.cpp}::OffsetPosition().
Referenced by Populate().
|
private |
Definition at line 78 of file AccessibleLinksFormatter.h.
Referenced by FormatLink(), Populate(), and ProcessArguments().
|
private |
Definition at line 77 of file AccessibleLinksFormatter.h.
Referenced by Populate().