1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-22 06:22:58 +02:00

move function

This commit is contained in:
Paul Licameli
2017-07-15 11:59:55 -04:00
parent fa96dcffb9
commit 812fd2adea
3 changed files with 41 additions and 24 deletions

View File

@@ -1301,6 +1301,29 @@ void CommandManager::TellUserWhyDisallowed( const wxString & Name, CommandFlag f
} }
} }
wxString CommandManager::DescribeCommandsAndShortcuts
(const std::vector<wxString> &commands, const wxString &separator) const
{
wxString result;
auto iter = commands.begin(), end = commands.end();
while (iter != end) {
result += *iter++;
if (iter != end) {
if (!iter->empty()) {
auto keyStr = GetKeyFromName(*iter);
if (!keyStr.empty()){
result += wxT(" ");
result += Internat::Parenthesize(KeyStringDisplay(keyStr, true));
}
}
++iter;
}
if (iter != end)
result += separator;
}
return result;
}
/// ///
/// ///
/// ///

View File

@@ -262,6 +262,18 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
void WriteXML(XMLWriter &xmlFile) const /* not override */; void WriteXML(XMLWriter &xmlFile) const /* not override */;
void TellUserWhyDisallowed(const wxString & Name, CommandFlag flagsGot, CommandFlag flagsRequired); void TellUserWhyDisallowed(const wxString & Name, CommandFlag flagsGot, CommandFlag flagsRequired);
///
/// Formatting summaries that include shortcut keys
///
wxString DescribeCommandsAndShortcuts
(// An array, alternating user-visible strings, and
// non-user-visible command names. If a shortcut key is defined
// for the command, then it is appended, parenthesized, after the
// user-visible string.
const std::vector<wxString> &commands,
// If more than one pair of strings is given, then use this separator.
const wxString &separator = wxT(" / ")) const;
protected: protected:
// //

View File

@@ -834,31 +834,13 @@ void ToolBar::MakeAlternateImages(AButton &button, int idx,
void ToolBar::SetButtonToolTip void ToolBar::SetButtonToolTip
(AButton &button, const std::vector<wxString> &commands, const wxString &separator) (AButton &button, const std::vector<wxString> &commands, const wxString &separator)
{ {
const auto project = GetActiveProject();
const auto commandManager = project ? project->GetCommandManager() : nullptr;
wxString result; wxString result;
auto iter = commands.begin(), end = commands.end(); const auto project = GetActiveProject();
while (iter != end) { const auto commandManager =
result += *iter++; project ? project->GetCommandManager() : nullptr;
if (iter != end) { if (commandManager)
if (!iter->empty()) { result =
if (commandManager) { commandManager->DescribeCommandsAndShortcuts(commands, separator);
auto keyStr = commandManager->GetKeyFromName(*iter);
// For DarkAudacity, only add '(shortcut-info)' if there is
// some, rather than as in that case in Audacity saying
// '(no key)'. More users will be confused by the Audacity
// way than helped by it.
if (!keyStr.empty()){
result += wxT(" ");
result += Internat::Parenthesize(KeyStringDisplay(keyStr, true));
}
}
}
++iter;
}
if (iter != end)
result += separator;
}
button.SetToolTip(result); button.SetToolTip(result);
} }