Thoughts on the "default syntax highlighter for QTextEdit" task

Aurélien Gâteau agateau at kde.org
Mon Aug 5 10:23:27 UTC 2013


Le lundi 5 août 2013 11:02:32 Kevin Krammer a écrit :
> On Thursday, 2013-08-01, Aurélien Gâteau wrote:
> > Should work, but extending the QPlatformIntegration class for such a
> > feature feels a bit overkill to me. Is there a simpler alternative?
>
> If at all then QPlatformIntegration is probably the wrong place, more like
> QPlatformTheme (which handles things more similar like native menu, native
> dialogs).

I simplified my original design already by dropping the factory class and 
adding a createDefaultSyntaxHighlighter() method to QPlatformIntegration, but 
I agree doing it in QPlatformTheme makes more sense.

> Interestingly there must be another type of runtime loading somewhere
> because the QKdeTheme can obviously not depend on any KDE code at build
> time.

Looking at QKdeTheme code, it implements everything using Qt-only code, but 
kdelibs/staging/frameworkintegration/src/platformtheme/kdeplatformtheme.* 
provides another implementation of QPlatformTheme, which is where we could 
implement the creation of the default highligher.
> 
> I wonder if syntax highlighting is not something that should be up to the
> style?

I pushed a first version of the patch here:

https://codereview.qt-project.org/#change,62119

But people are not really sold to the idea so far.

I am afraid adding this default syntax highlighter is not going to be enough 
to get proper spell checking anyway: we need to extend the context menu to 
provide suggestions for mistyped words, something which cannot be provided by 
the syntax highlighter.

Not sure what is the best course of action there, except making spell-checking 
a feature provided by frameworks, which developers would have to explicitly 
enable on their QTextEdit. This would also address one of the comments I got 
from the review which asked how to disable the default highlighter.

Aurélien


More information about the Kde-frameworks-devel mailing list