Return the name of the command found or an empty string if none from Hotkey::Scan rather than using an out reference
Originally committed to SVN as r6112.
This commit is contained in:
parent
022c711409
commit
7bb749b51f
3 changed files with 10 additions and 14 deletions
|
@ -91,7 +91,7 @@ void Hotkey::BuildHotkey(std::string const& context, const json::Object& object)
|
|||
}
|
||||
}
|
||||
|
||||
bool Hotkey::Scan(const std::string &context, const std::string &str, bool always, std::string &cmd) const {
|
||||
std::string Hotkey::Scan(const std::string &context, const std::string &str, bool always) const {
|
||||
std::string local, dfault;
|
||||
|
||||
HotkeyMap::const_iterator index, end;
|
||||
|
@ -99,9 +99,8 @@ bool Hotkey::Scan(const std::string &context, const std::string &str, bool alway
|
|||
std::string const& ctext = index->second.Context();
|
||||
|
||||
if (always && ctext == "Always") {
|
||||
cmd = index->second.CmdName();
|
||||
LOG_D("agi/hotkey/found") << "Found: " << str << " Context (req/found): " << context << "/Always Command: " << cmd;
|
||||
return true;
|
||||
LOG_D("agi/hotkey/found") << "Found: " << str << " Context (req/found): " << context << "/Always Command: " << index->second.CmdName();
|
||||
return index->second.CmdName();
|
||||
}
|
||||
if (ctext == "Default")
|
||||
dfault = index->second.CmdName();
|
||||
|
@ -110,18 +109,15 @@ bool Hotkey::Scan(const std::string &context, const std::string &str, bool alway
|
|||
}
|
||||
|
||||
if (!local.empty()) {
|
||||
cmd = local;
|
||||
LOG_D("agi/hotkey/found") << "Found: " << str << " Context: " << context << " Command: " << local;
|
||||
return true;
|
||||
return local;
|
||||
}
|
||||
if (!dfault.empty()) {
|
||||
cmd = dfault;
|
||||
LOG_D("agi/hotkey/found") << "Found: " << str << " Context (req/found): " << context << "/Default Command: " << dfault;
|
||||
return true;
|
||||
return dfault;
|
||||
}
|
||||
|
||||
cmd.clear();
|
||||
return false;
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> Hotkey::GetHotkeys(const std::string &context, const std::string &command) const {
|
||||
|
|
|
@ -107,8 +107,8 @@ public:
|
|||
/// @param context Context requested.
|
||||
/// @param str Hyphen separated key sequence.
|
||||
/// @param always Enable the "Always" override context
|
||||
/// @param[out] cmd Command found.
|
||||
bool Scan(const std::string &context, const std::string &str, bool always, std::string &cmd) const;
|
||||
/// @return Name of command or "" if none match
|
||||
std::string Scan(const std::string &context, const std::string &str, bool always) const;
|
||||
|
||||
/// Get the string representation of the hotkeys for the given command
|
||||
/// @param context Context requested
|
||||
|
|
|
@ -76,8 +76,8 @@ bool check(std::string const& context, agi::Context *c, int key_code, wchar_t ke
|
|||
std::string combo = keypress_to_str(key_code, key_char, modifier);
|
||||
if (combo.empty()) return false;
|
||||
|
||||
std::string command;
|
||||
if (inst->Scan(context, combo, OPT_GET("Audio/Medusa Timing Hotkeys")->GetBool(), command)) {
|
||||
std::string command = inst->Scan(context, combo, OPT_GET("Audio/Medusa Timing Hotkeys")->GetBool());
|
||||
if (!command.empty()) {
|
||||
/// The bottom line should be removed after all the hotkey commands are fixed.
|
||||
/// This is to avoid pointless exceptions.
|
||||
if (command.find("/") != std::string::npos) {
|
||||
|
|
Loading…
Reference in a new issue