RFC: spell checking for QTextEdit

Aurélien Gâteau agateau at kde.org
Wed Aug 7 11:16:23 UTC 2013


Le mercredi 7 août 2013 11:13:53 Aurélien Gâteau a écrit :
> Hi,
> 
> I'd like to reach a decision regarding spell checking for QTextEdit.
> 
> It was initially a Qt5 task:
> 
> "Allow to register a default syntax highlighter type for QTextEdit, the KDE
> backend would register the spell checking one coming from sonnet as default"
> 
> I started working on this task and put together a first patch, but then
> realized it would not be enough: in addition to the syntax highlighter,
> integration with QTextEdit requires context menu support to be able to
> provide suggestions for spelling errors.
> 
> I already have code which integrates Sonnet (our spellchecker component)
> with QTextEdit, in the form of a helper class named (for now)
> Sonnet::TextEditInstaller:
> 
> https://git.reviewboard.kde.org/r/111912/
> 
> 
> There was a discussion on IRC two days ago regarding how transparent should
> spellcheck integration with QTextEdit be, with two possible positions:
> 
> 
> A. Find a way to inject spellchecking in all QTextEdit through either QPA or
> our style.
> 
> Pros:
> - Completely transparent to Qt app developers
> - Porting a KDE app to KF5 is only KTextEdit => QTextEdit
> 
> Cons:
> - Depends on QPA and/or style, so won't always be available depending on the
> platform
> - Could cause problems if spellchecking is injected in QTextEdit where it
> makes no sense to provide this feature (eg. code editor)
> 
> 
> B. Only provide Sonnet::TextEditInstaller, which app developers would then
> have to explicitly use to add spell checking to QTextEdit in their
> applications.
> 
> Pros:
> - No under-the-hood hack
> - Independant from the platform as long as we have Sonnet plugins for it
> - Gives more control to the app developer: for example changing the spelling
> language, adding custom words to ignore, or ignoring blocks of text (think
> quoted email)
> 
> Cons:
> - Requires developers to explicitly use the API, so porting a KDE app to KF5
> is KTextEdit => QTextEdit + use Sonnet::TextEditInstaller.

More on this topic, Alex Fiestas suggested a new option:

C) Add spellchecking to QTextEdit itself:
- Extend QTextEdit with new properties to enable spellchecking, set 
spellchecking language...
- Add a spellcheck syntax highlighter
- Extend QPA to integrate with the platform spellchecking API.

Pros:
- Sounds like the proper way to do it in the long run: it provides proper 
platform integration (Android spellchecking suggestion is not done with a 
context menu for example)
- Could also be used to bring spellchecking to other widgets like QLineEdit? I 
know KMail could use this for its subject line edit, which is right now a 
custom one-line KTextEdit.
- Less work to port KDE apps to KF5: KTextEdit => QTextEdit + calling 
QTextEdit::setSpellCheckingEnabled(true)

Cons:
- More work, not sure it can be done in time for Qt 5.2.


I am tempted to say B) in the short term since it's mostly done, then C), but 
this could mean KDE apps would be first changed to use 
Sonnet::TextEditInstaller, only to drop it when QTextEdit gains the feature.

Aurélien


More information about the Kde-frameworks-devel mailing list