mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
More general fix for the OS X keyboard shortcuts not working problem. Fixes #1360849 [m command to merge books no longer functions](https://bugs.launchpad.net/calibre/+bug/1360849)
Add all actions created using the create_action/create_menu_action API directly to the main window this allows their shortcuts to work on OS X.
This commit is contained in:
parent
85a69325ea
commit
41d110e444
@ -12,6 +12,7 @@ from PyQt5.Qt import (QToolButton, QAction, QIcon, QObject, QMenu,
|
||||
QKeySequence)
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import isosx
|
||||
from calibre.gui2 import Dispatcher
|
||||
from calibre.gui2.keyboard import NameConflict
|
||||
|
||||
@ -191,7 +192,11 @@ class InterfaceAction(QObject):
|
||||
pass
|
||||
shortcut_action.setShortcuts([QKeySequence(key,
|
||||
QKeySequence.PortableText) for key in keys])
|
||||
|
||||
else:
|
||||
if isosx:
|
||||
# In Qt 5 keyboard shortcuts dont work unless the
|
||||
# action is explicitly added to the main window
|
||||
self.gui.addAction(shortcut_action)
|
||||
|
||||
if attr is not None:
|
||||
setattr(self, attr, action)
|
||||
@ -253,6 +258,10 @@ class InterfaceAction(QObject):
|
||||
self.gui.keyboard.register_shortcut(unique_name,
|
||||
shortcut_name, default_keys=keys,
|
||||
action=ac, description=description, group=self.action_spec[0])
|
||||
if isosx:
|
||||
# In Qt 5 keyboard shortcuts dont work unless the
|
||||
# action is explicitly added to the main window
|
||||
self.gui.addAction(ac)
|
||||
if triggered is not None:
|
||||
ac.triggered.connect(triggered)
|
||||
return ac
|
||||
|
@ -9,7 +9,6 @@ from functools import partial
|
||||
|
||||
from PyQt5.Qt import QToolButton
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
|
||||
class SimilarBooksAction(InterfaceAction):
|
||||
@ -31,11 +30,6 @@ class SimilarBooksAction(InterfaceAction):
|
||||
ac = self.create_action(spec=(text, icon, None, shortcut),
|
||||
attr=target)
|
||||
m.addAction(ac)
|
||||
if isosx:
|
||||
# For some reason with Qt 5 the keyboard shortcuts for these
|
||||
# actions dont work unless the actions are added to the main
|
||||
# window
|
||||
self.gui.addAction(ac)
|
||||
ac.triggered.connect(partial(self.show_similar_books, target))
|
||||
self.qaction.setMenu(m)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user