Still save keyboard shortcuts to actions that aren't visible in current library.

This commit is contained in:
Jim Miller 2020-10-11 11:53:49 -05:00
parent d2173ca772
commit aba21a2b1b

View File

@ -277,13 +277,23 @@ class ConfigModel(SearchQueryParser, QAbstractItemModel):
self.index(num-1, 0, group)) self.index(num-1, 0, group))
def commit(self): def commit(self):
kmap = {} # start with a copy and remove set_to_defaults instead of
# building from empty because shortcuts tied to actions not
# visible in the current library will be erased otherwise.
# Reading List, View Manager and FanFicFare plugins are
# examples where menu actions change by library.
kmap = dict(self.keyboard.config['map'])
for node in self.all_shortcuts: for node in self.all_shortcuts:
sc = node.data sc = node.data
if sc['set_to_default']: if sc['set_to_default']:
continue if sc['unique_name'] in kmap:
keys = [unicode_type(k.toString(k.PortableText)) for k in sc['keys']] del kmap[sc['unique_name']]
kmap[sc['unique_name']] = keys else:
keys = [unicode_type(k.toString(k.PortableText)) for k in sc['keys']]
kmap[sc['unique_name']] = keys
# note that something further on appears to depends on
# self.keyboard.config['map'] being a different object now to
# signal to save it.
self.keyboard.config['map'] = kmap self.keyboard.config['map'] = kmap
def universal_set(self): def universal_set(self):