mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Allow users to create their own checkpoints while tweaking the book
This commit is contained in:
parent
474e7401e5
commit
8b439c6a97
@ -12,7 +12,7 @@ from functools import partial
|
||||
|
||||
from PyQt4.Qt import (
|
||||
QObject, QApplication, QDialog, QGridLayout, QLabel, QSize, Qt, QCursor,
|
||||
QDialogButtonBox, QIcon, QTimer, QPixmap, QTextBrowser, QVBoxLayout)
|
||||
QDialogButtonBox, QIcon, QTimer, QPixmap, QTextBrowser, QVBoxLayout, QInputDialog)
|
||||
|
||||
from calibre import prints
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
@ -427,6 +427,13 @@ class Boss(QObject):
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def create_checkpoint(self):
|
||||
text, ok = QInputDialog.getText(self.gui, _('Choose name'), _(
|
||||
'Choose a name for the checkpoint.\nYou can later restore the book'
|
||||
' to this checkpoint via the\n"Revert to..." entries in the Edit menu.'))
|
||||
if ok:
|
||||
self.add_savepoint(text)
|
||||
|
||||
def save_book(self):
|
||||
c = current_container()
|
||||
for name, ed in editors.iteritems():
|
||||
|
@ -235,6 +235,12 @@ class Main(MainWindow):
|
||||
'count', keys=('Ctrl+N'), description=_('Count number of matches'))
|
||||
self.action_mark = reg(None, _('&Mark selected text'), self.boss.mark_selected_text, 'mark-selected-text', ('Ctrl+Shift+M',), _('Mark selected text'))
|
||||
|
||||
# Miscellaneous actions
|
||||
group = _('Miscellaneous')
|
||||
self.action_create_checkpoint = reg(
|
||||
'marked.png', _('&Create checkpoint'), self.boss.create_checkpoint, 'create-checkpoint', (), _(
|
||||
'Create a checkpoint with the current state of the book'))
|
||||
|
||||
def create_menubar(self):
|
||||
b = self.menuBar()
|
||||
|
||||
@ -246,6 +252,7 @@ class Main(MainWindow):
|
||||
e = b.addMenu(_('&Edit'))
|
||||
e.addAction(self.action_global_undo)
|
||||
e.addAction(self.action_global_redo)
|
||||
e.addAction(self.action_create_checkpoint)
|
||||
e.addSeparator()
|
||||
e.addAction(self.action_editor_undo)
|
||||
e.addAction(self.action_editor_redo)
|
||||
@ -295,7 +302,7 @@ class Main(MainWindow):
|
||||
return b
|
||||
|
||||
a = create(_('Book tool bar'), 'global').addAction
|
||||
for x in ('open_book', 'global_undo', 'global_redo', 'save', 'toc'):
|
||||
for x in ('open_book', 'global_undo', 'global_redo', 'save', 'create_checkpoint', 'toc'):
|
||||
a(getattr(self, 'action_' + x))
|
||||
|
||||
a = create(_('Polish book tool bar'), 'polish').addAction
|
||||
|
Loading…
x
Reference in New Issue
Block a user