More descriptive spell check tooltip

This commit is contained in:
Veronica K. B. Olsen
2020-10-04 21:21:30 +02:00
parent ac96636f8a
commit 96a5b9e4ae
3 changed files with 13 additions and 5 deletions
+6 -2
View File
@@ -455,7 +455,11 @@ class GuiDocEditor(QTextEdit):
theLang = self.theProject.projLang theLang = self.theProject.projLang
self.theDict.setLanguage(theLang, self.theProject.projDict) self.theDict.setLanguage(theLang, self.theProject.projDict)
self.theParent.statusBar.setLanguage(self.theDict.spellLanguage)
aLang, aName = self.theDict.describeDict()
self.theParent.statusBar.setLanguage(
aLang, "%s/%s" % (self.mainConf.spellTool, aName)
)
if not self.bigDoc: if not self.bigDoc:
self.spellCheckDocument() self.spellCheckDocument()
@@ -802,7 +806,7 @@ class GuiDocEditor(QTextEdit):
mnuHead = QAction("Spelling Suggestion(s)", mnuContext) mnuHead = QAction("Spelling Suggestion(s)", mnuContext)
mnuContext.addAction(mnuHead) mnuContext.addAction(mnuHead)
theSuggest = self.theDict.suggestWords(theWord) theSuggest = self.theDict.suggestWords(theWord)[:15]
if len(theSuggest) > 0: if len(theSuggest) > 0:
for aWord in theSuggest: for aWord in theSuggest:
mnuWord = QAction("%s %s" % (nwUnicode.U_ENDASH, aWord), mnuContext) mnuWord = QAction("%s %s" % (nwUnicode.U_ENDASH, aWord), mnuContext)
+2 -2
View File
@@ -198,7 +198,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Build a QRegExp for spell checker # Build a QRegExp for spell checker
# Include additional characters that the highlighter should # Include additional characters that the highlighter should
# consider to be word separators # consider to be word separators
wordSep = r"-_\+/" wordSep = r"\-_\+/"
wordSep += nwUnicode.U_ENDASH wordSep += nwUnicode.U_ENDASH
wordSep += nwUnicode.U_EMDASH wordSep += nwUnicode.U_EMDASH
self.spellRx = QRegularExpression(r"\b[^\s"+wordSep+r"]+\b") self.spellRx = QRegularExpression(r"\b[^\s"+wordSep+r"]+\b")
@@ -314,7 +314,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
while rxSpell.hasNext(): while rxSpell.hasNext():
rxMatch = rxSpell.next() rxMatch = rxSpell.next()
if not self.theDict.checkWord(rxMatch.captured(0)): if not self.theDict.checkWord(rxMatch.captured(0)):
if rxMatch.captured(0).isupper(): if rxMatch.captured(0).isupper() or rxMatch.captured(0).isnumeric():
continue continue
xPos = rxMatch.capturedStart(0) xPos = rxMatch.capturedStart(0)
xLen = rxMatch.capturedLength(0) xLen = rxMatch.capturedLength(0)
+5 -1
View File
@@ -152,13 +152,17 @@ class GuiMainStatus(QStatusBar):
qApp.processEvents() qApp.processEvents()
return return
def setLanguage(self, theLanguage): def setLanguage(self, theLanguage, theProvider=""):
"""Set the language code for the spell checker. """Set the language code for the spell checker.
""" """
if theLanguage is None: if theLanguage is None:
self.langText.setText("None") self.langText.setText("None")
self.langText.setToolTip("")
else: else:
self.langText.setText(NWSpellCheck.expandLanguage(theLanguage)) self.langText.setText(NWSpellCheck.expandLanguage(theLanguage))
self.langText.setToolTip(
"Provider: %s" % (theProvider if theProvider else "unknown")
)
return return
def setProjectStatus(self, isChanged): def setProjectStatus(self, isChanged):