mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Add a tool to easily open a file inside the book for editing by just typing a few characters from the file name. To use it press Ctrl+T in the editor or go to Edit->Quick open a file to edit'
This commit is contained in:
parent
b88f26adff
commit
62eb796b51
@ -38,6 +38,7 @@ from calibre.gui2.tweak_book.editor import editor_from_syntax, syntax_from_mime
|
||||
from calibre.gui2.tweak_book.editor.insert_resource import get_resource_data, NewBook
|
||||
from calibre.gui2.tweak_book.preferences import Preferences
|
||||
from calibre.gui2.tweak_book.widgets import RationalizeFolders, MultiSplit, ImportForeign
|
||||
from calibre.gui2.tweak_book.widgets import QuickOpen
|
||||
|
||||
_diff_dialogs = []
|
||||
|
||||
@ -1129,6 +1130,13 @@ class Boss(QObject):
|
||||
_('Editing files of type %s is not supported' % mime), show=True)
|
||||
return self.edit_file(name, syntax)
|
||||
|
||||
def quick_open(self):
|
||||
c = current_container()
|
||||
files = [name for name, mime in c.mime_map.iteritems() if c.exists(name) and syntax_from_mime(name, mime) is not None]
|
||||
d = QuickOpen(files, parent=self.gui)
|
||||
if d.exec_() == d.Accepted and d.selected_result is not None:
|
||||
self.edit_file_requested(d.selected_result, None, c.mime_map[d.selected_result])
|
||||
|
||||
# Editor basic controls {{{
|
||||
def do_editor_undo(self):
|
||||
ed = self.gui.central.current_editor
|
||||
|
@ -302,6 +302,8 @@ class Main(MainWindow):
|
||||
self.action_new_book = reg('book.png', _('Create &new, empty book'), self.boss.new_book, 'new-book', (), _('Create a new, empty book'))
|
||||
self.action_import_book = reg('book.png', _('&Import an HTML or DOCX file as a new book'),
|
||||
self.boss.import_book, 'import-book', (), _('Import an HTML or DOCX file as a new book'))
|
||||
self.action_quick_edit = reg('modified.png', _('&Quick open a file to edit'), self.boss.quick_open, 'quick-open', ('Ctrl+T'), _(
|
||||
'Quickly open a file from the book to edit it'))
|
||||
|
||||
# Editor actions
|
||||
group = _('Editor actions')
|
||||
@ -430,6 +432,7 @@ class Main(MainWindow):
|
||||
f = b.addMenu(_('&File'))
|
||||
f.addAction(self.action_new_file)
|
||||
f.addAction(self.action_import_files)
|
||||
f.addSeparator()
|
||||
f.addAction(self.action_open_book)
|
||||
f.addAction(self.action_new_book)
|
||||
f.addAction(self.action_import_book)
|
||||
@ -455,6 +458,7 @@ class Main(MainWindow):
|
||||
e.addAction(self.action_editor_paste)
|
||||
e.addAction(self.action_insert_char)
|
||||
e.addSeparator()
|
||||
e.addAction(self.action_quick_edit)
|
||||
e.addAction(self.action_preferences)
|
||||
|
||||
e = b.addMenu(_('&Tools'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user