mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-14 09:03:54 +01:00
CommandManager stores only stripped menu names (no & characters)...
... Keyboard preference dialog does not need to repeat the stripping
This commit is contained in:
@@ -643,7 +643,7 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn,
|
|||||||
|
|
||||||
TranslatableString labelPrefix;
|
TranslatableString labelPrefix;
|
||||||
if (!mSubMenuList.empty()) {
|
if (!mSubMenuList.empty()) {
|
||||||
labelPrefix = mSubMenuList.back()->name;
|
labelPrefix = mSubMenuList.back()->name.Stripped();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For key bindings for commands with a list, such as align,
|
// For key bindings for commands with a list, such as align,
|
||||||
@@ -684,7 +684,7 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn,
|
|||||||
entry->key = NormalizedKeyString{ accel.BeforeFirst(wxT('\t')) };
|
entry->key = NormalizedKeyString{ accel.BeforeFirst(wxT('\t')) };
|
||||||
entry->defaultKey = entry->key;
|
entry->defaultKey = entry->key;
|
||||||
entry->labelPrefix = labelPrefix;
|
entry->labelPrefix = labelPrefix;
|
||||||
entry->labelTop = wxMenuItem::GetLabelText(mCurrentMenuName.Translation());
|
entry->labelTop = mCurrentMenuName.Stripped();
|
||||||
entry->menu = menu;
|
entry->menu = menu;
|
||||||
entry->finder = finder;
|
entry->finder = finder;
|
||||||
entry->callback = callback;
|
entry->callback = callback;
|
||||||
@@ -1218,13 +1218,12 @@ CommandManager::HandleTextualCommand(const CommandID & Str,
|
|||||||
return CommandNotFound;
|
return CommandNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandManager::GetCategories(
|
TranslatableStrings CommandManager::GetCategories( AudacityProject& )
|
||||||
wxArrayString &cats, AudacityProject * /* p */)
|
|
||||||
{
|
{
|
||||||
cats.clear();
|
TranslatableStrings cats;
|
||||||
|
|
||||||
for (const auto &entry : mCommandList) {
|
for (const auto &entry : mCommandList) {
|
||||||
wxString cat = entry->labelTop;
|
auto &cat = entry->labelTop;
|
||||||
if ( ! make_iterator_range( cats ).contains(cat) ) {
|
if ( ! make_iterator_range( cats ).contains(cat) ) {
|
||||||
cats.push_back(cat);
|
cats.push_back(cat);
|
||||||
}
|
}
|
||||||
@@ -1247,6 +1246,8 @@ void CommandManager::GetCategories(
|
|||||||
|
|
||||||
cats.push_back(COMMAND);
|
cats.push_back(COMMAND);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandManager::GetAllCommandNames(CommandIDs &names,
|
void CommandManager::GetAllCommandNames(CommandIDs &names,
|
||||||
@@ -1286,7 +1287,7 @@ void CommandManager::GetAllCommandData(
|
|||||||
std::vector<NormalizedKeyString> &keys,
|
std::vector<NormalizedKeyString> &keys,
|
||||||
std::vector<NormalizedKeyString> &default_keys,
|
std::vector<NormalizedKeyString> &default_keys,
|
||||||
TranslatableStrings &labels,
|
TranslatableStrings &labels,
|
||||||
wxArrayString &categories,
|
TranslatableStrings &categories,
|
||||||
#if defined(EXPERIMENTAL_KEY_VIEW)
|
#if defined(EXPERIMENTAL_KEY_VIEW)
|
||||||
TranslatableStrings &prefixes,
|
TranslatableStrings &prefixes,
|
||||||
#endif
|
#endif
|
||||||
@@ -1297,18 +1298,7 @@ void CommandManager::GetAllCommandData(
|
|||||||
// It does need the effects.
|
// It does need the effects.
|
||||||
//if ( entry->isEffect )
|
//if ( entry->isEffect )
|
||||||
// continue;
|
// continue;
|
||||||
if (!entry->multi)
|
if ( !entry->multi || includeMultis )
|
||||||
{
|
|
||||||
names.push_back(entry->name);
|
|
||||||
keys.push_back(entry->key);
|
|
||||||
default_keys.push_back(entry->defaultKey);
|
|
||||||
labels.push_back(entry->label);
|
|
||||||
categories.push_back(entry->labelTop);
|
|
||||||
#if defined(EXPERIMENTAL_KEY_VIEW)
|
|
||||||
prefixes.push_back(entry->labelPrefix);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if( includeMultis )
|
|
||||||
{
|
{
|
||||||
names.push_back(entry->name);
|
names.push_back(entry->name);
|
||||||
keys.push_back(entry->key);
|
keys.push_back(entry->key);
|
||||||
@@ -1352,11 +1342,11 @@ TranslatableString CommandManager::GetPrefixedLabelFromName(const CommandID &nam
|
|||||||
return entry->label;
|
return entry->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString CommandManager::GetCategoryFromName(const CommandID &name)
|
TranslatableString CommandManager::GetCategoryFromName(const CommandID &name)
|
||||||
{
|
{
|
||||||
CommandListEntry *entry = mCommandNameHash[name];
|
CommandListEntry *entry = mCommandNameHash[name];
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return wxT("");
|
return {};
|
||||||
|
|
||||||
return entry->labelTop;
|
return entry->labelTop;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ struct CommandListEntry
|
|||||||
NormalizedKeyString defaultKey;
|
NormalizedKeyString defaultKey;
|
||||||
TranslatableString label;
|
TranslatableString label;
|
||||||
TranslatableString labelPrefix;
|
TranslatableString labelPrefix;
|
||||||
wxString labelTop;
|
TranslatableString labelTop;
|
||||||
wxMenu *menu;
|
wxMenu *menu;
|
||||||
CommandHandlerFinder finder;
|
CommandHandlerFinder finder;
|
||||||
CommandFunctorPointer callback;
|
CommandFunctorPointer callback;
|
||||||
@@ -270,7 +270,7 @@ class AUDACITY_DLL_API CommandManager final
|
|||||||
// Accessing
|
// Accessing
|
||||||
//
|
//
|
||||||
|
|
||||||
void GetCategories(wxArrayString &cats, AudacityProject *);
|
TranslatableStrings GetCategories( AudacityProject& );
|
||||||
void GetAllCommandNames(CommandIDs &names, bool includeMultis) const;
|
void GetAllCommandNames(CommandIDs &names, bool includeMultis) const;
|
||||||
void GetAllCommandLabels(
|
void GetAllCommandLabels(
|
||||||
TranslatableStrings &labels, std::vector<bool> &vExcludeFromMacros,
|
TranslatableStrings &labels, std::vector<bool> &vExcludeFromMacros,
|
||||||
@@ -279,7 +279,7 @@ class AUDACITY_DLL_API CommandManager final
|
|||||||
CommandIDs &names,
|
CommandIDs &names,
|
||||||
std::vector<NormalizedKeyString> &keys,
|
std::vector<NormalizedKeyString> &keys,
|
||||||
std::vector<NormalizedKeyString> &default_keys,
|
std::vector<NormalizedKeyString> &default_keys,
|
||||||
TranslatableStrings &labels, wxArrayString &categories,
|
TranslatableStrings &labels, TranslatableStrings &categories,
|
||||||
#if defined(EXPERIMENTAL_KEY_VIEW)
|
#if defined(EXPERIMENTAL_KEY_VIEW)
|
||||||
TranslatableStrings &prefixes,
|
TranslatableStrings &prefixes,
|
||||||
#endif
|
#endif
|
||||||
@@ -291,7 +291,7 @@ class AUDACITY_DLL_API CommandManager final
|
|||||||
|
|
||||||
TranslatableString GetLabelFromName(const CommandID &name);
|
TranslatableString GetLabelFromName(const CommandID &name);
|
||||||
TranslatableString GetPrefixedLabelFromName(const CommandID &name);
|
TranslatableString GetPrefixedLabelFromName(const CommandID &name);
|
||||||
wxString GetCategoryFromName(const CommandID &name);
|
TranslatableString GetCategoryFromName(const CommandID &name);
|
||||||
NormalizedKeyString GetKeyFromName(const CommandID &name) const;
|
NormalizedKeyString GetKeyFromName(const CommandID &name) const;
|
||||||
NormalizedKeyString GetDefaultKeyFromName(const CommandID &name);
|
NormalizedKeyString GetDefaultKeyFromName(const CommandID &name);
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
void KeyConfigPrefs::RefreshBindings(bool bSort)
|
void KeyConfigPrefs::RefreshBindings(bool bSort)
|
||||||
{
|
{
|
||||||
TranslatableStrings Labels;
|
TranslatableStrings Labels;
|
||||||
wxArrayString Categories;
|
TranslatableStrings Categories;
|
||||||
TranslatableStrings Prefixes;
|
TranslatableStrings Prefixes;
|
||||||
|
|
||||||
mNames.clear();
|
mNames.clear();
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ KeyView::UpdateHScroll()
|
|||||||
//
|
//
|
||||||
void
|
void
|
||||||
KeyView::RefreshBindings(const CommandIDs & names,
|
KeyView::RefreshBindings(const CommandIDs & names,
|
||||||
const wxArrayString & categories,
|
const TranslatableStrings & categories,
|
||||||
const TranslatableStrings & prefixes,
|
const TranslatableStrings & prefixes,
|
||||||
const TranslatableStrings & labels,
|
const TranslatableStrings & labels,
|
||||||
const std::vector<NormalizedKeyString> & keys,
|
const std::vector<NormalizedKeyString> & keys,
|
||||||
@@ -667,8 +667,8 @@ KeyView::RefreshBindings(const CommandIDs & names,
|
|||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
// Remove any menu code from the category and prefix
|
// Remove any menu code from the category and prefix
|
||||||
wxString cat = wxMenuItem::GetLabelText(categories[i]);
|
wxString cat = categories[i].Translation();
|
||||||
wxString pfx = wxMenuItem::GetLabelText(prefixes[i].Translation());
|
wxString pfx = prefixes[i].Translation();
|
||||||
|
|
||||||
// Append "Menu" this node is for a menu title
|
// Append "Menu" this node is for a menu title
|
||||||
if (cat != CommandTranslated)
|
if (cat != CommandTranslated)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
wxString GetName() const override; // Gets the control name from the base class
|
wxString GetName() const override; // Gets the control name from the base class
|
||||||
|
|
||||||
void RefreshBindings(const CommandIDs & names,
|
void RefreshBindings(const CommandIDs & names,
|
||||||
const wxArrayString & categories,
|
const TranslatableStrings & categories,
|
||||||
const TranslatableStrings & prefixes,
|
const TranslatableStrings & prefixes,
|
||||||
const TranslatableStrings & labels,
|
const TranslatableStrings & labels,
|
||||||
const std::vector<NormalizedKeyString> & keys,
|
const std::vector<NormalizedKeyString> & keys,
|
||||||
|
|||||||
Reference in New Issue
Block a user