KDE Color Theme
Open, NormalPublic

Description

Currently, in KTextEditor, we support default colors that are derived from KDE's color scheme, meaning that if you change the KDE color scheme, the colors in KTextEditor also change.

With the current Themes, this is not possible, since a Theme is completely defined through "hard-coded" colors in the .theme files.

If KTextEditor switches to SyntaxHighlighting also for Themes, KTextEditor will loose the feature of using the KDE color scheme.

Is that a problem? What are possible solutions if we still want to support a KDE like color scheme?

Some ideas:

Idea 1:
KTextEditor could have a button "Create Theme for current KDE colors". This then would add a new Theme that is compatible with KDE's color scheme (possibly having the same name as the current KDE color scheme), and the user could change these colors afterwards. However, this requires user actions and is not automatic.

Idea 2:
SyntaxHighlighting could make sure to ship as many color Themes as KDE by default has. Then, in KTextEditor we'd have a checkbox "Follow KDE Color Themes", and whenever the global color scheme changes, we search whether we find a Theme that matches the KDE color theme name, and if we find a match, we choose this one. This would work to some degree, but the drawback is that it requires continous work from our side.

Idea 3:
Again, we add a checkbox "[x] Automatically follow system color scheme", but we simply try to make a smart choice among the color schemes we have. That means: Whenever the system color scheme changes, we try to look for a theme that matches the system background, and choose the one that matches as close as possible.

To me it seems Idea 3 is most feasible, since we just ship some sane default themes in SyntaxHighlighting and let KTextEditor do the work. And if e.g. the system theme is Breeze Dark, we would certainly also pick the Breeze Dark theme, since the backgrounds match...

Opinions?

Maybe we could have a function:

Theme Repository::bestThemeForPalette(const QPalette & palette);

that automatically find the best matching theme?

A bestThemeForPalette() method would indeed be convenient, as all users of this without explicit theme configuration do something like
app.palette().color(QPalette::Base).lightness() < 128 ? repo.defaultTheme(Repository::DarkTheme) : repo.defaultTheme(Repository::LightTheme);