From a7ab2ae11bd68bcfb338579d9b28e0357636dd44 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 2 Dec 2013 09:01:45 +0530 Subject: [PATCH] Modify dirtied question if many dirtied editors present. Also mark editors as clean when updating editors from container. --- src/calibre/gui2/tweak_book/boss.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 7d8915078f..dd5a6df403 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -96,6 +96,11 @@ class Boss(QObject): dirtied = {name for name, ed in editors.iteritems() if ed.is_modified} if not dirtied: return True + if len(dirtied) > 4: + return question_dialog(self.gui, _('Unsaved changes'), _( + 'You have unsaved changes in many opened files. If you proceed,' + ' you will lose them. Proceed anyway?') % ', '.join(dirtied)) + return question_dialog(self.gui, _('Unsaved changes'), _( 'You have unsaved changes in the files %s. If you proceed,' ' you will lose them. Proceed anyway?') % ', '.join(dirtied)) @@ -155,6 +160,7 @@ class Boss(QObject): for name, ed in tuple(editors.iteritems()): if c.has_name(name): ed.replace_data(c.raw_data(name)) + ed.is_modified = False else: self.close_editor(name) @@ -162,8 +168,8 @@ class Boss(QObject): container = current_container() self.gui.file_list.build(container) self.update_global_history_actions() - self.set_modified() self.update_editors_from_container() + self.set_modified() def delete_requested(self, spine_items, other_items): if not self.check_dirtied():