diff --git a/src/calibre/gui2/actions/catalog.py b/src/calibre/gui2/actions/catalog.py index 9b95f5e8d0..5287d0d9b3 100644 --- a/src/calibre/gui2/actions/catalog.py +++ b/src/calibre/gui2/actions/catalog.py @@ -18,11 +18,15 @@ class GenerateCatalogAction(InterfaceAction): name = 'Generate Catalog' action_spec = (_('Create catalog'), 'catalog.png', 'Catalog builder', ()) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) def genesis(self): self.qaction.triggered.connect(self.generate_catalog) + def location_selected(self, loc): + enabled = loc == 'library' + self.qaction.setEnabled(enabled) + def generate_catalog(self): rows = self.gui.library_view.selectionModel().selectedRows() if not rows or len(rows) < 2: diff --git a/src/calibre/gui2/actions/choose_library.py b/src/calibre/gui2/actions/choose_library.py index 657d150dbb..01430f14f0 100644 --- a/src/calibre/gui2/actions/choose_library.py +++ b/src/calibre/gui2/actions/choose_library.py @@ -138,7 +138,7 @@ class ChooseLibraryAction(InterfaceAction): name = 'Choose Library' action_spec = (_('Choose Library'), 'lt.png', _('Choose calibre library to work with'), None) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_add_menu = True action_menu_clone_qaction = _('Switch/create library...') diff --git a/src/calibre/gui2/actions/convert.py b/src/calibre/gui2/actions/convert.py index 0dbbdaf1f3..fc1d166685 100644 --- a/src/calibre/gui2/actions/convert.py +++ b/src/calibre/gui2/actions/convert.py @@ -20,7 +20,7 @@ class ConvertAction(InterfaceAction): name = 'Convert Books' action_spec = (_('Convert books'), 'convert.png', None, _('C')) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_type = 'current' action_add_menu = True diff --git a/src/calibre/gui2/actions/copy_to_library.py b/src/calibre/gui2/actions/copy_to_library.py index fdcce87342..383b3e54d8 100644 --- a/src/calibre/gui2/actions/copy_to_library.py +++ b/src/calibre/gui2/actions/copy_to_library.py @@ -127,7 +127,7 @@ class CopyToLibraryAction(InterfaceAction): action_spec = (_('Copy to library'), 'lt.png', _('Copy selected books to the specified library'), None) popup_type = QToolButton.InstantPopup - dont_add_to = frozenset(['toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_type = 'current' action_add_menu = True diff --git a/src/calibre/gui2/actions/device.py b/src/calibre/gui2/actions/device.py index 483b398943..4d96669972 100644 --- a/src/calibre/gui2/actions/device.py +++ b/src/calibre/gui2/actions/device.py @@ -24,7 +24,7 @@ class ShareConnMenu(QMenu): # {{{ config_email = pyqtSignal() toggle_server = pyqtSignal() - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) def __init__(self, parent=None): QMenu.__init__(self, parent) diff --git a/src/calibre/gui2/actions/next_match.py b/src/calibre/gui2/actions/next_match.py index 8e076655a9..c604dc635c 100644 --- a/src/calibre/gui2/actions/next_match.py +++ b/src/calibre/gui2/actions/next_match.py @@ -11,7 +11,7 @@ class NextMatchAction(InterfaceAction): name = 'Move to next highlighted book' action_spec = (_('Move to next match'), 'arrow-down.png', _('Move to next highlighted match'), [_('N'), _('F3')]) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_type = 'current' def genesis(self): diff --git a/src/calibre/gui2/actions/open.py b/src/calibre/gui2/actions/open.py index a66f68eee5..fc78df5f33 100644 --- a/src/calibre/gui2/actions/open.py +++ b/src/calibre/gui2/actions/open.py @@ -13,7 +13,7 @@ class OpenFolderAction(InterfaceAction): name = 'Open Folder' action_spec = (_('Open containing folder'), 'document_open.png', None, _('O')) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_type = 'current' def genesis(self): diff --git a/src/calibre/gui2/actions/random.py b/src/calibre/gui2/actions/random.py index f30b1e0464..03d1dedd82 100644 --- a/src/calibre/gui2/actions/random.py +++ b/src/calibre/gui2/actions/random.py @@ -16,11 +16,15 @@ class PickRandomAction(InterfaceAction): name = 'Pick Random Book' action_spec = (_('Pick a random book'), 'random.png', 'Select a random book from your calibre library', ()) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) def genesis(self): self.qaction.triggered.connect(self.pick_random) + def location_selected(self, loc): + enabled = loc == 'library' + self.qaction.setEnabled(enabled) + def pick_random(self): pick = random.randint(0, self.gui.library_view.model().rowCount(None)) self.gui.library_view.set_current_row(pick) diff --git a/src/calibre/gui2/actions/show_book_details.py b/src/calibre/gui2/actions/show_book_details.py index 1c28a08a79..2ab1e19edd 100644 --- a/src/calibre/gui2/actions/show_book_details.py +++ b/src/calibre/gui2/actions/show_book_details.py @@ -15,7 +15,7 @@ class ShowBookDetailsAction(InterfaceAction): name = 'Show Book Details' action_spec = (_('Show book details'), 'dialog_information.png', None, _('I')) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_type = 'current' def genesis(self): diff --git a/src/calibre/gui2/actions/show_quickview.py b/src/calibre/gui2/actions/show_quickview.py index 4f7bbc0473..b07b05af66 100644 --- a/src/calibre/gui2/actions/show_quickview.py +++ b/src/calibre/gui2/actions/show_quickview.py @@ -14,7 +14,7 @@ class ShowQuickviewAction(InterfaceAction): name = 'Show quickview' action_spec = (_('Show quickview'), 'search.png', None, _('Q')) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_type = 'current' current_instance = None diff --git a/src/calibre/gui2/actions/tweak_epub.py b/src/calibre/gui2/actions/tweak_epub.py index d3924e7cd3..d5ee346d31 100755 --- a/src/calibre/gui2/actions/tweak_epub.py +++ b/src/calibre/gui2/actions/tweak_epub.py @@ -17,7 +17,7 @@ class TweakEpubAction(InterfaceAction): action_spec = (_('Tweak ePub'), 'trim.png', _('Make small changes to ePub format books'), _('T')) - dont_add_to = frozenset(['menubar-device', 'toolbar-device', 'context-menu-device']) + dont_add_to = frozenset(['context-menu-device']) action_type = 'current' def genesis(self):