Force keybindings to lower case

This commit is contained in:
Florian Bruhin 2014-07-03 07:46:14 +02:00
parent d45e883f6d
commit ea84ce7acf
4 changed files with 11 additions and 11 deletions

View File

@ -113,7 +113,7 @@ class BaseKeyParser(QObject):
Return:
True if event has been handled, False otherwise.
"""
binding = keyevent_to_string(e)
binding = keyevent_to_string(e).lower()
try:
cmdstr = self.special_bindings[binding]
except KeyError:

View File

@ -117,12 +117,12 @@ class ReadConfigTests(unittest.TestCase):
supports_chains=True)
kp.read_config('test')
self.assertIn('ccc', kp.bindings)
self.assertIn('Ctrl+A', kp.special_bindings)
self.assertIn('ctrl+a', kp.special_bindings)
kp.read_config('test2')
self.assertNotIn('ccc', kp.bindings)
self.assertNotIn('Ctrl+A', kp.special_bindings)
self.assertNotIn('ctrl+a', kp.special_bindings)
self.assertIn('foo', kp.bindings)
self.assertIn('Ctrl+X', kp.special_bindings)
self.assertIn('ctrl+x', kp.special_bindings)
class SpecialKeysTests(unittest.TestCase):

View File

@ -486,12 +486,12 @@ class NormalizeTests(unittest.TestCase):
def test_normalize(self):
"""Test normalize with some strings."""
strings = (
('Control+x', 'Ctrl+X'),
('Windows+x', 'Meta+X'),
('Mod1+x', 'Alt+X'),
('Mod4+x', 'Meta+X'),
('Control--', 'Ctrl+-'),
('Windows++', 'Meta++'),
('Control+x', 'ctrl+x'),
('Windows+x', 'meta+x'),
('Mod1+x', 'alt+x'),
('Mod4+x', 'meta+x'),
('Control--', 'ctrl+-'),
('Windows++', 'meta++'),
)
for orig, repl in strings:
self.assertEqual(utils.normalize_keystr(orig), repl, orig)

View File

@ -461,4 +461,4 @@ def normalize_keystr(keystr):
keystr = keystr.replace(orig, repl)
for mod in ('Ctrl', 'Meta', 'Alt', 'Shift'):
keystr = keystr.replace(mod + '-', mod + '+')
return keystr
return keystr.lower()