From 7088ae51db49c6f86de2d9225c885fa26ee24108 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 17 Apr 2014 08:09:03 +0530 Subject: [PATCH] Integrate spell check dialog into editor --- src/calibre/gui2/tweak_book/boss.py | 6 ++++++ src/calibre/gui2/tweak_book/spell.py | 2 +- src/calibre/gui2/tweak_book/ui.py | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index a6d7846f1c..77110a99c4 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -905,6 +905,12 @@ class Boss(QObject): c.parent().raise_() c.run_checks(current_container()) + def spell_check_requested(self): + if current_container() is None: + return + self.commit_all_editors_to_container() + self.gui.spell_check.show() + @in_thread_job def fix_requested(self, errors): self.add_savepoint(_('Before: Auto-fix errors')) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index b228af0b89..2323c1c2d6 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -675,6 +675,7 @@ class SpellCheck(Dialog): self.__current_word = None self.thread = None self.cancel = False + dictionaries.initialize() Dialog.__init__(self, _('Check spelling'), 'spell-check', parent) self.work_finished.connect(self.work_done, type=Qt.QueuedConnection) self.setAttribute(Qt.WA_DeleteOnClose, False) @@ -818,7 +819,6 @@ class SpellCheck(Dialog): if i == 0: self.suggested_list.setCurrentItem(item) self.suggested_word.setText(s) - self.change_button.setFocus(Qt.OtherFocusReason) prefix = b.unign_text if ignored else b.ign_text b.setText(prefix + ' ' + current_word) diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index 1aa1d60adf..cc7832c906 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -29,6 +29,7 @@ from calibre.gui2.tweak_book.undo import CheckpointView from calibre.gui2.tweak_book.preview import Preview from calibre.gui2.tweak_book.search import SearchPanel from calibre.gui2.tweak_book.check import Check +from calibre.gui2.tweak_book.spell import SpellCheck from calibre.gui2.tweak_book.search import SavedSearches from calibre.gui2.tweak_book.toc import TOCViewer from calibre.gui2.tweak_book.char_select import CharSelect @@ -221,6 +222,7 @@ class Main(MainWindow): self.central = Central(self) self.setCentralWidget(self.central) self.check_book = Check(self) + self.spell_check = SpellCheck(parent=self) self.toc_view = TOCViewer(self) self.saved_searches = SavedSearches(self) self.image_browser = InsertImage(self, for_browsing=True) @@ -400,6 +402,8 @@ class Main(MainWindow): # Check Book actions group = _('Check Book') self.action_check_book = reg('debug.png', _('&Check Book'), self.boss.check_requested, 'check-book', ('F7'), _('Check book for errors')) + self.action_spell_check_book = reg('spell-check.png', _('Check &spelling'), self.boss.spell_check_requested, 'spell-check-book', ('Alt+F7'), _( + 'Check book for spelling errors')) self.action_check_book_next = reg('forward.png', _('&Next error'), partial( self.check_book.next_error, delta=1), 'check-book-next', ('Ctrl+F7'), _('Show next error')) self.action_check_book_previous = reg('back.png', _('&Previous error'), partial( @@ -478,6 +482,7 @@ class Main(MainWindow): e.addAction(self.action_pretty_all) e.addAction(self.action_rationalize_folders) e.addAction(self.action_set_semantics) + e.addAction(self.action_spell_check_book) e.addAction(self.action_check_book) e = b.addMenu(_('&View')) @@ -536,7 +541,7 @@ class Main(MainWindow): return b a = create(_('Book tool bar'), 'global').addAction - for x in ('new_file', 'open_book', None, 'global_undo', 'global_redo', 'create_checkpoint', 'save', None, 'toc', 'check_book'): + for x in ('new_file', 'open_book', None, 'global_undo', 'global_redo', 'create_checkpoint', 'save', None, 'toc', 'check_book', 'spell_check_book'): if x is None: self.global_bar.addSeparator() continue