Restore some of the old spell check information in the status bar
This commit is contained in:
+5
-4
@@ -94,7 +94,7 @@ class Config:
|
||||
|
||||
## Localisation
|
||||
self.qLocal = QLocale.system()
|
||||
self.guiLang = self.qLocal.bcp47Name()
|
||||
self.guiLang = self.qLocal.name()
|
||||
self.qtLangPath = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
|
||||
self.nwLangPath = None
|
||||
self.qtTrans = {}
|
||||
@@ -374,9 +374,10 @@ class Config:
|
||||
self.qtTrans = {}
|
||||
|
||||
langList = [
|
||||
(self.qtLangPath, "qt"),
|
||||
(self.qtLangPath, "qtbase"),
|
||||
(self.nwLangPath, "nw"),
|
||||
(self.qtLangPath, "qt"), # Qt 4.x
|
||||
(self.qtLangPath, "qtbase"), # Qt 5.x
|
||||
(self.nwLangPath, "qtbase"), # Alternative Qt 5.x
|
||||
(self.nwLangPath, "nw"), # novelWriter
|
||||
]
|
||||
for lngPath, lngBase in langList:
|
||||
for lngCode in self.qLocal.uiLanguages():
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ class NWIndex():
|
||||
|
||||
# TimeStamps
|
||||
self._timeNovel = 0
|
||||
self._timeNotes = 0
|
||||
self._timeNotes = 0
|
||||
self._timeIndex = 0
|
||||
|
||||
return
|
||||
|
||||
@@ -82,6 +82,11 @@ class NWSpellCheck():
|
||||
"""
|
||||
return []
|
||||
|
||||
def describeDict(self):
|
||||
"""Dummy function.
|
||||
"""
|
||||
return "", ""
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
@@ -182,8 +187,24 @@ class NWSpellEnchant(NWSpellCheck):
|
||||
retList.append((spTag, spProvider.name))
|
||||
except Exception:
|
||||
logger.error("Failed to list languages for enchant spell checking")
|
||||
|
||||
return retList
|
||||
|
||||
def describeDict(self):
|
||||
"""Return the tag and provider of the currently loaded
|
||||
dictionary.
|
||||
"""
|
||||
try:
|
||||
spTag = self.theDict.tag
|
||||
spName = self.theDict.provider.name
|
||||
except Exception:
|
||||
logger.error("Failed to extract information about the dictionary")
|
||||
nw.logException()
|
||||
spTag = ""
|
||||
spName = ""
|
||||
|
||||
return spTag, spName
|
||||
|
||||
# END Class NWSpellEnchant
|
||||
|
||||
class NWSpellEnchantDummy:
|
||||
@@ -303,4 +324,10 @@ class NWSpellSimple(NWSpellCheck):
|
||||
|
||||
return retList
|
||||
|
||||
def describeDict(self):
|
||||
"""Return the tag and provider of the currently loaded
|
||||
dictionary.
|
||||
"""
|
||||
return self.theLang, ""
|
||||
|
||||
# END Class NWSpellSimple
|
||||
|
||||
+3
-1
@@ -603,7 +603,9 @@ class GuiDocEditor(QTextEdit):
|
||||
theLang = self.theProject.projLang
|
||||
|
||||
self.theDict.setLanguage(theLang, self.theProject.projDict)
|
||||
self.theParent.statusBar.setLanguage(theLang)
|
||||
theTag, theProvider = self.theDict.describeDict()
|
||||
|
||||
self.theParent.statusBar.setLanguage(theLang, theProvider)
|
||||
|
||||
if not self.bigDoc:
|
||||
self.spellCheckDocument()
|
||||
|
||||
+7
-3
@@ -147,16 +147,20 @@ class GuiMainStatus(QStatusBar):
|
||||
qApp.processEvents()
|
||||
return
|
||||
|
||||
def setLanguage(self, theLang):
|
||||
def setLanguage(self, theLang, theProvider=""):
|
||||
"""Set the language code for the spell checker.
|
||||
"""
|
||||
if theLang is None:
|
||||
self.langText.setText(self.tr("None"))
|
||||
self.langText.setToolTip("")
|
||||
else:
|
||||
qLocal = QLocale(theLang)
|
||||
spLang = qLocal.nativeLanguageName().title()
|
||||
spName = qLocal.bcp47Name()
|
||||
self.langText.setText("%s (%s)" % (spLang, spName))
|
||||
self.langText.setText(spLang)
|
||||
if theProvider:
|
||||
self.langText.setToolTip("%s (%s)" % (theLang, theProvider))
|
||||
else:
|
||||
self.langText.setToolTip(theLang)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ def testCoreSpell_Super(monkeypatch, tmpDir, tmpConf):
|
||||
assert spChk.checkWord("")
|
||||
assert spChk.suggestWords("") == []
|
||||
assert spChk.listDictionaries() == []
|
||||
assert spChk.describeDict() == ("", "")
|
||||
|
||||
# Add a word to the user's dictionary
|
||||
assert spChk._readProjectDictionary("dummy") is False
|
||||
@@ -86,6 +87,7 @@ def testCoreSpell_Enchant(monkeypatch, tmpDir, tmpConf):
|
||||
assert spChk.checkWord("")
|
||||
assert spChk.suggestWords("") == []
|
||||
assert spChk.listDictionaries() == []
|
||||
assert spChk.describeDict() == ("", "")
|
||||
|
||||
monkeypatch.undo()
|
||||
|
||||
@@ -109,6 +111,10 @@ def testCoreSpell_Enchant(monkeypatch, tmpDir, tmpConf):
|
||||
dList = spChk.listDictionaries()
|
||||
assert len(dList) > 0
|
||||
|
||||
aTag, aName = spChk.describeDict()
|
||||
assert aTag == "en"
|
||||
assert aName != ""
|
||||
|
||||
# END Test testCoreSpell_Enchant
|
||||
|
||||
@pytest.mark.core
|
||||
@@ -169,4 +175,9 @@ def testCoreSpell_Simple(monkeypatch, tmpDir, tmpConf):
|
||||
# List dictionaries
|
||||
assert spChk.listDictionaries() == [("en", "difflib")]
|
||||
|
||||
# Description
|
||||
aTag, aName = spChk.describeDict()
|
||||
assert aTag == "en"
|
||||
assert aName == ""
|
||||
|
||||
# END Test testCoreSpell_Simple
|
||||
|
||||
Reference in New Issue
Block a user