SUMMARY When using a dark UI color theme, with the default syntax highligting theme for LightTheme those text regions which would be rendered using "Normal" textstyle appear invisible against bright backgrounds. STEPS TO REPRODUCE 1. Use Plasma, switch to dark color theme "Breeze Dark" 2. In Dolphin, enable preview of "Text Files" (needs KA 19.04) 3. Navigate to folder with text files, e.g. a dir with C++ sources 4. Enable "Preview" for folder, also trigger tooltips & info docker OBSERVED RESULT Rendered text misses out large parts of text to render. EXPECTED RESULT All text is properly rendered in some sane colors against the bright background. Additionally strange is that QColor(highlightingTheme.textColor(KSyntaxHighlighting::Theme::Normal)) is always QColor(ARGB 1, 0.121569, 0.109804, 0.105882). Matching the "text-color" : "#1f1c1b" entry in default.theme. Is there potentially a chance that instead of applying the "Normal" style for such text regions, that the regions stay unformatted in the QTextDocument, and thus Qt's rendering falls back to UI colors?
*** Bug 406745 has been marked as a duplicate of this bug. ***
*** Bug 406404 has been marked as a duplicate of this bug. ***
The issue is that QTextDocument uses the application palette by default. Indeed, looking at the codeeditor code (https://github.com/KDE/syntax-highlighting/blob/master/examples/codeeditor.cpp#L198), we can see that the widget palette is changed whenever the theme is changed: void CodeEditor::setTheme(const KSyntaxHighlighting::Theme &theme) { auto pal = qApp->palette(); if (theme.isValid()) { pal.setColor(QPalette::Base, theme.editorColor(KSyntaxHighlighting::Theme::BackgroundColor)); pal.setColor(QPalette::Text, theme.textColor(KSyntaxHighlighting::Theme::Normal)); pal.setColor(QPalette::Highlight, theme.editorColor(KSyntaxHighlighting::Theme::TextSelection)); } setPalette(pal); m_highlighter->setTheme(theme); m_highlighter->rehighlight(); highlightCurrentLine(); } This part is missing in thumbnail/textcreator.cpp. One fix is to do the following: const QPalette appPalette = qApp->palette(); QPalette pal = appPalette; if (theme.isValid()) { pal.setColor(QPalette::Base, theme.editorColor(KSyntaxHighlighting::Theme::BackgroundColor)); pal.setColor(QPalette::Text, theme.textColor(KSyntaxHighlighting::Theme::Normal)); pal.setColor(QPalette::Highlight, theme.editorColor(KSyntaxHighlighting::Theme::TextSelection)); } qApp->setPalette(pal); // ... do the painting qApp->setPalette(appPalette); @Friedrich: Can you check whether this works? If this is being run in a separate process, then you can even drop reverting to the old palette. Another solution would be to change the SyntaxHighlighter implementation in SyntaxHighligher::applyFormat(), see https://github.com/KDE/syntax-highlighting/blob/master/src/lib/syntaxhighlighter.cpp#L159 There, the part "format.isDefaultTextStyle(theme()) || " needs to be removed, this should work as well.
For reference: The preview was implemented in https://phabricator.kde.org/D19432.
Git commit bbc465981bd55ca5449f5d22e972fccbe994e24f by Dominik Haumann. Committed on 22/05/2019 at 20:09. Pushed by dhaumann into branch 'master'. SyntaxHighlighter: Fix foreground color for text without special highlighting Summary: QTextDocument seems to use the widget palette (or application palette) when drawing text. That is, by default the palette's foreground color is used when no special QTextCharFormat is specified. This patch changes applyFormat() such that the foreground color is always set to avoid the fallback to the QPalette's foreground color. Related: bug 406816 FIXED-IN: 5.59 Test Plan: make && make test + manual testing with the codeeditor example Reviewers: vkrause, cullmann, kossebau Reviewed By: cullmann Subscribers: kwrite-devel, kde-frameworks-devel Tags: #kate, #frameworks Differential Revision: https://phabricator.kde.org/D21295 M +0 -1 examples/codeeditor/codeeditor.cpp M +4 -4 src/lib/syntaxhighlighter.cpp https://commits.kde.org/syntax-highlighting/bbc465981bd55ca5449f5d22e972fccbe994e24f
Git commit 4ec12a850e258de49d2ed7103f82b468939164c1 by Ilia Kats. Committed on 11/12/2019 at 20:08. Pushed by iliakats into branch 'master'. fix preview of plain text files when using dark theme Related: bug 409380 Differential Revision: https://phabricator.kde.org/D25891 M +3 -1 thumbnail/textcreator.cpp https://commits.kde.org/kio-extras/4ec12a850e258de49d2ed7103f82b468939164c1
*** Bug 415624 has been marked as a duplicate of this bug. ***
*** Bug 417809 has been marked as a duplicate of this bug. ***
Hello, Regarding the test plan and seeing the VERSION FIXED IN = 20.04, is it fair to say if one upgrades/installs right now Kubuntu 20.04 from daily build this bug would be fixed? I tested 20.04 daily build 2 days ago and the behavior was not fixed, but I do not know for sure if the updated code was part of that daily build or not. Thanks
It will be fixed in the 20.04 version of KDE applications, not necessarily the 20.04 release of Kubuntu. IIRC they are planning to ship the 19.04 version of KDE applications.
You could ask them to backport this fix though.
Thanks Nate, that's what I thought after posting, the version is related to KDE not Kubuntu, since this is the KDE bugs site. :) I thought I have KDE 19.12.2 applications but I must have been looking at the wrong place for the version I run. I will definately keep an eye on this one, install dev versions of applications if available or ask to backport yes. Thank you for your precise comment.
happy to see this fixed. I guess, this won't enable dark (source colorscheme is hardcoded&binary?) text file previews?
Still getting this bug on updated Kubuntu 20.04. Plain text is white on white, while syntax colored text is displayed as normal. Dolphin 19.12.3 Linux (x86_64) release 5.4.0-52-generic Qt 5.12.8 KDE Plasma 5.18.5, KDE Frameworks 5.68.0 Plasma Color Scheme: Breeze Dark
You have to upgrade to KDE Applications 20.04 or above. 19.12 will not fix it. If you upgrade to Kubuntu 20.10 the issue will be fixed as it uses KDE Apps 20.08.
Thanks! I asked for a backport on launchpad (is that the right place for this? do I need to provide more info?) https://bugs.launchpad.net/ubuntu/+source/dolphin/+bug/1901431
(In reply to Frank from comment #15) > You have to upgrade to KDE Applications 20.04 or above. 19.12 will not fix > it. > > If you upgrade to Kubuntu 20.10 the issue will be fixed as it uses KDE Apps > 20.08. I've just upgraded to Kubuntu 20.10, but the issue persists... :( $ apt list --installed dolphin* dolphin/groovy,now 4:20.08.2-0ubuntu1 amd64 [installed,automatic] $ apt list --installed kde* kde-cli-tools-data/groovy,groovy,now 4:5.19.5-0ubuntu1 all [installed,automatic] kde-cli-tools/groovy,now 4:5.19.5-0ubuntu1 amd64 [installed,automatic] kde-config-gtk-style-preview/groovy,now 4:5.19.5-0ubuntu1 amd64 [installed,automatic] kde-config-gtk-style/groovy,now 4:5.19.5-0ubuntu1 amd64 [installed,automatic] kde-config-screenlocker/groovy,now 5.19.5-0ubuntu1 amd64 [installed,automatic] kde-config-sddm/groovy,now 4:5.19.5-0ubuntu1 amd64 [installed,automatic] kde-config-tablet/groovy,now 3.2.0-3build1 amd64 [installed,automatic] kde-config-whoopsie/groovy,now 15.10ubuntu2 amd64 [installed,automatic] kde-spectacle/groovy,now 20.08.2-0ubuntu1 amd64 [installed,automatic] kde-style-breeze/groovy,now 4:5.19.5-0ubuntu1 amd64 [installed,automatic] kde-style-oxygen-qt5/groovy,now 4:5.19.5-0ubuntu1 amd64 [installed,automatic] kdeconnect/groovy,now 20.08.2-0ubuntu1 amd64 [installed,automatic] kded5/groovy,now 5.74.0-0ubuntu1 amd64 [installed,automatic] kdegraphics-thumbnailers/groovy,now 4:20.08.1-0ubuntu1 amd64 [installed,automatic] kdenetwork-filesharing/groovy,now 4:20.08.1-0ubuntu1 amd64 [installed,automatic] kdeplasma-addons-data/groovy,groovy,now 4:5.19.5-0ubuntu1 all [installed,automatic]
That's interesting. I run the following: KDE Plasma 5.21.5 KDE Framework 5.82.0 QT 5.15.2 Dolphin 21.04.1 I do not have the issue anymore even when I was on older versions of all 4 above. Maybe there is something specific to Kubuntu? Or maybe the fix was pushed forward into a newer version that you don't have yet. I am not actually sure which of the above 4 really fixes the issue. :( I would need someone with more expertise to clarify this.
*** Bug 410934 has been marked as a duplicate of this bug. ***