Wed, 16 Jun 2021 17:47:50 +0200
Changed some dialogs to use the new QTextEdit and QPlainTextEdit subclasses with spell checker.
--- a/eric7/APIs/Python3/eric7.api Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/APIs/Python3/eric7.api Wed Jun 16 17:47:50 2021 +0200 @@ -1629,9 +1629,11 @@ eric7.EricWidgets.EricSpellCheckedTextEdit.EricSpellCheckedPlainTextEdit?1(*args) eric7.EricWidgets.EricSpellCheckedTextEdit.EricSpellCheckedTextEdit.setAcceptRichText?4(accept) eric7.EricWidgets.EricSpellCheckedTextEdit.EricSpellCheckedTextEdit?1(*args) +eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin.DefaultLanguage?7 eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin.MaxSuggestions?7 eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin.contextMenuEvent?4(evt) eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin.dict?4() +eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin.setDefaultLanguage?4(language) eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin.setDict?4(spellDict) eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin.setFormat?4(formatName) eric7.EricWidgets.EricSpellCheckedTextEdit.SpellCheckMixin?1()
--- a/eric7/Documentation/Help/source.qhp Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Documentation/Help/source.qhp Wed Jun 16 17:47:50 2021 +0200 @@ -13658,6 +13658,7 @@ <keyword name="SpellCheckMixin.__setLanguage" id="SpellCheckMixin.__setLanguage" ref="eric7.EricWidgets.EricSpellCheckedTextEdit.html#SpellCheckMixin.__setLanguage" /> <keyword name="SpellCheckMixin.contextMenuEvent" id="SpellCheckMixin.contextMenuEvent" ref="eric7.EricWidgets.EricSpellCheckedTextEdit.html#SpellCheckMixin.contextMenuEvent" /> <keyword name="SpellCheckMixin.dict" id="SpellCheckMixin.dict" ref="eric7.EricWidgets.EricSpellCheckedTextEdit.html#SpellCheckMixin.dict" /> + <keyword name="SpellCheckMixin.setDefaultLanguage" id="SpellCheckMixin.setDefaultLanguage" ref="eric7.EricWidgets.EricSpellCheckedTextEdit.html#SpellCheckMixin.setDefaultLanguage" /> <keyword name="SpellCheckMixin.setDict" id="SpellCheckMixin.setDict" ref="eric7.EricWidgets.EricSpellCheckedTextEdit.html#SpellCheckMixin.setDict" /> <keyword name="SpellCheckMixin.setFormat" id="SpellCheckMixin.setFormat" ref="eric7.EricWidgets.EricSpellCheckedTextEdit.html#SpellCheckMixin.setFormat" /> <keyword name="SpellChecker" id="SpellChecker" ref="eric7.QScintilla.SpellChecker.html#SpellChecker" />
--- a/eric7/Documentation/Source/eric7.EricWidgets.EricSpellCheckedTextEdit.html Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Documentation/Source/eric7.EricWidgets.EricSpellCheckedTextEdit.html Wed Jun 16 17:47:50 2021 +0200 @@ -63,8 +63,8 @@ <h2>EnchantHighlighter</h2> <p> - Class implementing a QSyntaxHighlighter subclass that consults a - pyEnchant dictionary to highlight misspelled words. + Class implementing a QSyntaxHighlighter subclass that consults a + pyEnchant dictionary to highlight misspelled words. </p> <h3>Derived from</h3> QSyntaxHighlighter @@ -118,7 +118,7 @@ <b>EnchantHighlighter</b>(<i>*args</i>) <p> - Constructor + Constructor </p> <dl> @@ -132,7 +132,7 @@ <b>chunkers</b>(<i></i>) <p> - Public method to get the chunkers in use. + Public method to get the chunkers in use. </p> <dl> <dt>Return:</dt> @@ -151,7 +151,7 @@ <b>dict</b>(<i></i>) <p> - Public method to get the spelling dictionary in use. + Public method to get the spelling dictionary in use. </p> <dl> <dt>Return:</dt> @@ -170,7 +170,7 @@ <b>highlightBlock</b>(<i>text</i>) <p> - Public method to apply the text highlight. + Public method to apply the text highlight. </p> <dl> @@ -184,7 +184,7 @@ <b>setChunkers</b>(<i>chunkers</i>) <p> - Public method to set the chunkers to be used. + Public method to set the chunkers to be used. </p> <dl> @@ -198,7 +198,7 @@ <b>setDict</b>(<i>spellDict</i>) <p> - Public method to set the spelling dictionary to be used. + Public method to set the spelling dictionary to be used. </p> <dl> @@ -214,7 +214,7 @@ <h2>EricSpellCheckedPlainTextEdit</h2> <p> - Class implementing a QPlainTextEdit with built-in spell checker. + Class implementing a QPlainTextEdit with built-in spell checker. </p> <h3>Derived from</h3> QPlainTextEdit, SpellCheckMixin @@ -248,7 +248,7 @@ <b>EricSpellCheckedPlainTextEdit</b>(<i>*args</i>) <p> - Constructor + Constructor </p> <dl> @@ -264,7 +264,7 @@ <h2>EricSpellCheckedTextEdit</h2> <p> - Class implementing a QTextEdit with built-in spell checker. + Class implementing a QTextEdit with built-in spell checker. </p> <h3>Derived from</h3> QTextEdit, SpellCheckMixin @@ -302,7 +302,7 @@ <b>EricSpellCheckedTextEdit</b>(<i>*args</i>) <p> - Constructor + Constructor </p> <dl> @@ -316,7 +316,7 @@ <b>setAcceptRichText</b>(<i>accept</i>) <p> - Public method to set the text edit mode. + Public method to set the text edit mode. </p> <dl> @@ -332,19 +332,23 @@ <h2>SpellCheckMixin</h2> <p> - Class implementing the spell-check mixin for the widget classes. + Class implementing the spell-check mixin for the widget classes. </p> <h3>Derived from</h3> None <h3>Class Attributes</h3> <table> -<tr><td>MaxSuggestions</td></tr> +<tr><td>DefaultLanguage</td></tr><tr><td>MaxSuggestions</td></tr> </table> <h3>Class Methods</h3> <table> -<tr><td>None</td></tr> + +<tr> +<td><a href="#SpellCheckMixin.setDefaultLanguage">setDefaultLanguage</a></td> +<td>Class method to set the default spell-check language.</td> +</tr> </table> <h3>Methods</h3> @@ -409,20 +413,34 @@ <tr><td>None</td></tr> </table> +<a NAME="SpellCheckMixin.setDefaultLanguage" ID="SpellCheckMixin.setDefaultLanguage"></a> +<h4>SpellCheckMixin.setDefaultLanguage (class method)</h4> +<b>setDefaultLanguage</b>(<i>language</i>) + +<p> + Class method to set the default spell-check language. +</p> +<dl> + +<dt><i>language</i> (str)</dt> +<dd> +language to be set as default +</dd> +</dl> <a NAME="SpellCheckMixin.__init__" ID="SpellCheckMixin.__init__"></a> <h4>SpellCheckMixin (Constructor)</h4> <b>SpellCheckMixin</b>(<i></i>) <p> - Constructor + Constructor </p> <a NAME="SpellCheckMixin.__correctWord" ID="SpellCheckMixin.__correctWord"></a> <h4>SpellCheckMixin.__correctWord</h4> <b>__correctWord</b>(<i>act</i>) <p> - Private slot to correct the misspelled word with the selected - correction. + Private slot to correct the misspelled word with the selected + correction. </p> <dl> @@ -436,7 +454,8 @@ <b>__createCorrectionsMenu</b>(<i>cursor, parent=None</i>) <p> - Private method to create a menu for corrections of the selected word. + Private method to create a menu for corrections of the selected + word. </p> <dl> @@ -466,7 +485,7 @@ <b>__createFormatsMenu</b>(<i>parent=None</i>) <p> - Private method to create a menu for selecting the document format. + Private method to create a menu for selecting the document format. </p> <dl> @@ -492,7 +511,8 @@ <b>__createLanguagesMenu</b>(<i>parent=None</i>) <p> - Private method to create a menu for selecting the spell-check language. + Private method to create a menu for selecting the spell-check + language. </p> <dl> @@ -518,7 +538,7 @@ <b>__createSpellcheckContextMenu</b>(<i>pos</i>) <p> - Private method to create the spell-check context menu. + Private method to create the spell-check context menu. </p> <dl> @@ -544,7 +564,8 @@ <b>__cursorForMisspelling</b>(<i>pos</i>) <p> - Private method to create a text cursor selecting the misspelled word. + Private method to create a text cursor selecting the misspelled + word. </p> <dl> @@ -570,7 +591,7 @@ <b>__setFormat</b>(<i>act</i>) <p> - Private slot to set the selected document format. + Private slot to set the selected document format. </p> <dl> @@ -584,7 +605,7 @@ <b>__setLanguage</b>(<i>act</i>) <p> - Private slot to set the selected language. + Private slot to set the selected language. </p> <dl> @@ -598,8 +619,8 @@ <b>contextMenuEvent</b>(<i>evt</i>) <p> - Protected method to handle context menu events to add a spelling - suggestions submenu. + Protected method to handle context menu events to add a spelling + suggestions submenu. </p> <dl> @@ -613,7 +634,7 @@ <b>dict</b>(<i></i>) <p> - Public method to get a reference to the dictionary in use. + Public method to get a reference to the dictionary in use. </p> <dl> <dt>Return:</dt> @@ -632,7 +653,7 @@ <b>setDict</b>(<i>spellDict</i>) <p> - Public method to set the dictionary to be used. + Public method to set the dictionary to be used. </p> <dl> @@ -646,7 +667,7 @@ <b>setFormat</b>(<i>formatName</i>) <p> - Public method to set the document format. + Public method to set the document format. </p> <dl>
--- a/eric7/EricWidgets/EricPlainTextDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/EricWidgets/EricPlainTextDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -18,7 +18,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QPlainTextEdit" name="textEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="textEdit"> <property name="readOnly"> <bool>true</bool> </property> @@ -39,6 +39,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <resources/> <connections> <connection>
--- a/eric7/EricWidgets/EricSpellCheckedTextEdit.py Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/EricWidgets/EricSpellCheckedTextEdit.py Wed Jun 16 17:47:50 2021 +0200 @@ -8,12 +8,16 @@ checking. """ -import sys +import contextlib -import enchant -from enchant import tokenize -from enchant.errors import TokenizerNotFoundError, DictNotFoundError -from enchant.utils import trim_suggestions +try: + import enchant + import enchant.tokenize + from enchant.errors import TokenizerNotFoundError, DictNotFoundError + from enchant.utils import trim_suggestions + ENCHANT_AVAILABLE = True +except ImportError: + ENCHANT_AVAILABLE = False from PyQt6.QtCore import pyqtSlot, Qt, QCoreApplication from PyQt6.QtGui import ( @@ -24,395 +28,429 @@ # TODO: add user dictionaries with respective menu entries - -class SpellCheckMixin(): - """ - Class implementing the spell-check mixin for the widget classes. - """ - # don't show more than this to keep the menu manageable - MaxSuggestions = 20 - - def __init__(self): +if ENCHANT_AVAILABLE: + class SpellCheckMixin(): """ - Constructor + Class implementing the spell-check mixin for the widget classes. """ - self.__highlighter = EnchantHighlighter(self.document()) - try: - # Start with a default dictionary based on the current locale. - spellDict = enchant.Dict() - except DictNotFoundError: - # Use English dictionary if no locale dictionary is available. - spellDict = enchant.Dict("en") - self.__highlighter.setDict(spellDict) - - def contextMenuEvent(self, evt): - """ - Protected method to handle context menu events to add a spelling - suggestions submenu. + # don't show more than this to keep the menu manageable + MaxSuggestions = 20 + + # default language to be used when no other is set + DefaultLanguage = None - @param evt reference to the context menu event - @type QContextMenuEvent - """ - menu = self.__createSpellcheckContextMenu(evt.pos()) - menu.exec(evt.globalPos()) - - def __createSpellcheckContextMenu(self, pos): - """ - Private method to create the spell-check context menu. + def __init__(self): + """ + Constructor + """ + self.__highlighter = EnchantHighlighter(self.document()) + try: + # Start with a default dictionary based on the current locale. + spellDict = ( + enchant.Dict(SpellCheckMixin.DefaultLanguage) + if bool(SpellCheckMixin.DefaultLanguage) else + enchant.Dict() + ) + except DictNotFoundError: + # Use English dictionary if no locale dictionary is available + # or the default one could not be found. + spellDict = enchant.Dict("en") + self.__highlighter.setDict(spellDict) + + def contextMenuEvent(self, evt): + """ + Protected method to handle context menu events to add a spelling + suggestions submenu. + + @param evt reference to the context menu event + @type QContextMenuEvent + """ + menu = self.__createSpellcheckContextMenu(evt.pos()) + menu.exec(evt.globalPos()) - @param pos position of the mouse pointer - @type QPoint - @return context menu with additional spell-check entries - @rtype QMenu - """ - menu = self.createStandardContextMenu(pos) - - # Add a submenu for setting the spell-check language and - # document format. - menu.addSeparator() - menu.addMenu(self.__createLanguagesMenu(menu)) - menu.addMenu(self.__createFormatsMenu(menu)) - - # Try to retrieve a menu of corrections for the right-clicked word - spellMenu = self.__createCorrectionsMenu( - self.__cursorForMisspelling(pos), menu) + def __createSpellcheckContextMenu(self, pos): + """ + Private method to create the spell-check context menu. + + @param pos position of the mouse pointer + @type QPoint + @return context menu with additional spell-check entries + @rtype QMenu + """ + menu = self.createStandardContextMenu(pos) + + # Add a submenu for setting the spell-check language and + # document format. + menu.addSeparator() + menu.addMenu(self.__createLanguagesMenu(menu)) + menu.addMenu(self.__createFormatsMenu(menu)) + + # Try to retrieve a menu of corrections for the right-clicked word + spellMenu = self.__createCorrectionsMenu( + self.__cursorForMisspelling(pos), menu) + + if spellMenu: + menu.insertSeparator(menu.actions()[0]) + menu.insertMenu(menu.actions()[0], spellMenu) + + return menu - if spellMenu: - menu.insertSeparator(menu.actions()[0]) - menu.insertMenu(menu.actions()[0], spellMenu) - - return menu - - def __createCorrectionsMenu(self, cursor, parent=None): - """ - Private method to create a menu for corrections of the selected word. - - @param cursor reference to the text cursor - @type QTextCursor - @param parent reference to the parent widget (defaults to None) - @type QWidget (optional) - @return menu with corrections - @rtype QMenu - """ - if cursor is None: + def __createCorrectionsMenu(self, cursor, parent=None): + """ + Private method to create a menu for corrections of the selected + word. + + @param cursor reference to the text cursor + @type QTextCursor + @param parent reference to the parent widget (defaults to None) + @type QWidget (optional) + @return menu with corrections + @rtype QMenu + """ + if cursor is None: + return None + + text = cursor.selectedText() + suggestions = trim_suggestions( + text, self.__highlighter.dict().suggest(text), + SpellCheckMixin.MaxSuggestions) + + spellMenu = QMenu( + QCoreApplication.translate("SpellCheckMixin", + "Spelling Suggestions"), + parent) + for word in suggestions: + act = spellMenu.addAction(word) + act.setData((cursor, word)) + + # Only return the menu if it's non-empty + if spellMenu.actions(): + spellMenu.triggered.connect(self.__correctWord) + return spellMenu + return None - text = cursor.selectedText() - suggestions = trim_suggestions(text, - self.__highlighter.dict().suggest(text), - SpellCheckMixin.MaxSuggestions) - - spellMenu = QMenu( - QCoreApplication.translate("SpellCheckMixin", - "Spelling Suggestions"), - parent) - for word in suggestions: - act = spellMenu.addAction(word) - act.setData((cursor, word)) - - # Only return the menu if it's non-empty - if spellMenu.actions(): - spellMenu.triggered.connect(self.__correctWord) - return spellMenu - - return None - - def __createLanguagesMenu(self, parent=None): - """ - Private method to create a menu for selecting the spell-check language. - - @param parent reference to the parent widget (defaults to None) - @type QWidget (optional) - @return menu with spell-check languages - @rtype QMenu - """ - curLanguage = self.__highlighter.dict().tag - languageMenu = QMenu( - QCoreApplication.translate("SpellCheckMixin", "Language"), - parent) - languageActions = QActionGroup(languageMenu) + def __createLanguagesMenu(self, parent=None): + """ + Private method to create a menu for selecting the spell-check + language. + + @param parent reference to the parent widget (defaults to None) + @type QWidget (optional) + @return menu with spell-check languages + @rtype QMenu + """ + curLanguage = self.__highlighter.dict().tag.lower() + languageMenu = QMenu( + QCoreApplication.translate("SpellCheckMixin", "Language"), + parent) + languageActions = QActionGroup(languageMenu) + + for language in sorted(enchant.list_languages()): + act = QAction(language, languageActions) + act.setCheckable(True) + act.setChecked(language.lower() == curLanguage) + act.setData(language) + languageMenu.addAction(act) + + languageMenu.triggered.connect(self.__setLanguage) + return languageMenu - for language in enchant.list_languages(): - act = QAction(language, languageActions) - act.setCheckable(True) - act.setChecked(language == curLanguage) - act.setData(language) - languageMenu.addAction(act) - - languageMenu.triggered.connect(self.__setLanguage) - return languageMenu - - def __createFormatsMenu(self, parent=None): - """ - Private method to create a menu for selecting the document format. - - @param parent reference to the parent widget (defaults to None) - @type QWidget (optional) - @return menu with document formats - @rtype QMenu - """ - formatMenu = QMenu( - QCoreApplication.translate("SpellCheckMixin", "Format"), - parent) - formatActions = QActionGroup(formatMenu) - - curFormat = self.__highlighter.chunkers() - for name, chunkers in ( - (QCoreApplication.translate("SpellCheckMixin", "Text"), - []), - (QCoreApplication.translate("SpellCheckMixin", "HTML"), - [tokenize.HTMLChunker]) - ): - act = QAction(name, formatActions) - act.setCheckable(True) - act.setChecked(chunkers == curFormat) - act.setData(chunkers) - formatMenu.addAction(act) + def __createFormatsMenu(self, parent=None): + """ + Private method to create a menu for selecting the document format. + + @param parent reference to the parent widget (defaults to None) + @type QWidget (optional) + @return menu with document formats + @rtype QMenu + """ + formatMenu = QMenu( + QCoreApplication.translate("SpellCheckMixin", "Format"), + parent) + formatActions = QActionGroup(formatMenu) + + curFormat = self.__highlighter.chunkers() + for name, chunkers in ( + (QCoreApplication.translate("SpellCheckMixin", "Text"), + []), + (QCoreApplication.translate("SpellCheckMixin", "HTML"), + [enchant.tokenize.HTMLChunker]) + ): + act = QAction(name, formatActions) + act.setCheckable(True) + act.setChecked(chunkers == curFormat) + act.setData(chunkers) + formatMenu.addAction(act) + + formatMenu.triggered.connect(self.__setFormat) + return formatMenu - formatMenu.triggered.connect(self.__setFormat) - return formatMenu - - def __cursorForMisspelling(self, pos): - """ - Private method to create a text cursor selecting the misspelled word. - - @param pos position of the misspelled word - @type QPoint - @return text cursor for the misspelled word - @rtype QTextCursor - """ - cursor = self.cursorForPosition(pos) - misspelledWords = getattr(cursor.block().userData(), "misspelled", []) + def __cursorForMisspelling(self, pos): + """ + Private method to create a text cursor selecting the misspelled + word. + + @param pos position of the misspelled word + @type QPoint + @return text cursor for the misspelled word + @rtype QTextCursor + """ + cursor = self.cursorForPosition(pos) + misspelledWords = getattr(cursor.block().userData(), + "misspelled", []) + + # If the cursor is within a misspelling, select the word + for (start, end) in misspelledWords: + if start <= cursor.positionInBlock() <= end: + blockPosition = cursor.block().position() + + cursor.setPosition(blockPosition + start, + QTextCursor.MoveMode.MoveAnchor) + cursor.setPosition(blockPosition + end, + QTextCursor.MoveMode.KeepAnchor) + break + + if cursor.hasSelection(): + return cursor + else: + return None - # If the cursor is within a misspelling, select the word - for (start, end) in misspelledWords: - if start <= cursor.positionInBlock() <= end: - blockPosition = cursor.block().position() - - cursor.setPosition(blockPosition + start, - QTextCursor.MoveMode.MoveAnchor) - cursor.setPosition(blockPosition + end, - QTextCursor.MoveMode.KeepAnchor) - break + @pyqtSlot(QAction) + def __correctWord(self, act): + """ + Private slot to correct the misspelled word with the selected + correction. + + @param act reference to the selected action + @type QAction + """ + cursor, word = act.data() + + cursor.beginEditBlock() + cursor.removeSelectedText() + cursor.insertText(word) + cursor.endEditBlock() - if cursor.hasSelection(): - return cursor - else: - return None - - @pyqtSlot(QAction) - def __correctWord(self, act): - """ - Private slot to correct the misspelled word with the selected - correction. - - @param act reference to the selected action - @type QAction - """ - cursor, word = act.data() + @pyqtSlot(QAction) + def __setLanguage(self, act): + """ + Private slot to set the selected language. + + @param act reference to the selected action + @type QAction + """ + language = act.data() + self.__highlighter.setDict(enchant.Dict(language)) - cursor.beginEditBlock() - cursor.removeSelectedText() - cursor.insertText(word) - cursor.endEditBlock() - - @pyqtSlot(QAction) - def __setLanguage(self, act): - """ - Private slot to set the selected language. + @pyqtSlot(QAction) + def __setFormat(self, act): + """ + Private slot to set the selected document format. + + @param act reference to the selected action + @type QAction + """ + chunkers = act.data() + self.__highlighter.setChunkers(chunkers) - @param act reference to the selected action - @type QAction - """ - language = act.data() - self.__highlighter.setDict(enchant.Dict(language)) - - @pyqtSlot(QAction) - def __setFormat(self, act): - """ - Private slot to set the selected document format. + def setFormat(self, formatName): + """ + Public method to set the document format. + + @param formatName name of the document format + @type str + """ + self.__highlighter.setChunkers( + [enchant.tokenize.HTMLChunker] + if format == "html" else + [] + ) - @param act reference to the selected action - @type QAction - """ - chunkers = act.data() - self.__highlighter.setChunkers(chunkers) - - def setFormat(self, formatName): - """ - Public method to set the document format. + def dict(self): + """ + Public method to get a reference to the dictionary in use. + + @return reference to the current dictionary + @rtype enchant.Dict + """ + return self.__highlighter.dict() - @param formatName name of the document format - @type str - """ - self.__highlighter.setChunkers( - [tokenize.HTMLChunker] - if format == "html" else - [] - ) - - def dict(self): + def setDict(self, spellDict): + """ + Public method to set the dictionary to be used. + + @param spellDict reference to the spell-check dictionary + @type emchant.Dict + """ + self.__highlighter.setDict(spellDict) + + @classmethod + def setDefaultLanguage(cls, language): + """ + Class method to set the default spell-check language. + + @param language language to be set as default + @type str + """ + with contextlib.suppress(DictNotFoundError): + # set default language only, if a dictionary is available + enchant.Dict(language) + cls.DefaultLanguage = language + + class EnchantHighlighter(QSyntaxHighlighter): """ - Public method to get a reference to the dictionary in use. - - @return reference to the current dictionary - @rtype enchant.Dict - """ - return self.__highlighter.dict() - - def setDict(self, spellDict): - """ - Public method to set the dictionary to be used. - - @param spellDict reference to the spell-check dictionary - @type emchant.Dict - """ - self.__highlighter.setDict(spellDict) - - -class EnchantHighlighter(QSyntaxHighlighter): - """ - Class implementing a QSyntaxHighlighter subclass that consults a - pyEnchant dictionary to highlight misspelled words. - """ - TokenFilters = (tokenize.EmailFilter, tokenize.URLFilter) - - # Define the spell-check style once and just assign it as necessary - ErrorFormat = QTextCharFormat() - ErrorFormat.setUnderlineColor(Qt.GlobalColor.red) - ErrorFormat.setUnderlineStyle( - QTextCharFormat.UnderlineStyle.SpellCheckUnderline) - - def __init__(self, *args): - """ - Constructor - - @param *args list of arguments for the QSyntaxHighlighter - @type list - """ - QSyntaxHighlighter.__init__(self, *args) - - self.__spellDict = None - self.__chunkers = [] - - def chunkers(self): - """ - Public method to get the chunkers in use. - - @return list of chunkers in use - @rtype list - """ - return self.__chunkers - - def setChunkers(self, chunkers): - """ - Public method to set the chunkers to be used. - - @param chunkers chunkers to be used - @type list - """ - self.__chunkers = chunkers - self.setDict(self.dict()) - - def dict(self): - """ - Public method to get the spelling dictionary in use. - - @return spelling dictionary - @rtype enchant.Dict - """ - return self.__spellDict - - def setDict(self, spellDict): - """ - Public method to set the spelling dictionary to be used. - - @param spellDict spelling dictionary - @type enchant.Dict + Class implementing a QSyntaxHighlighter subclass that consults a + pyEnchant dictionary to highlight misspelled words. """ - try: - self.__tokenizer = tokenize.get_tokenizer( - spellDict.tag, - chunkers=self.__chunkers, - filters=EnchantHighlighter.TokenFilters) - except TokenizerNotFoundError: - # Fall back to the "good for most euro languages" English tokenizer - self.__tokenizer = tokenize.get_tokenizer( - chunkers=self.__chunkers, - filters=EnchantHighlighter.TokenFilters) - self.__spellDict = spellDict - - self.rehighlight() - - def highlightBlock(self, text): - """ - Public method to apply the text highlight. - - @param text text to be spell-checked - @type str - """ - """Overridden QSyntaxHighlighter method to apply the highlight""" - if not self.__spellDict: - return - - # Build a list of all misspelled words and highlight them - misspellings = [] - for (word, pos) in self.__tokenizer(text): - if not self.__spellDict.check(word): - self.setFormat(pos, len(word), EnchantHighlighter.ErrorFormat) - misspellings.append((pos, pos + len(word))) - - # Store the list so the context menu can reuse this tokenization pass - # (Block-relative values so editing other blocks won't invalidate them) - data = QTextBlockUserData() - data.misspelled = misspellings - self.setCurrentBlockUserData(data) - + TokenFilters = (enchant.tokenize.EmailFilter, + enchant.tokenize.URLFilter) -class EricSpellCheckedPlainTextEdit(QPlainTextEdit, SpellCheckMixin): - """ - Class implementing a QPlainTextEdit with built-in spell checker. - """ - def __init__(self, *args): - """ - Constructor + # Define the spell-check style once and just assign it as necessary + ErrorFormat = QTextCharFormat() + ErrorFormat.setUnderlineColor(Qt.GlobalColor.red) + ErrorFormat.setUnderlineStyle( + QTextCharFormat.UnderlineStyle.SpellCheckUnderline) + + def __init__(self, *args): + """ + Constructor + + @param *args list of arguments for the QSyntaxHighlighter + @type list + """ + QSyntaxHighlighter.__init__(self, *args) + + self.__spellDict = None + self.__chunkers = [] + + def chunkers(self): + """ + Public method to get the chunkers in use. + + @return list of chunkers in use + @rtype list + """ + return self.__chunkers + + def setChunkers(self, chunkers): + """ + Public method to set the chunkers to be used. + + @param chunkers chunkers to be used + @type list + """ + self.__chunkers = chunkers + self.setDict(self.dict()) + + def dict(self): + """ + Public method to get the spelling dictionary in use. + + @return spelling dictionary + @rtype enchant.Dict + """ + return self.__spellDict - @param *args list of arguments for the QPlainTextEdit constructor. - @type list - """ - QPlainTextEdit.__init__(self, *args) - SpellCheckMixin.__init__(self) - + def setDict(self, spellDict): + """ + Public method to set the spelling dictionary to be used. + + @param spellDict spelling dictionary + @type enchant.Dict + """ + try: + self.__tokenizer = enchant.tokenize.get_tokenizer( + spellDict.tag, + chunkers=self.__chunkers, + filters=EnchantHighlighter.TokenFilters) + except TokenizerNotFoundError: + # Fall back to the "good for most euro languages" + # English tokenizer + self.__tokenizer = enchant.tokenize.get_tokenizer( + chunkers=self.__chunkers, + filters=EnchantHighlighter.TokenFilters) + self.__spellDict = spellDict + + self.rehighlight() + + def highlightBlock(self, text): + """ + Public method to apply the text highlight. + + @param text text to be spell-checked + @type str + """ + """Overridden QSyntaxHighlighter method to apply the highlight""" + if not self.__spellDict: + return + + # Build a list of all misspelled words and highlight them + misspellings = [] + for (word, pos) in self.__tokenizer(text): + if not self.__spellDict.check(word): + self.setFormat(pos, len(word), + EnchantHighlighter.ErrorFormat) + misspellings.append((pos, pos + len(word))) + + # Store the list so the context menu can reuse this tokenization + # pass (Block-relative values so editing other blocks won't + # invalidate them) + data = QTextBlockUserData() + data.misspelled = misspellings + self.setCurrentBlockUserData(data) -class EricSpellCheckedTextEdit(QTextEdit, SpellCheckMixin): - """ - Class implementing a QTextEdit with built-in spell checker. - """ - def __init__(self, *args): + class EricSpellCheckedPlainTextEdit(QPlainTextEdit, SpellCheckMixin): + """ + Class implementing a QPlainTextEdit with built-in spell checker. """ - Constructor - - @param *args list of arguments for the QPlainTextEdit constructor. - @type list + def __init__(self, *args): + """ + Constructor + + @param *args list of arguments for the QPlainTextEdit constructor. + @type list + """ + QPlainTextEdit.__init__(self, *args) + SpellCheckMixin.__init__(self) + + class EricSpellCheckedTextEdit(QTextEdit, SpellCheckMixin): + """ + Class implementing a QTextEdit with built-in spell checker. """ - QTextEdit.__init__(self, *args) - SpellCheckMixin.__init__(self) + def __init__(self, *args): + """ + Constructor + + @param *args list of arguments for the QPlainTextEdit constructor. + @type list + """ + QTextEdit.__init__(self, *args) + SpellCheckMixin.__init__(self) + + self.setFormat("html") - self.setFormat("html") - - def setAcceptRichText(self, accept): - """ - Public method to set the text edit mode. - - @param accept flag indicating to accept rich text - @type bool - """ - QTextEdit.setAcceptRichText(accept) - self.setFormat("html" if accept else "text") + def setAcceptRichText(self, accept): + """ + Public method to set the text edit mode. + + @param accept flag indicating to accept rich text + @type bool + """ + QTextEdit.setAcceptRichText(self, accept) + self.setFormat("html" if accept else "text") +else: + # enchant not available + EricSpellCheckedPlainTextEdit = QPlainTextEdit + EricSpellCheckedTextEdit = QTextEdit if __name__ == '__main__': + import sys from PyQt6.QtWidgets import QApplication + if ENCHANT_AVAILABLE: + SpellCheckMixin.setDefaultLanguage("en_US") + app = QApplication(sys.argv) spellEdit = EricSpellCheckedPlainTextEdit() spellEdit.show()
--- a/eric7/MultiProject/AddProjectDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/MultiProject/AddProjectDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -74,7 +74,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="QTextEdit" name="descriptionEdit"> + <widget class="EricSpellCheckedTextEdit" name="descriptionEdit"> <property name="toolTip"> <string>Enter a short description for the project</string> </property> @@ -135,6 +135,11 @@ <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> </customwidgets> <tabstops> <tabstop>nameEdit</tabstop>
--- a/eric7/MultiProject/PropertiesDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/MultiProject/PropertiesDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -1,7 +1,8 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>PropertiesDialog</class> - <widget class="QDialog" name="PropertiesDialog" > - <property name="geometry" > + <widget class="QDialog" name="PropertiesDialog"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> @@ -9,41 +10,41 @@ <height>227</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>Multiproject Properties</string> </property> - <property name="sizeGripEnabled" > + <property name="sizeGripEnabled"> <bool>true</bool> </property> - <layout class="QVBoxLayout" > + <layout class="QVBoxLayout"> <item> - <layout class="QGridLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="descriptionLabel" > - <property name="text" > + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="descriptionLabel"> + <property name="text"> <string>&Description:</string> </property> - <property name="alignment" > + <property name="alignment"> <set>Qt::AlignTop</set> </property> - <property name="buddy" > + <property name="buddy"> <cstring>descriptionEdit</cstring> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QTextEdit" name="descriptionEdit" > - <property name="toolTip" > + <item row="0" column="1"> + <widget class="EricSpellCheckedTextEdit" name="descriptionEdit"> + <property name="toolTip"> <string>Enter description</string> </property> - <property name="whatsThis" > - <string><b>Description</b> -<p>Enter a short description for the multiproject.</p></string> + <property name="whatsThis"> + <string><b>Description</b> +<p>Enter a short description for the multiproject.</p></string> </property> - <property name="tabChangesFocus" > + <property name="tabChangesFocus"> <bool>true</bool> </property> - <property name="acceptRichText" > + <property name="acceptRichText"> <bool>false</bool> </property> </widget> @@ -51,17 +52,24 @@ </layout> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="standardButtons" > + <property name="standardButtons"> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> </property> </widget> </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>descriptionEdit</tabstop> <tabstop>buttonBox</tabstop> @@ -74,11 +82,11 @@ <receiver>PropertiesDialog</receiver> <slot>accept()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>248</x> <y>254</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>157</x> <y>274</y> </hint> @@ -90,11 +98,11 @@ <receiver>PropertiesDialog</receiver> <slot>reject()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>316</x> <y>260</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>286</x> <y>274</y> </hint>
--- a/eric7/Plugins/VcsPlugins/vcsGit/GitCommitDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsGit/GitCommitDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -21,7 +21,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QTextEdit" name="logEdit"> + <widget class="EricSpellCheckedTextEdit" name="logEdit"> <property name="toolTip"> <string>Enter the log message.</string> </property> @@ -97,6 +97,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>logEdit</tabstop> <tabstop>recentComboBox</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsGit/GitMergeDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsGit/GitMergeDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -148,7 +148,7 @@ </widget> </item> <item> - <widget class="QPlainTextEdit" name="commitMessageEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="commitMessageEdit"> <property name="toolTip"> <string>Enter a message for the merge commit</string> </property> @@ -192,6 +192,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>idButton</tabstop> <tabstop>idEdit</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/HgCloseHeadSelectionDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/CloseheadExtension/HgCloseHeadSelectionDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -61,7 +61,7 @@ </widget> </item> <item> - <widget class="QTextEdit" name="logEdit"> + <widget class="EricSpellCheckedTextEdit" name="logEdit"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -88,6 +88,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>headsList</tabstop> <tabstop>logEdit</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -202,7 +202,7 @@ </widget> </item> <item> - <widget class="QPlainTextEdit" name="messageEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="messageEdit"> <property name="toolTip"> <string>Enter a commit message (leave empty to use default)</string> </property> @@ -264,6 +264,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>numberButton</tabstop> <tabstop>numberSpinBox</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgBackoutDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgBackoutDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -199,7 +199,7 @@ </widget> </item> <item> - <widget class="QPlainTextEdit" name="messageEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="messageEdit"> <property name="toolTip"> <string>Enter the commit message or leave empty to use the default one</string> </property> @@ -271,6 +271,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>numberButton</tabstop> <tabstop>numberSpinBox</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -21,7 +21,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QTextEdit" name="logEdit"> + <widget class="EricSpellCheckedTextEdit" name="logEdit"> <property name="toolTip"> <string>Enter the log message.</string> </property> @@ -167,6 +167,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>logEdit</tabstop> <tabstop>recentComboBox</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgImportDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgImportDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -44,7 +44,7 @@ </widget> </item> <item> - <widget class="QPlainTextEdit" name="messageEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="messageEdit"> <property name="enabled"> <bool>false</bool> </property> @@ -218,6 +218,11 @@ <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> </customwidgets> <tabstops> <tabstop>noCommitCheckBox</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditCommitEditor.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditCommitEditor.ui Wed Jun 16 17:47:50 2021 +0200 @@ -28,7 +28,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_3"> <item> - <widget class="QPlainTextEdit" name="messageEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="messageEdit"> <property name="toolTip"> <string>Edit the commit message</string> </property> @@ -59,7 +59,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QPlainTextEdit" name="infoEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="infoEdit"> <property name="readOnly"> <bool>true</bool> </property> @@ -81,6 +81,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesFoldDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesFoldDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -28,7 +28,7 @@ </widget> </item> <item row="0" column="1"> - <widget class="QPlainTextEdit" name="messageEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="messageEdit"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -240,6 +240,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>messageEdit</tabstop> <tabstop>sourcePatches</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesNewPatchDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesNewPatchDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -42,7 +42,7 @@ </widget> </item> <item row="1" column="1"> - <widget class="QPlainTextEdit" name="messageEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="messageEdit"> <property name="toolTip"> <string>Enter the commit message for the patch</string> </property> @@ -163,6 +163,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>nameEdit</tabstop> <tabstop>messageEdit</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsPySvn/SvnCommitDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsPySvn/SvnCommitDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -21,7 +21,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QTextEdit" name="logEdit"> + <widget class="EricSpellCheckedTextEdit" name="logEdit"> <property name="toolTip"> <string>Enter the log message.</string> </property> @@ -93,6 +93,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>logEdit</tabstop> <tabstop>recentComboBox</tabstop>
--- a/eric7/Plugins/VcsPlugins/vcsSubversion/SvnCommitDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsSubversion/SvnCommitDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -21,7 +21,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QTextEdit" name="logEdit"> + <widget class="EricSpellCheckedTextEdit" name="logEdit"> <property name="toolTip"> <string>Enter the log message.</string> </property> @@ -93,6 +93,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>logEdit</tabstop> <tabstop>recentComboBox</tabstop>
--- a/eric7/Plugins/WizardPlugins/EricMessageBoxWizard/EricMessageBoxWizardDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/WizardPlugins/EricMessageBoxWizard/EricMessageBoxWizardDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -180,7 +180,7 @@ </widget> </item> <item> - <widget class="QTextEdit" name="eMessage"> + <widget class="EricSpellCheckedTextEdit" name="eMessage"> <property name="toolTip"> <string>Enter the message to be shown in the message box</string> </property> @@ -529,6 +529,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>rInformation</tabstop> <tabstop>rQuestion</tabstop>
--- a/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/WizardPlugins/EricPluginWizard/PluginWizardDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -175,7 +175,7 @@ </widget> </item> <item row="7" column="1" colspan="2"> - <widget class="QPlainTextEdit" name="longDescriptionEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="longDescriptionEdit"> <property name="toolTip"> <string>Enter the long description</string> </property> @@ -494,6 +494,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>projectButton</tabstop> <tabstop>dataTabWidget</tabstop>
--- a/eric7/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/WizardPlugins/MessageBoxWizard/MessageBoxWizardDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -140,7 +140,7 @@ </widget> </item> <item> - <widget class="QTextEdit" name="eMessage"> + <widget class="EricSpellCheckedTextEdit" name="eMessage"> <property name="toolTip"> <string>Enter the message to be shown in the QMessageBox</string> </property> @@ -381,6 +381,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>rInformation</tabstop> <tabstop>rQuestion</tabstop>
--- a/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -307,7 +307,7 @@ </widget> </item> <item row="1" column="1"> - <widget class="QPlainTextEdit" name="descriptionEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="descriptionEdit"> <property name="toolTip"> <string>Enter the description of the package or files (one per line) to get it from.</string> </property> @@ -889,6 +889,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>introCheckBox</tabstop> <tabstop>importCheckBox</tabstop>
--- a/eric7/Project/PropertiesDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Project/PropertiesDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -348,7 +348,7 @@ </widget> </item> <item row="13" column="1"> - <widget class="QTextEdit" name="descriptionEdit"> + <widget class="EricSpellCheckedTextEdit" name="descriptionEdit"> <property name="toolTip"> <string>Enter description</string> </property> @@ -426,6 +426,11 @@ <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> </customwidgets> <tabstops> <tabstop>nameEdit</tabstop>
--- a/eric7/Tasks/TaskPropertiesDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/Tasks/TaskPropertiesDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -48,7 +48,7 @@ </widget> </item> <item row="1" column="1"> - <widget class="QTextEdit" name="descriptionEdit"> + <widget class="EricSpellCheckedTextEdit" name="descriptionEdit"> <property name="toolTip"> <string>Enter the task description</string> </property> @@ -250,6 +250,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>summaryEdit</tabstop> <tabstop>descriptionEdit</tabstop>
--- a/eric7/UI/EmailDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/UI/EmailDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -56,7 +56,7 @@ </widget> </item> <item> - <widget class="QTextEdit" name="message"> + <widget class="EricSpellCheckedTextEdit" name="message"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -179,6 +179,13 @@ </layout> </widget> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <customwidgets> + <customwidget> + <class>EricSpellCheckedTextEdit</class> + <extends>QTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>subject</tabstop> <tabstop>message</tabstop>
--- a/eric7/UI/InstallInfoDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/UI/InstallInfoDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -185,7 +185,7 @@ </widget> </item> <item> - <widget class="QPlainTextEdit" name="remarksEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="remarksEdit"> <property name="toolTip"> <string/> </property> @@ -215,6 +215,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>installedFromEdit</tabstop> <tabstop>interpreteEdit</tabstop>
--- a/eric7/UI/UserInterface.py Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/UI/UserInterface.py Wed Jun 16 17:47:50 2021 +0200 @@ -743,6 +743,11 @@ SpellChecker.setDefaultLanguage( Preferences.getEditor("SpellCheckingDefaultLanguage")) + with contextlib.suppress(ImportError, AttributeError): + from EricWidgets.EricSpellCheckedTextEdit import SpellCheckMixin + SpellCheckMixin.setDefaultLanguage( + Preferences.getEditor("SpellCheckingDefaultLanguage")) + # attributes for the last shown configuration page and the # extended configuration entries self.__lastConfigurationPageName = "" @@ -6202,6 +6207,11 @@ SpellChecker.setDefaultLanguage( Preferences.getEditor("SpellCheckingDefaultLanguage")) + with contextlib.suppress(ImportError, AttributeError): + from EricWidgets.EricSpellCheckedTextEdit import SpellCheckMixin + SpellCheckMixin.setDefaultLanguage( + Preferences.getEditor("SpellCheckingDefaultLanguage")) + if self.__layoutType == "Sidebars": delay = Preferences.getUI("SidebarDelay") self.leftSidebar.setDelay(delay)
--- a/eric7/WebBrowser/Bookmarks/AddBookmarkDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/WebBrowser/Bookmarks/AddBookmarkDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -80,7 +80,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="QPlainTextEdit" name="descriptionEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="descriptionEdit"> <property name="toolTip"> <string>Enter a description</string> </property> @@ -108,6 +108,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>nameEdit</tabstop> <tabstop>addressEdit</tabstop>
--- a/eric7/WebBrowser/Bookmarks/BookmarkPropertiesDialog.ui Tue Jun 15 19:42:36 2021 +0200 +++ b/eric7/WebBrowser/Bookmarks/BookmarkPropertiesDialog.ui Wed Jun 16 17:47:50 2021 +0200 @@ -68,7 +68,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="QPlainTextEdit" name="descriptionEdit"> + <widget class="EricSpellCheckedPlainTextEdit" name="descriptionEdit"> <property name="toolTip"> <string>Enter a description</string> </property> @@ -93,6 +93,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>EricSpellCheckedPlainTextEdit</class> + <extends>QPlainTextEdit</extends> + <header>EricWidgets/EricSpellCheckedTextEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>nameEdit</tabstop> <tabstop>addressEdit</tabstop>