Fix some custom keyboard shortcuts that use the shift key not working

This commit is contained in:
Kovid Goyal 2014-08-14 22:46:58 +05:30
parent 2f5b725806
commit 50c3dbbc53

View File

@ -16,6 +16,7 @@ from PyQt5.Qt import (QObject, QKeySequence, QAbstractItemModel, QModelIndex,
QGridLayout, QLabel, QRadioButton, QPushButton, QToolButton, QIcon) QGridLayout, QLabel, QRadioButton, QPushButton, QToolButton, QIcon)
from calibre.utils.config import JSONConfig from calibre.utils.config import JSONConfig
from calibre.utils.cleantext import clean_ascii_chars
from calibre.constants import DEBUG from calibre.constants import DEBUG
from calibre import prints from calibre import prints
from calibre.utils.icu import sort_key, lower from calibre.utils.icu import sort_key, lower
@ -58,7 +59,6 @@ def finalize(shortcuts, custom_keys_map={}): # {{{
seen[x] = shortcut seen[x] = shortcut
keys.append(ks) keys.append(ks)
keys = tuple(keys) keys = tuple(keys)
#print (111111, unique_name, candidates, keys)
keys_map[unique_name] = keys keys_map[unique_name] = keys
ac = shortcut['action'] ac = shortcut['action']
@ -126,8 +126,6 @@ class Manager(QObject): # {{{
custom_keys_map = {un:tuple(keys) for un, keys in self.config.get( custom_keys_map = {un:tuple(keys) for un, keys in self.config.get(
'map', {}).iteritems()} 'map', {}).iteritems()}
self.keys_map = finalize(self.shortcuts, custom_keys_map=custom_keys_map) self.keys_map = finalize(self.shortcuts, custom_keys_map=custom_keys_map)
#import pprint
# pprint.pprint(self.keys_map)
def replace_action(self, unique_name, new_action): def replace_action(self, unique_name, new_action):
''' '''
@ -447,7 +445,9 @@ class Editor(QFrame): # {{{
button = getattr(self, 'button%d'%which) button = getattr(self, 'button%d'%which)
button.setStyleSheet('QPushButton { font-weight: normal}') button.setStyleSheet('QPushButton { font-weight: normal}')
mods = int(ev.modifiers()) & ~Qt.KeypadModifier mods = int(ev.modifiers()) & ~Qt.KeypadModifier
txt = unicode(ev.text()) # for some reason qt sometimes produces ascii control codes in text,
# for example ctrl+shift+u will give text == '\x15' on linux
txt = clean_ascii_chars(ev.text())
if txt and txt.lower() == txt.upper(): if txt and txt.lower() == txt.upper():
# We have a symbol like ! or > etc. In this case the value of code # We have a symbol like ! or > etc. In this case the value of code
# already includes Shift, so remove it # already includes Shift, so remove it
@ -695,4 +695,3 @@ class ShortcutConfig(QWidget): # {{{
self.view.setFocus(Qt.OtherFocusReason) self.view.setFocus(Qt.OtherFocusReason)
# }}} # }}}