Bug 406404 - No previews for text/plain files
Summary: No previews for text/plain files
Status: RESOLVED DUPLICATE of bug 406821
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: Thumbnails and previews (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL: https://phabricator.kde.org/D20766
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-10 13:10 UTC by Eugene Shalygin
Modified: 2019-04-24 02:18 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Works for me (12.17 KB, image/png)
2019-04-12 18:11 UTC, Nate Graham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Shalygin 2019-04-10 13:10:07 UTC
SUMMARY

Previews for plain text files always shown as empty. 


STEPS TO REPRODUCE
1. Enable previews for text files.
2. Navigate to a directory with such file.
3. Hover mouse over the file

OBSERVED RESULT

Preview image show no content. 
EXPECTED RESULT

Preview image show actual file content.
SOFTWARE/OS VERSIONS
Qt Version: 5.12.1
KDE from git master
ADDITIONAL INFORMATION

I've tried to build debug version of kio-extras and symlink debug texttumbnail.so to the system. Seems like dolphin does not even call ThumbCreator *new_creator();

All the other thumbnailers work, for example the one for HTML files.
Comment 1 Patrick Silva 2019-04-11 23:00:21 UTC
I can confirm.

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.15.80
KDE Frameworks Version: 5.57.0
Qt Version: 5.12.0
Comment 2 Nate Graham 2019-04-12 18:11:18 UTC
Created attachment 119387 [details]
Works for me

Works for me in the latest Neon Dev Unstable.
Comment 3 maxmustermann1884 2019-04-22 20:48:23 UTC
maybe related to this?
https://bugs.kde.org/show_bug.cgi?id=406745

https://i.imgur.com/Cph7xuc.png -> file preview works, but text-color=background-color
Comment 4 Eugene Shalygin 2019-04-23 09:36:32 UTC
Yes, thanks!

I got previews back with these changes:

diff --git a/thumbnail/CMakeLists.txt b/thumbnail/CMakeLists.txt
index 966039d0..00978725 100644
--- a/thumbnail/CMakeLists.txt
+++ b/thumbnail/CMakeLists.txt
@@ -95,6 +95,7 @@ target_link_libraries(textthumbnail
     Qt5::Gui
     KF5::KIOWidgets
     KF5::SyntaxHighlighting
+    KF5::ConfigWidgets
 )
 
 install(TARGETS textthumbnail DESTINATION ${KDE_INSTALL_PLUGINDIR})
diff --git a/thumbnail/textcreator.cpp b/thumbnail/textcreator.cpp
index 8bdab821..806ffe25 100644
--- a/thumbnail/textcreator.cpp
+++ b/thumbnail/textcreator.cpp
@@ -33,6 +33,7 @@
 #include <KSyntaxHighlighting/Theme>
 #include <KSyntaxHighlighting/Definition>
 #include <KDesktopFile>
+#include <KColorScheme>
 
 // TODO Fix or remove kencodingprober code
 // #include <kencodingprober.h>
@@ -136,8 +137,7 @@ bool TextCreator::create(const QString &path, int width, int height, QImage &img
                 }
             }
 
-            QColor bgColor = QColor ( 245, 245, 245 ); // light-grey background
-            m_pixmap.fill( bgColor );
+            m_pixmap.fill( KColorScheme(QPalette::Active).background().color() );
 
             QPainter painter( &m_pixmap );
Comment 5 maxmustermann1884 2019-04-23 11:13:45 UTC
*** Bug 406745 has been marked as a duplicate of this bug. ***
Comment 6 Friedrich W. H. Kossebau 2019-04-23 16:33:14 UTC
Seems caused by bug #406821 in KF5's KSyntaxHighlighting.
Comment 7 Nate Graham 2019-04-24 02:18:55 UTC

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