Minor change in ui/accelerator.cpp

This commit is contained in:
David Capello 2017-01-06 14:19:06 -03:00
parent 0b954087a9
commit 4ac63503c0

View File

@ -197,9 +197,6 @@ Accelerator::Accelerator(const std::string& str)
else if (tok == base::string_to_lower(kWinKeyName)) {
m_modifiers = (KeyModifiers)((int)m_modifiers | (int)kKeyWinModifier);
}
// Scancode
// Word with one character
else if (base::utf8_length(tok) == 1) {
std::wstring wstr = base::from_utf8(tok);
@ -210,10 +207,8 @@ Accelerator::Accelerator(const std::string& str)
m_unicodeChar = std::tolower(wstr[0]);
m_scancode = kKeyNil;
}
// Other ones
else {
// F1, F2, ..., F11, F12
if (tok[0] == 'f' && (tok.size() <= 3)) {
else if (tok[0] == 'f' && (tok.size() <= 3)) {
int num = std::strtol(tok.c_str()+1, NULL, 10);
if ((num >= 1) && (num <= 12))
m_scancode = (KeyScancode)((int)kKeyF1 + num - 1);
@ -282,7 +277,6 @@ Accelerator::Accelerator(const std::string& str)
m_scancode = kKeyEnterPad;
}
}
}
bool Accelerator::operator==(const Accelerator& other) const
{
@ -324,7 +318,8 @@ std::string Accelerator::toString() const
buf += base::to_utf8(wideUnicodeChar);
}
else if (m_scancode > 0 &&
m_scancode < scancode_to_string_size)
m_scancode < scancode_to_string_size &&
scancode_to_string[m_scancode])
buf += scancode_to_string[m_scancode];
else if (!buf.empty() && buf[buf.size()-1] == '+')
buf.erase(buf.size()-1);