From 8b439c6a97a2bc0d624bac7519a70238c210e931 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 15 Nov 2013 16:38:32 +0530 Subject: [PATCH] Allow users to create their own checkpoints while tweaking the book --- src/calibre/gui2/tweak_book/boss.py | 9 ++++++++- src/calibre/gui2/tweak_book/ui.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 93d295bd06..5b8cb5ee3f 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -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(): diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index 7e3325088c..fb51ddd56d 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -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