Tag Archives: planetkde

WebApps written in QML: Not far from Reality anymore

Have you ever tried to vertically center an element using CSS or wanted an element to just use the whole remaining space or similar things? Did you ever struggle with complex interfaces when writing a modern website? Did you ever use QML for a desktop-app and were in wonder how amazingly it just works? Then there probably was also the point where you thought ”why can’t I just use QML for my webapp?”. So have I.

And in fact it is nearer to reality than you would think: Say hello to QmlWeb.

QmlWeb is a JavaScript library that is able to parse QML-code and create a website out of it using normal HTML/DOM elements and absolute positions within CSS, translating the QML properties into CSS properties. Currently it’s also able to paint into a canvas but as canvas is far less powerful, that’s probably going to be dropped. So using the DOM-backend there is no need for HTML5. The webbrowser needs to support ECMAScript5 for now, though.
QmlWeb is a small project by Lauri Paimen that he’s already developing for a few years now. In the last months, I entered into the development refactoring parts of the library, so by now Lauri yielded the maintainance to me. The biggest part of the credits, though, are due to him.

As of today, I’m proud to announce that QmlWeb will be from now on a KDE-Project.

QmlWeb-Demopage
(A small prototype of a website for QmlWeb – of course written using QML ;) )

QmlWeb of course doesn’t yet support everything Qt’s implementation of QML does, but it already supports a quite usable subset of it. It supports nearly all of the most basic QML syntax. The element types it supports, are

  • Item
  • Rectangle
  • Text
  • Image
  • BorderImage
  • MouseArea
  • Repeater
  • ListModel
  • NumberAnimation
  • SequentialAnimation

Moreover it has support for HTML input elements (Button, TextInput, TextArea are currently supported, more to come).
Positioning using anchors works like a charm, Components work too, so does the signal-slot system. Basic animations work nicely (Animations in QML are most probably far more powerful, but what works in QmlWeb is already quite nice :) ). Keyboard-control is missing as well as States. Layouts (Row, Column, etc.) are currently under development.

Of course there are many more little features missing, but the library is already quite usable. In fact I’m already using it for one webapp, I’m currently writing. There are some places where I’m still using direct html/css, but that’s another nice feature of QmlWeb. You can easily integrate it with normal html/css: QmlWeb exposes the element-id to css-classes, so you can easily include a stylesheet in your surrounding html-file and set all css-properties, you can’t control (yet) with QML, to your QML-element.

That’s soooo awesome! How can I use it?

Just grab the latest code from git://anongit.kde.org/qmlweb, put the qmlweb folder in the same directory like your webpage and put the following code into your index.html:

<!DOCTYPE html>
<html>
    <head>
        <title>QmlWeb Demo</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="../qmlweb/src/parser.js"></script>
        <script type="text/javascript" src="../qmlweb/src/process.js"></script>
        <script type="text/javascript" src="../qmlweb/src/import.js"></script>
        <script type="text/javascript" src="../qmlweb/src/qtcore.js"></script>
    </head>
    <body style="margin: 0;">
        <script type="text/javascript">
            var qmlEngine = new QMLEngine();
            qmlEngine.loadFile("main.qml");
            qmlEngine.start();
        </script>
    </body>
</html>

Then add a file main.qml containing your QML-coded website. (Tip: use “anchors.fill: parent” in your root element to use the whole size of the inner window)

But it can’t do XYZ!!

Well, QmlWeb is not finished, yet. And I’m looking for people willing to help. :)
Just grab the code, fix it and join our mailinglist <this project’s name>@kde.org, join us on #kde-qmlweb on Freenode/irc or get in touch with me, directly: <my nick>@web.de (btw. the project’s name is qmlweb and my nick is akreuzkamp ;) )

Btw.:
I'm going to Akademy 2013! :)

Edit: I added information about how it renders QML to websites (QmlWeb is using normal HTML/DOM elements and absolute positions within CSS, translating the QML properties into CSS properties to paint elements).

Edit2: I corrected the code example, added a tip how to use the full window size and added information about the mailinglist and irc-channel.

Rethinking Virtual Desktops

First of all: This is my first blog-post on planetkde. So I’ll introduce myself:
My name is Anton Kreuzkamp, I am 15 years old and am from Germany (near Frankfurt). I am using KDE for about 3 years now and am developer for about 1½ years. I’m kind of a migrant worker in KDE, I do some feature here, some patch there, but no fix project (so far I’ve contributed to Plasma, KWin and Rekonq but I have plans for Calligra, Kontact and other projects as well).

So let’s come to the real topic of this post.
There were times when people used virtual desktops (VD) to seperate their different activities on the computer. Now KDE has Activities ‒ a much more powerful way to seperate different tasks than VD. So why do we still need virtual desktops? Why do we have two different concepts doing the same? The answer is easy and has been given a dozen times before: Because they are NOT the same, but are made for different kind of tasks. Activities are about… well, activities, a logical separation of different tasks. VD are about extending the available space of  the desktop, where the windows are to many to fit on the screen nicely.

I have never used VD. My windows use to be more than half of my screen in size, so I can’t have multiple windows shown completely on the screen, and even VD don’t help there. But wouldn’t it be nice if you could combine the free space of two virtual desktops? Then a window would fit in that space. But of course you can’t have one half of a window on one VD and the other half on the another VD and still use it. So I implemented this idea in form of a kwin effect:
The Workspace Strap
The Workspace Strap Effect
It allows you to organize your windows on a linear strap, either horizontally or vertically, that supports stepless scrolling. When you press Alt+Meta (configurable) you get a preview of the strap (see above) and can easily scroll by dragging.

But as a picture says more than 1000 words and a screencast is made of a thousand pictures, here’s one for explanation:

http://www.youtube.com/watch?v=lm2z-V7zhus

This implementation is just a kind of experiment to see whether it’s a satisfying experience, to integrate it upstream, it will probably need to be rewritten deeper in Kwin (like virtual desktops or window tiling), but if it’s coming over well I will try to find the time for it.

The code can be found at kde-apps.org or in my personal scratch-repo: git://anongit.kde.org/scratch/akreuzkamp/workspacestrap.git

I appreciate feedback of all kinds.
Have fun.

PS: I tried half a dozen screencast applications and none of it worked. I finally managed to make the screencast using an application not made for taking screencasts but to display videos: VLC media player. Real time encoding, full HD-quality with 20fps, no performance regressions (on my machine), without crashes. Thanks a lot to the VLC team.