1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 07:40:23 +02:00

Define and use non-mutating TranslatableString::Stripped

This commit is contained in:
Paul Licameli 2019-12-19 10:23:18 -05:00
parent cd0e1e680a
commit 5e26ef1eba
8 changed files with 14 additions and 11 deletions

View File

@ -89,7 +89,7 @@ public:
const TranslatableString &Msgid() const { return mMsgid; }
const wxString Translation() const { return mMsgid.Translation(); }
const wxString StrippedTranslation() const
{ return TranslatableString{mMsgid}.Strip().Translation(); }
{ return mMsgid.Stripped().Translation(); }
bool empty() const { return mInternal.empty(); }

View File

@ -467,6 +467,10 @@ public:
TranslatableString &&Strip( unsigned options = MenuCodes ) &&
{ return std::move( Strip( options ) ); }
// non-mutating, constructs another TranslatableString object
TranslatableString Stripped( unsigned options = MenuCodes ) const
{ return TranslatableString{ *this }.Strip( options ); }
private:
enum class Request {
Context, // return a disambiguating context string

View File

@ -2109,7 +2109,7 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt)
mpWind->SetToolTip( mItem.mToolTip.Translation() );
if ( !mItem.mName.empty() )
mpWind->SetName( mItem.mName.Strip().Translation() );
mpWind->SetName( mItem.mName.Stripped().Translation() );
if ( !mItem.mNameSuffix.empty() )
mpWind->SetName(

View File

@ -986,7 +986,7 @@ TranslatableString CommandManager::DescribeCommandsAndShortcuts(
// Note: not putting this and other short format strings in the
// translation catalogs
auto piece = TranslatableString{wxT("%s%s")}
.Format( mark, TranslatableString{pair.Msgid()}.Strip() );
.Format( mark, pair.Msgid().Stripped() );
auto name = pair.Internal();
if (!name.empty()) {
@ -1145,8 +1145,7 @@ bool CommandManager::HandleCommandEntry(const CommandListEntry * entry,
if( !proj )
return false;
auto NiceName = entry->label;
NiceName.Strip(
const auto NiceName = entry->label.Stripped(
TranslatableString::Ellipses | TranslatableString::MenuCodes );
// NB: The call may have the side effect of changing flags.
bool allowed =

View File

@ -106,9 +106,9 @@ void Grabber::SetAsSpacer( bool bIsSpacer ) {
mAsSpacer = bIsSpacer;
};
void Grabber::SetToolTip(TranslatableString toolTip)
void Grabber::SetToolTip(const TranslatableString &toolTip)
{
wxWindow::SetToolTip( toolTip.Strip().Translation() );
wxWindow::SetToolTip( toolTip.Stripped().Translation() );
}
//

View File

@ -119,7 +119,7 @@ class Grabber final : public wxWindow
void SetAsSpacer( bool bIsSpacer );
// overload and hide the inherited function that takes naked wxString:
void SetToolTip(TranslatableString toolTip);
void SetToolTip(const TranslatableString &toolTip);
protected:

View File

@ -48,9 +48,9 @@ void wxPanelWrapper::SetName(const TranslatableString & name)
wxPanel::SetName( name.Translation() );
}
void wxPanelWrapper::SetToolTip(TranslatableString toolTip)
void wxPanelWrapper::SetToolTip(const TranslatableString &toolTip)
{
wxPanel::SetToolTip( toolTip.Strip().Translation() );
wxPanel::SetToolTip( toolTip.Stripped().Translation() );
}
void wxPanelWrapper::SetName()

View File

@ -72,7 +72,7 @@ public:
// overload and hide the inherited functions that take naked wxString:
void SetLabel(const TranslatableString & label);
void SetName(const TranslatableString & name);
void SetToolTip(TranslatableString toolTip);
void SetToolTip(const TranslatableString &toolTip);
// Set the name to equal the label:
void SetName();
};