Bug 222875 - Wrong formatting in Wikipedia applet
Summary: Wrong formatting in Wikipedia applet
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Context View (show other bugs)
Version: 2.3-GIT
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-15 18:07 UTC by Jan-Willem van de Meent
Modified: 2010-04-09 13:18 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.3.1


Attachments
Amarok window showing wikipedia applet rendering error (330.32 KB, image/png)
2010-01-15 18:09 UTC, Jan-Willem van de Meent
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan-Willem van de Meent 2010-01-15 18:07:42 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

In Amarok 2.2.2, after an update to KDE 4.4 RC1, the wikipedia applet does not display pages correctly anymore. It appears as if no stylesheet is being loaded, resulting in standard black text on a white background and wrong image placement. I will attach a screenshot to illustrate the effect.

Everything was working fine in the same version of Amarok running under KDE 4.3.
Comment 1 Jan-Willem van de Meent 2010-01-15 18:09:01 UTC
Created attachment 39916 [details]
Amarok window showing wikipedia applet rendering error
Comment 2 Myriam Schweingruber 2010-01-15 20:01:47 UTC
Confirmed on GIT.
Comment 3 rubberglove 2010-02-03 23:19:42 UTC
Just wanted to mention that I've noticed the same issue with amarok 2.2.2 and KDE 4.4 (both RC2 and now RC3) under fedora 12 (x86_64).
Comment 4 Jan-Willem van de Meent 2010-02-17 16:21:26 UTC
Still present on KDE SC 4.4.0 with Amarok 2.2.2.90
Comment 5 Leo Franchi 2010-02-17 22:51:10 UTC
the code hasn't changed but it seems to be working again for me, using amarok trunk and kde trunk.
Comment 6 Simon ESNEAULT 2010-02-18 10:07:48 UTC
Yep, I've tried to debug that one, it appears that the plasma::WebPage is not loading the css for some reason. We should inform the plasma dev of that regression, but they're probably aware of that if Leo says it's fixed in kde trunk. Mabe we can find a workaround, but I couldn't come out with one :/

-Simon
Comment 7 Jan-Willem van de Meent 2010-02-19 11:02:05 UTC
I've noticed that in 2.2.2.90 right-clicking the widget and selecting 'reload' causes the page the reappear with the default wikipedia formatting. Don't know if this is of help at all...
Comment 8 Simon ESNEAULT 2010-04-09 12:46:20 UTC
commit 598055946efd27922249bf318c8d3d5c325a01ff
Author: Simon Esneault <simon.esneault@gmail.com>
Date:   Fri Apr 9 12:41:01 2010 +0200

    Fix bug 222875. Wikipedia applet was not loading the css due to a QtWebkit regression
    Now we give the css encoded on a base64 to hte QWebPage, and the css is loaded on kde 4.4
    Please test this on other version (4.3 or 4.5)
    Simon
    
    BUG: 222875

diff --git a/src/context/applets/wikipedia/WikipediaApplet.cpp b/src/context/applets/wikipedia/WikipediaApplet.cpp
index dd996f2..20c1b8e 100644
--- a/src/context/applets/wikipedia/WikipediaApplet.cpp
+++ b/src/context/applets/wikipedia/WikipediaApplet.cpp
@@ -43,6 +43,7 @@
 #include <QMenu>
 #include <QWebHistory>
 #include <QWebPage>
+#include <QWebFrame>
 
 
 WikipediaApplet::WikipediaApplet( QObject* parent, const QVariantList& args )
@@ -473,10 +474,16 @@ WikipediaApplet::paletteChanged( const QPalette & palette )
         {
             m_css->write( contents.toLatin1() );
 
-            QString filename = m_css->fileName();
+            // NOTE shall we keep this commented out, and bring it back later or the base64 is just what we need ?
+            //   QString filename = m_css->fileName();
             m_css->close(); // flush buffer to disk
-            debug() << "set user stylesheet to:" << "file://" + filename;
-            m_webView->page()->settings()->setUserStyleSheetUrl( "file://" + filename );
+            //   debug() << "set user stylesheet to:" << "file://" + filename;
+            //   m_webView->page()->settings()->setUserStyleSheetUrl( "file://" + filename );
+
+
+            //NOTE  We give it encoded on a base64
+            // as it is currently broken on QtWebkit (see https://bugs.webkit.org/show_bug.cgi?id=34884 )
+            m_webView->mainFrame()->page()->settings()->setUserStyleSheetUrl( QUrl( QString( "data:text/css;charset=utf-8;base64," + QString( QByteArray( contents.toLatin1() ).toBase64().data() ) ) ) );
         }
     }
 }