mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Also sort user dictionaries in context menu for code editor
And in the spell check dialog make the default dictionary the initial active dictionary when the dialog is opened.
This commit is contained in:
parent
3cd0a296bd
commit
fb34bd9622
@ -27,7 +27,7 @@ from calibre.gui2.tweak_book.editor import (
|
||||
)
|
||||
from calibre.gui2.tweak_book.editor.help import help_url
|
||||
from calibre.gui2.tweak_book.editor.text import TextEdit
|
||||
from calibre.utils.icu import utf16_length
|
||||
from calibre.utils.icu import utf16_length, primary_sort_key
|
||||
from polyglot.builtins import itervalues, string_or_bytes
|
||||
|
||||
|
||||
@ -572,7 +572,7 @@ class Editor(QMainWindow):
|
||||
ac = m.addAction(_('Add this word to the dictionary'))
|
||||
dmenu = QMenu(m)
|
||||
ac.setMenu(dmenu)
|
||||
for dic in dics:
|
||||
for dic in sorted(dics, key=lambda x: primary_sort_key(x.name)):
|
||||
dmenu.addAction(dic.name, partial(self._nuke_word, dic.name, word, locale))
|
||||
m.addSeparator()
|
||||
|
||||
|
@ -1145,13 +1145,12 @@ class SpellCheck(Dialog):
|
||||
self.find_word.emit(w, self.words_model.words[w])
|
||||
|
||||
def initialize_user_dictionaries(self):
|
||||
ct = str(self.user_dictionaries.currentText())
|
||||
ct = str(self.user_dictionaries.currentText()) or _('Default')
|
||||
self.user_dictionaries.clear()
|
||||
self.user_dictionaries.addItems(sorted((d.name for d in dictionaries.active_user_dictionaries), key=primary_sort_key))
|
||||
if ct:
|
||||
idx = self.user_dictionaries.findText(ct)
|
||||
if idx > -1:
|
||||
self.user_dictionaries.setCurrentIndex(idx)
|
||||
idx = self.user_dictionaries.findText(ct)
|
||||
if idx > -1:
|
||||
self.user_dictionaries.setCurrentIndex(idx)
|
||||
self.user_dictionaries.setVisible(self.user_dictionaries.count() > 0)
|
||||
self.user_dictionaries_missing_label.setVisible(not self.user_dictionaries.isVisible())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user