Bug 410934 - Preview of Textfiles are unreadable if using dark theme in Plasma. Affects file thumbnails and Information Panel
Summary: Preview of Textfiles are unreadable if using dark theme in Plasma. Affects fi...
Status: RESOLVED DUPLICATE of bug 406821
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 19.04.3
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-15 13:16 UTC by Matthias Mueller
Modified: 2021-06-03 09:39 UTC (History)
4 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 Matthias Mueller 2019-08-15 13:16:06 UTC
I'm using breeze dark and noticed that when i view textfiles in dolphins information panel, the text there has the default color (white-ish), but also a white background and is thus not readable.

I don't think this is a theming issue as i didn't find any way to set the test color for the preview.

Setting the background of the preview to something other than white could lead to new issues with theming, so i think it would be best to simply default to black text on white ground for the preview?
Comment 1 Christoph Feck 2019-09-09 13:44:01 UTC
Which frameworks version are you using? You can find out with Dolphin menu > Help > About Dolphin > Libraries
Comment 2 Friedrich W. H. Kossebau 2019-09-09 13:49:11 UTC
Qt version is also interesting.
Comment 3 Matthias Mueller 2019-09-09 14:38:14 UTC
Framework is 5.61.0, QT is at 5.13.0.
While verifying that the issue still persists i noticed that some "generic" textfiles do come color-coded (.bashrc and .bash_profile for example) - but this doesn't seem to be caused by the file-content, as when i copy .bashrc to .bashrc1, the new file is white again. But going with .(1).bashrc yields colorcoded - so it seems it's dependent on file extension? After all i would assume that the file extension is parsed to view files like .py, .yml, .sh with colorcoded text?
Comment 4 Matthias Mueller 2019-09-09 14:39:44 UTC
I just noticed that a PKGBUILD file is also colored without any extension, so it's not just that.
Comment 5 James Nelson 2019-09-22 21:47:28 UTC
I have this bug too and wanted to add some info, but I don't have much of a dev environment nor any experience with patching. I'm just using Dolphin and KDE pretty regularly. (Dolphin 19.08.1, frameworks 5.61.0, Qt 5.13.1 built against 5.13.0)

In Dolphin, the font color for text file thumbnails/previews is always this one:

[System Settings] -> [Colors] -> [in selection: Edit Color Scheme...] -> [Color Set: "View"] -> "Normal Text"
or
... [Edit Color Scheme...] -> Common Colors -> "View Text"


In code, I found a light background for the previews/thumbnails of all text files:
https://cgit.kde.org/kio-extras.git/tree/thumbnail/textcreator.cpp
lines 143 & 144:

  QColor bgColor = QColor ( 245, 245, 245 ); // light-grey background
  m_pixmap.fill( bgColor );


Seems this will affect both the preview panel, and the main view's preview-enabled thumbnails. 

If we change textcreator.cpp to have a explicitly black/dark-colors font, then rebuild, does that fix the problem? Can somebody please try this?


More detail of how I was looking for this, tracing up from Dolphin->[kio]->[kio-extras]:

• [dolphin]/src/panels/information/informationpanelapplet.cpp

  connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview,
          this, &InformationPanelContent::showPreview);

• [kio]/src/widgets/previewjob.cpp

  void PreviewJobPrivate::emitPreview(const QImage &thumb)
  {
[...]
          pix = QPixmap::fromImage(thumb);
      }
      emit q->gotPreview(currentItem.item, pix);
  }

• looking for anything that would affect the pixmap, or QPixmap, that PreviewJob needs by streaming text into it:

• [kio-extras]/thumbnail/textcreator.cpp
72  bool TextCreator::create(const QString &path, int width, int height, QImage &img)
73  {
...
113    // create text-preview
114    QFile file( path );
...
143            QColor bgColor = QColor ( 245, 245, 245 ); // light-grey background
144            m_pixmap.fill( bgColor );
145
146            QPainter painter( &m_pixmap );
147
148            QTextDocument textDocument(text);
...
172            textDocument.drawContents(&painter, QRectF(QPointF(0, 0), canvasSize));
...
176            img = m_pixmap.toImage();
...
179        file.close();
...
182 }
Comment 6 Patrick Silva 2021-06-03 09:39:54 UTC

*** This bug has been marked as a duplicate of bug 406821 ***