Bug 446222 - Default font color for text file thumbnails is "View Text" but this can be set as white by system theme and the white background of the thumbnail never changes.
Summary: Default font color for text file thumbnails is "View Text" but this can be se...
Status: REPORTED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: icons mode (show other bugs)
Version: 19.12.3
Platform: Ubuntu Linux
: NOR minor
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-29 02:59 UTC by ocalhoun
Modified: 2021-11-29 07:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ocalhoun 2021-11-29 02:59:37 UTC
SUMMARY
Default font color for text file thumbnails is "View Text" but this can be set as white by KDE system theme and the white background of the thumbnail never changes. This is especially likely to happen when using dark/night color schemes. (Previews still load properly for any file that's interpreted as code, such as .py because the context highlighting overrides the font color and makes it readable.)

Solution A) hard-code the font color on text file thumbnails so that it can't be changed by the system theme. This makes sense because the background color can't be changed either.

Solution B) allow changing the background color of text file thumbnails through the system color scheme, and set it to a color that usually contrasts with the "View Text" color.


STEPS TO REPRODUCE
1. In the KDE system settings, change the color scheme so that the "View Text" color is white (or just switch the overall system theme to the pre-installed 'Breeze Dark').
2. In Dolphin, enable text file thumbnails.
3. In Dolphin, open a folder that contains plain text files (.txt or no file extension) that have text in them. 

OBSERVED RESULT
Text file thumbnails show up as 'blank', despite the actual files having text in them. On very close inspection, you might notice that the text is actually there, but colored white against the white background. But it's barely visible and entirely unreadable.

EXPECTED RESULT
Text file thumbnails have black (or other dark color) text against the white background.


SOFTWARE/OS VERSIONS
Linux: Ubuntu 20.04 (with KDE installed on top)
KDE Plasma Version: 5.18.5
KDE Frameworks Version:  5.68.0
Qt Version: 5.12.8

ADDITIONAL INFORMATION
If somebody can point me to where in the code these colors are determined, I'd be happy to try and change it myself.
Anyway, even if this bug is fixed, it will probably be a long time before the newly updated Dolphin version makes it onto the LTS versions of Ubuntu, so I'd very much appreciate the opportunity to fix it on my own PC, even if it means I have to compile my own fork of Dolphin to do so.
(Hopefully, the thumbnails are actually generated by another package, so I could have my own fork or updated version of just that package. That would be ideal.)
Comment 1 ocalhoun 2021-11-29 07:18:14 UTC
I've found the code responsible for this!

https://invent.kde.org/network/kio-extras/-/blob/master/thumbnail/textcreator.cpp
line 131: QColor bgColor = QColor ( 245, 245, 245 ); // light-grey background
This is where the background color is hard-coded.

The font color is probably coming from one of these two lines:
line 142: textDocument.setDefaultFont(font);
line 147 textDocument.setDefaultTextOption(textOption);

Since this seems to be an issue with the KIO repository, I'll see if I can make a but report there instead ... or maybe even a pull request. You can close this if you want to, unless you feel like trying to fix this bug from your end.