mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Edit book: Add a shortcut (Ctrl+Alt+Down) to edit the next file in the book spine. Fixes #1779616 [Editor: Add a keyboard shortcut to open the next file](https://bugs.launchpad.net/calibre/+bug/1779616)
This commit is contained in:
parent
86dab6d6cc
commit
0f276ad5a0
@ -1451,6 +1451,9 @@ class Boss(QObject):
|
|||||||
_('Editing files of type %s is not supported' % mime), show=True)
|
_('Editing files of type %s is not supported' % mime), show=True)
|
||||||
return self.edit_file(name, syntax)
|
return self.edit_file(name, syntax)
|
||||||
|
|
||||||
|
def edit_next_file(self, backwards=False):
|
||||||
|
self.gui.file_list.edit_next_file(self.currently_editing, backwards)
|
||||||
|
|
||||||
def quick_open(self):
|
def quick_open(self):
|
||||||
if not self.ensure_book(_('No book is currently open. You must first open a book to edit.')):
|
if not self.ensure_book(_('No book is currently open. You must first open a book to edit.')):
|
||||||
return
|
return
|
||||||
|
@ -734,6 +734,21 @@ class FileList(QTreeWidget):
|
|||||||
error_dialog(self, _('Cannot edit'),
|
error_dialog(self, _('Cannot edit'),
|
||||||
_('No item with the name: %s was found') % name, show=True)
|
_('No item with the name: %s was found') % name, show=True)
|
||||||
|
|
||||||
|
def edit_next_file(self, currently_editing=None, backwards=False):
|
||||||
|
category = self.categories['text']
|
||||||
|
seen_current = False
|
||||||
|
items = (category.child(i) for i in xrange(category.childCount()))
|
||||||
|
if backwards:
|
||||||
|
items = reversed(tuple(items))
|
||||||
|
for item in items:
|
||||||
|
name = unicode(item.data(0, NAME_ROLE) or '')
|
||||||
|
if seen_current:
|
||||||
|
self._request_edit(item)
|
||||||
|
return True
|
||||||
|
if currently_editing == name:
|
||||||
|
seen_current = True
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_files(self):
|
def all_files(self):
|
||||||
return (category.child(i) for category in self.categories.itervalues() for i in xrange(category.childCount()))
|
return (category.child(i) for category in self.categories.itervalues() for i in xrange(category.childCount()))
|
||||||
@ -982,6 +997,7 @@ class FileListWidget(QWidget):
|
|||||||
for x in ('delete_done', 'select_name', 'select_names', 'request_edit', 'mark_name_as_current', 'clear_currently_edited_name'):
|
for x in ('delete_done', 'select_name', 'select_names', 'request_edit', 'mark_name_as_current', 'clear_currently_edited_name'):
|
||||||
setattr(self, x, getattr(self.file_list, x))
|
setattr(self, x, getattr(self.file_list, x))
|
||||||
self.setFocusProxy(self.file_list)
|
self.setFocusProxy(self.file_list)
|
||||||
|
self.edit_next_file = self.file_list.edit_next_file
|
||||||
|
|
||||||
def build(self, container, preserve_state=True):
|
def build(self, container, preserve_state=True):
|
||||||
self.file_list.build(container, preserve_state=preserve_state)
|
self.file_list.build(container, preserve_state=preserve_state)
|
||||||
|
@ -337,6 +337,11 @@ class Main(MainWindow):
|
|||||||
self.action_open_book = treg('document_open.png', _('&Open book'), self.boss.open_book, 'open-book', 'Ctrl+O', _('Open a new book'))
|
self.action_open_book = treg('document_open.png', _('&Open book'), self.boss.open_book, 'open-book', 'Ctrl+O', _('Open a new book'))
|
||||||
self.action_open_book_folder = treg('mimetypes/dir.png', _('Open &folder (unzipped EPUB) as book'), partial(self.boss.open_book, open_folder=True),
|
self.action_open_book_folder = treg('mimetypes/dir.png', _('Open &folder (unzipped EPUB) as book'), partial(self.boss.open_book, open_folder=True),
|
||||||
'open-folder-as-book', (), _('Open a folder (unzipped EPUB) as a book'))
|
'open-folder-as-book', (), _('Open a folder (unzipped EPUB) as a book'))
|
||||||
|
self.action_edit_next_file = treg('arrow-down.png', _('Edit &next file'), partial(self.boss.edit_next_file, backwards=False),
|
||||||
|
'edit-next-file', 'Ctrl+Alt+Down', _('Edit the next file in the spine'))
|
||||||
|
self.action_edit_previous_file = treg('arrow-up.png', _('Edit &previous file'), partial(self.boss.edit_next_file, backwards=True),
|
||||||
|
'edit-previous-file', 'Ctrl+Alt+Up', _('Edit the previous file in the spine'))
|
||||||
|
# Qt does not generate shortcut overrides for cmd+arrow on os x which
|
||||||
# Qt does not generate shortcut overrides for cmd+arrow on os x which
|
# Qt does not generate shortcut overrides for cmd+arrow on os x which
|
||||||
# means these shortcuts interfere with editing
|
# means these shortcuts interfere with editing
|
||||||
self.action_global_undo = treg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', () if isosx else 'Ctrl+Left',
|
self.action_global_undo = treg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', () if isosx else 'Ctrl+Left',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user