mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Enhancement #1360550 Shortcut to template editor
This commit is contained in:
parent
dfac964265
commit
72d21bfcc5
@ -834,6 +834,11 @@ class ActionQuickview(InterfaceActionBase):
|
|||||||
actual_plugin = 'calibre.gui2.actions.show_quickview:ShowQuickviewAction'
|
actual_plugin = 'calibre.gui2.actions.show_quickview:ShowQuickviewAction'
|
||||||
description = _('Show a list of related books quickly')
|
description = _('Show a list of related books quickly')
|
||||||
|
|
||||||
|
class ActionTemplateTester(InterfaceActionBase):
|
||||||
|
name = 'Template Tester'
|
||||||
|
actual_plugin = 'calibre.gui2.actions.show_template_tester:ShowTemplateTesterAction'
|
||||||
|
description = _('Show an editor for testing templates')
|
||||||
|
|
||||||
class ActionSaveToDisk(InterfaceActionBase):
|
class ActionSaveToDisk(InterfaceActionBase):
|
||||||
name = 'Save To Disk'
|
name = 'Save To Disk'
|
||||||
actual_plugin = 'calibre.gui2.actions.save_to_disk:SaveToDiskAction'
|
actual_plugin = 'calibre.gui2.actions.save_to_disk:SaveToDiskAction'
|
||||||
@ -969,7 +974,7 @@ plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
|
|||||||
ActionAddToLibrary, ActionEditCollections, ActionMatchBooks, ActionChooseLibrary,
|
ActionAddToLibrary, ActionEditCollections, ActionMatchBooks, ActionChooseLibrary,
|
||||||
ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore,
|
ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore,
|
||||||
ActionPluginUpdater, ActionPickRandom, ActionEditToC, ActionSortBy,
|
ActionPluginUpdater, ActionPickRandom, ActionEditToC, ActionSortBy,
|
||||||
ActionMarkBooks, ActionEmbed]
|
ActionMarkBooks, ActionEmbed, ActionTemplateTester]
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
45
src/calibre/gui2/actions/show_template_tester.py
Normal file
45
src/calibre/gui2/actions/show_template_tester.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
||||||
|
from calibre.gui2 import error_dialog
|
||||||
|
|
||||||
|
class ShowTemplateTesterAction(InterfaceAction):
|
||||||
|
|
||||||
|
name = 'Template tester'
|
||||||
|
action_spec = (_('Template tester'), 'debug.png', None, '')
|
||||||
|
dont_add_to = frozenset(['context-menu-device'])
|
||||||
|
action_type = 'current'
|
||||||
|
|
||||||
|
def genesis(self):
|
||||||
|
self.qaction.triggered.connect(self.show_template_editor)
|
||||||
|
|
||||||
|
def show_template_editor(self, *args):
|
||||||
|
view = self.gui.current_view()
|
||||||
|
if view is not self.gui.library_view:
|
||||||
|
return error_dialog(self.gui, _('No template tester available'),
|
||||||
|
_('Template tester is not available for books '
|
||||||
|
'on the device.')).exec_()
|
||||||
|
|
||||||
|
rows = view.selectionModel().selectedRows()
|
||||||
|
if not rows:
|
||||||
|
return error_dialog(self.gui, _('No books selected'),
|
||||||
|
_('A book must be selected'), show=True)
|
||||||
|
if len(rows) > 1:
|
||||||
|
return error_dialog(self.gui, _('Selected multiple books'),
|
||||||
|
_('Only one book can be selected'), show=True)
|
||||||
|
|
||||||
|
index = rows[0]
|
||||||
|
if index.isValid():
|
||||||
|
db = view.model().db
|
||||||
|
t = TemplateDialog(self.gui, _('Enter a template to test'),
|
||||||
|
mi=db.get_metadata(index.row(), index_is_id=False,
|
||||||
|
get_cover=False))
|
||||||
|
t.setWindowTitle(_('Template tester'))
|
||||||
|
t.exec_()
|
Loading…
x
Reference in New Issue
Block a user