diff --git a/src/command/command.cpp b/src/command/command.cpp index edc041b6a..d0419161c 100644 --- a/src/command/command.cpp +++ b/src/command/command.cpp @@ -19,6 +19,9 @@ #include +#include +#include "include/aegisub/hotkey.h" + #include namespace cmd { @@ -32,6 +35,16 @@ namespace cmd { return it; } + wxString Command::GetTooltip(std::string ht_context) const { + wxString ret = StrHelp(); + + std::vector hotkeys = hotkey::get_hotkey_strs(ht_context, name()); + if (!hotkeys.empty()) + ret += to_wx(" (" + boost::join(hotkeys, "/") + ")"); + + return ret; + } + void reg(std::unique_ptr cmd) { cmd_map[cmd->name()] = std::move(cmd); } diff --git a/src/command/command.h b/src/command/command.h index 4d7b00225..899cace05 100644 --- a/src/command/command.h +++ b/src/command/command.h @@ -103,6 +103,9 @@ DEFINE_EXCEPTION(CommandNotFound, CommandError); /// Short help string describing what the command does virtual wxString StrHelp() const=0; + /// Formats the Help text together with the registered hotkey + wxString GetTooltip(std::string ht_context) const; + /// Get this command's type flags /// @return Bitmask of CommandFlags virtual int Type() const { return COMMAND_NORMAL; } diff --git a/src/toolbar.cpp b/src/toolbar.cpp index 40c0a7769..ac2aecb25 100644 --- a/src/toolbar.cpp +++ b/src/toolbar.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -143,7 +142,7 @@ namespace { wxITEM_NORMAL; wxBitmap const& bitmap = command->Icon(icon_size, retina_helper.GetScaleFactor(), GetLayoutDirection()); - AddTool(TOOL_ID_BASE + commands.size(), command->StrDisplay(context), bitmap, GetTooltip(command), kind); + AddTool(TOOL_ID_BASE + commands.size(), command->StrDisplay(context), bitmap, command->GetTooltip(ht_context), kind); commands.push_back(command); needs_onidle = needs_onidle || flags != cmd::COMMAND_NORMAL; @@ -157,16 +156,6 @@ namespace { Realize(); } - wxString GetTooltip(cmd::Command *command) { - wxString ret = command->StrHelp(); - - std::vector hotkeys = hotkey::get_hotkey_strs(ht_context, command->name()); - if (!hotkeys.empty()) - ret += to_wx(" (" + boost::join(hotkeys, "/") + ")"); - - return ret; - } - public: Toolbar(wxWindow *parent, std::string name, agi::Context *c, std::string ht_context, bool vertical) : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize, wxTB_NODIVIDER | wxTB_FLAT | (vertical ? wxTB_VERTICAL : wxTB_HORIZONTAL)) diff --git a/src/visual_tool_vector_clip.cpp b/src/visual_tool_vector_clip.cpp index b14aa81b5..351f5757f 100644 --- a/src/visual_tool_vector_clip.cpp +++ b/src/visual_tool_vector_clip.cpp @@ -52,7 +52,7 @@ void VisualToolVectorClip::AddTool(std::string command_name, VisualToolVectorCli } int icon_size = OPT_GET("App/Toolbar Icon Size")->GetInt(); - toolBar->AddTool(BUTTON_ID_BASE + mode, command->StrDisplay(c), command->Icon(icon_size), command->StrHelp(), wxITEM_CHECK); + toolBar->AddTool(BUTTON_ID_BASE + mode, command->StrDisplay(c), command->Icon(icon_size), command->GetTooltip("Video"), wxITEM_CHECK); }