Share this post

cubetest in a browser? pffft!

Plasma devel is motoring along at its usual hectic pace. We held meetings with our SoC students last week on IRC and/or Skype and SoK students have begun lining up as well, we have 10 plugins of various types (Plasmoids, DataEngines, Wallpapers..) in kdereview that are waiting for final triaging into the 4.3 release (and a few more that I'm not sure are quite ready yet.. but we'll see :), the bugsquad laid waste to the Plasma bug reports over the weekend and the Plasma team has been up to its usual hyjinks.

Marco added borders around the window previews, which were really needed now that we can show multiple window thumbnails per preview (and we'll be working on making it possible to mouse over those tooltips and select windows from there too :), Rob has been tidying up the extenders and jobs/notifications in the system tray, Sebastian's been working on Akonadi and OpenSocial glue, a number of nice little additions have been made to various widgets (including the often requested "Show applications by name in Kickoff" option), to name a few things off the top of my head.

The new system tray hotness we've been working on is now in extragear/libs/ for 4.3 and we'll be rolling a tarball for for 4.3 and committing our changes to various KDE apps to use the new protocol. So if you come across a check for libknotificationitem, you know where to look now. ;) I'm very excited about that.

It was when I visited, however, that I found my "fun thing to do today": Jos' blog on writing applications with SVG.

"SVG!" I murmured to myself, "I know SVG stuff! Plasma knows SVG stuff! Screw showing it in a web browser, let's try it on Plasma!" Now, Plasma::Svg is not designed for things like Jos' app-in-an-SVG; it is an image painter that uses SVG data to create the pixmaps. That's very, very useful (more so than you might think until you start trying to use SVG to paint interface elements :) but also very, very different from what Jos is doing.

However, Plasma has Plasma::WebView which is a nice little QGraphicsView wrapper around QtWebKit, and QtWebKit comes with an SVG engine that is quite capable of handling Jos' file. Just to check, I threw down a Web Browser plasmoid and loaded the SVG file from disk in it:

(It's a little blocky because I was also playing with the zoom level.)

That wasn't very exciting though: I knew it would work because Aurora Arora uses QtWebKit and Jos had already said it worked in Aurora Arora. So how about a Plasmoid just for Cube Test? In fact, why not do it in Javascript? It turned out to be almost too easy:

Here's the code, all four lines of it:

layout = new LinearLayout(plasmoid); view = new WebView(); layout.addItem(view); view.url = Url(plasmoid.file("images", "cubetest.svg"));

All the magic, of course, is in WebView and the cubetest.svg file. The Plasmoid is fully resizable (yes, the contents scale to match the size of the Plasmoid smoothly) and the SVG is fully interactive. As I started spinning cubes around P. came up and said, "Ooh, what's that? Is it a new game? How do you play it?" :)

You may notice in the above code that the SVG file is fetched from the Plasmoid. It's actually using the Plasma::Package associated with the Plasmoid and finding the cubetest.svg file in the images location. That makes the Plasmoid 100% self-contained: it's the application (cubetest.svg) and the "player" (QtWebKit via Plasma) all in one.

If you have KDE from svn (or, soon enough, 4.3) you can download the Cube Test Plasmoid here, all 4.7k of it, and try it out today!

p.s. I totally missed posting this when I was first sent the link, but one of my presentations from the Student Summit on Sustainability on the social implications of F/OSS is up on Thanks, Pascal, for passing this on and everyone on the organization team that made S3 such a terrific event!

Share this post