mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Another small speedup
This commit is contained in:
parent
cf3c80598e
commit
8d1433ae78
@ -102,3 +102,5 @@ def set_book_locale(lang):
|
||||
raise ValueError('')
|
||||
except ValueError:
|
||||
dictionaries.default_locale = dictionaries.ui_locale
|
||||
from calibre.gui2.tweak_book.editor.syntax.html import refresh_spell_check_status
|
||||
refresh_spell_check_status()
|
||||
|
@ -123,9 +123,9 @@ class Boss(QObject):
|
||||
self.gui.manage_fonts.subset_all_fonts.connect(self.manage_fonts_subset)
|
||||
|
||||
def preferences(self):
|
||||
orig_spell = tprefs['inline_spell_check']
|
||||
p = Preferences(self.gui)
|
||||
ret = p.exec_()
|
||||
orig_spell = tprefs['inline_spell_check']
|
||||
if p.dictionaries_changed:
|
||||
dictionaries.clear_caches()
|
||||
dictionaries.initialize(force=True) # Reread user dictionaries
|
||||
@ -141,6 +141,8 @@ class Boss(QObject):
|
||||
for ed in editors.itervalues():
|
||||
ed.apply_settings(dictionaries_changed=p.dictionaries_changed)
|
||||
if orig_spell != tprefs['inline_spell_check']:
|
||||
from calibre.gui2.tweak_book.editor.syntax.html import refresh_spell_check_status
|
||||
refresh_spell_check_status()
|
||||
for ed in editors.itervalues():
|
||||
try:
|
||||
ed.editor.highlighter.rehighlight()
|
||||
|
@ -53,6 +53,12 @@ TagStart = namedtuple('TagStart', 'offset prefix name closing is_start')
|
||||
TagEnd = namedtuple('TagEnd', 'offset self_closing is_start')
|
||||
Attr = namedtuple('Attr', 'offset type data')
|
||||
|
||||
do_spell_check = False
|
||||
|
||||
def refresh_spell_check_status():
|
||||
global do_spell_check
|
||||
do_spell_check = tprefs['inline_spell_check'] and hasattr(dictionaries, 'active_user_dictionaries')
|
||||
|
||||
class Tag(object):
|
||||
|
||||
__slots__ = ('name', 'bold', 'italic', 'lang')
|
||||
@ -263,7 +269,7 @@ def process_text(state, text, nbsp_format, spell_format, user_data):
|
||||
elif last < len(text):
|
||||
ans.append((len(text) - last, fmt))
|
||||
|
||||
if tprefs['inline_spell_check'] and state.tags and user_data.tag_ok_for_spell(state.tags[-1].name) and hasattr(dictionaries, 'active_user_dictionaries'):
|
||||
if do_spell_check and state.tags and user_data.tag_ok_for_spell(state.tags[-1].name):
|
||||
split_ans = []
|
||||
locale = state.current_lang or dictionaries.default_locale
|
||||
sfmt = QTextCharFormat(spell_format)
|
||||
|
Loading…
x
Reference in New Issue
Block a user