Thomas Zander
KDE
KOffice
Posted by Thomas Zander
 in KDE, KOffice
 on Tuesday, March 31, 2009 @ 20:10

So I had to do some writing today and I thought, lets use KWord 2.0-Release Candidate for that. Eating your own dogfood and all that.
After a day of using the application in its default setup I am kind of pleased with it. Its obviously not an application that is going to replace any concurrence in its current state (the 2.0 release is aimed at integrators and basic users) but the actual typing of text and the usage of the basic features is good. I can write my docs in there.

That said, I had 2 crashes over the whole (10 hour) working day, both fixed in the RC, I fixed some loading/saving issues as well. And my todo list got quite a bit longer ;)

Overall I think that the upcoming KWord2-release candidate is an enormous step forward from the latest beta. A speed of innovation and bug-crushing that I hope to see continue till the actual release (when its ready!). For people that can live without various features we had to omit in the 2.0 release I think the upcoming release will be a very cool basis platform for productivity applications.

ps. Yes, KWord will actually fully save and load the text, shapes etc that you can add in the app, in the upcoming Release Candidate. Finally! I know some of you have been asking about that ;)

Jens
Uncategorized
Qt
Styles
Posted by Jens
 in Uncategorized, Qt, Styles
 on Tuesday, March 31, 2009 @ 13:31

There are a few widgets in Qt that have been treated a bit like a stepchild to other widgets. One of these widgets is the QDial. To a certain extent this has been intentional. A normal flat slider is almost always a better choice usability wise and most platforms do not have a native equivalent so it has been left looking a bit out of place everywhere. In fact the only face lift it has received since Qt 3 days is a bit of anti-aliasing. In case you haven’t seen it, here it is in all it’s glory:

old dial

However lately there has been an increased interest in touch screen devices where QDial seems to make a bit more sense usability wise. Combined with the fact that it has always been an eye-sore in our styles example I decided to finally do something about it for 4.6. So here is the new and improved QDial:

new dial 2

As you see it’s a bit more shiny. It replaces the ugly focus rect with a subtle glow and it’s designed to look more like something more out of this century. Old styles like motif and windows classic will still get the old looks because that’s what they are… old, but on all our modern styles we will use the new one. I hope you like the change.

styles example
Edit: Added a new screenshot in a few different styles also showing the increased contrast.

Jörg
Qt
Labs
Posted by Jörg
 in Qt, Labs
 on Friday, March 27, 2009 @ 15:08

Poor, poor Visual C++ developer. You see these MinGW or Linux guys using GNU make on their fancy quad core machines to compile Qt. They are already hacking again while you still sip at your coffee, watching the distressing 25% CPU usage in the task manager. And just because nmake doesn’t make use of all available processing power.

But good news, everyone! The misery is over. I’ve writte a nmake clone that can use an arbitrary number of processes concurrently. The thing is called jom and the sources are here, a ZIP with the binary is available for download here.

To install jom, just extract the zip file to a directory which is in your PATH. Now, instead of calling nmake to build Qt, call jom. It automatically detects the number of processor cores in your PC by calling QThread::idealThreadCount().
You also can use the -j command line argument to set the number of concurrent processes.

On a quad core machine with a Qt build takes half of the time it took using nmake. There’s still room for improvement. Jom is aimed to be compatible with decent nmake Makefiles. Its not complete yet but hey, you can already speed up your Qt builds!

Update:
This project moved to gitorious! The source can now be found here:
http://qt.gitorious.org/qt-labs/jom

Leonardo
Labs
Graphics
Kinetic
Posted by Leonardo
 in Labs, Graphics, Kinetic
 on Friday, March 27, 2009 @ 14:34

Following the good habit of release early, release often: here we have yet another qt solutions release: the QtAnimationFramework 2.2 (and since 2.1 it’s LGPL too \o/)

It’s mainly a refinement of the previous version, after a round of API review and incorporating all the feedback we got internally and externally. One main modification was to rename QtAnimation to QtVariantAnimation (this was to scare most users away from using QtVariantAnimation directly, as this is an abstract class). Apart from that, we did some minor API modifications in QtVariantAnimation, QtAnimationGroup and QtSequentialAnimationGroup and several bugfixes.

This solution also includes the code to the AnimatedTiles example that was previously posted here, by Andreas.

We are also providing an example class CustomPropertyAnimation, in the sub-attaq demo, which shows how to animate QGraphicsItem (you can also use it to animate your own classes). You just need to provide your specific getter and setter functions. Another nice feature of the sub-attaq demo is that it’s now using the statemachine API for coding the game logic (that’s really cool, more details will follow in a separate blog post)!

As the animation framework is approaching a fairly stable stage now, we are looking forward for it being used in more and more applications. The animation framework is a fundamental piece, on which the other pieces of the bigger kinetic project will build upon, such as the declarative UI (this alone deserves a separate post too). Therefore all the work on creating your animations now will be worth in the future.

Our next step regarding the animation framework is to integrate into qt 4.6 and after that there will be no more solution releases :)

Hope you have fun and looking forward for your feedback!

Harald Fernengel
Qt
 in Qt
 on Monday, March 23, 2009 @ 10:52

You may have already seen our Embedded Widgets Demo. We got a lot of good feedback, including lots of requests for the source code. Therefore, I’m happy to announce that the sources are now available.

Within the project you will find a collection of industrial style widgets - mainly for touch screen interaction. In addition there are two example applications (Patient Care and Catalog), which serve as a showcase for these widgets. Here’s a video featuring our lovely Carol:

The emphasis of this demo is on SVG and CSS use and how both these techniques can be combined to build an easy to use, industrial looking
user interface. The target audience for such a UI would for example be an operator in a factory, who is used to physical knobs and turning dials.

Although this demo is mainly targeted at and tested for our embedded platforms (Embedded Linux, Windows CE), it also runs fine on X11 (for example on the N810 with the Qt/Hildon integration), and even on a Mac OS X or Windows desktop.

The heavy use of SVGs paired with transformations, gradients, anti-aliasing and other effects comes with a cost, though: for Qt for Embedded Linux, we suggest to use the configure switch -D QT_COORD_TYPE=double, which will increase the rendering quality.

Ariya Hidayat
Graphics Dojo
XML
Posted by Ariya Hidayat
 in Graphics Dojo, XML
 on Friday, March 20, 2009 @ 07:47

According to the FAQ, Google Suggest "guesses what you’re typing and offers suggestions in real time". You can try it easily, just go to Google search page with the suggest feature and start typing something in the search field. Wouldn’t it be nice if we can have that feature (where it makes sense) in our Qt-based applications? For example, the search box in the web browser demo is one candidate. In fact, that is one little feature I plan to add to the browser demo for Qt 4.6.

Since it will be quite some time until Qt 4.6 shows up, I thought I’d simplify the reference implementation and make it as an example. Since there is no official API for Google Suggest, we will use the trick (as explained in many places before) of parsing the XML returned by Google for certain search term. For example, "qt software" will give the following exemplary result.

<toplevel>
  <CompleteSuggestion>
    <suggestion data="qt software download"/>
    <num_queries int="633000"/>
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="qt software nokia"/>
    <num_queries int="441000"/>
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="qt software development"/>
    <num_queries int="716000"/>
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="qt software toolkit"/>
    <num_queries int="446000"/>
  </CompleteSuggestion>
  </toplevel>

Quite simple, isn’t it? An instance of QXmlStreamReader and a dozen of lines are all we need for a quick-and-dirty parser for this piece of XML. For the pop-up, two-column list is necessary. Intentionally I refrained from using QCompleter nor Model/View for the sake of keeping the code as readable as possible. Once the user picks a search term, the default browser is launched (via QDesktopServices) with the proper Google search URL for that particular term.

Get the example from the usual git repository. Don’t want to use git? Get snapshot (105 KB) and unpack it. You can use Qt >= 4.4.

Careful readers might notice that I included the DragMove Charm. Indeed, this makes the search box movable by just dragging it around. Since there is no title bar and thus there is not a close button, just press Escape if you want to quit.

The obligatory screencast (only 11 seconds) follows. Or watch it directly on YouTube or blip.tv or grab the Ogg Theora video (450 KB).

As an exercise for the reader, rewrite the parsing code to use XLST 2.0 instead (it is new in QtXmlPatters in Qt 4.5). And while you are there, you can fix the parser so that it handles the XML properly (not just quick skipping the elements). In addition, forming the right URLs (both for suggestion and launching the browser) can use some encoding fixes as well. And who else also wants Yahoo! search suggest?

Ariya Hidayat
Graphics Dojo
Posted by Ariya Hidayat
 in Graphics Dojo
 on Friday, March 20, 2009 @ 07:37

It is about time for another charm. By charm here, I mean something that you can cast to your existing code (e.g. without changing the class implementation) to get new magical functionalities. You saw the Flick Charm before, as an example.

Today we uncover the secret to make a window (usually the top-level widget) movable by mouse dragging. This trick is employed for example in applications which have custom window decoration, like Apple iTunes or Google Chrome. In these applications, the title bar is not the actual native title bar from the window system. Yet you can "grab" it and use it to move the window around. You may encounter similar behavior in many different web widgets (not in the sense of QWidget), be it Dashboard widgets, Microsoft gadgets, plasmoids, Google gadgets, and so on.

The secret is of course by (ab)using the event filter. Thus, making your window movable-by-dragging is a matter of writing the code:

DragMoveCharm charm;
charm.activateOn(window);

(At the risk of repeating myself, no code for window needs to be touched).

Any mouse events will be monitored and if they indicate the dragging, the window will be repositioned appropriately. Of course, the trick here is to apply the charm to the top-level window which serves as the outermost frame of your application. A wrong way to use it is e.g. instantiating a QWebView instance and applying there, because now the mouse can’t be used to scroll or select text.

Get the example for the usual git repository. Don’t want to use git? Just grab the snapshot archive (103 KB) and unpack it. You need either Qt 4.4 or Qt 4.5.

And here is a 30-second screencast that demonstrates the charm. Watch in on YouTube, blip.tv, or get the Ogg Theora video (3.7 MB).

Thomas Zander
KDE
Posted by Thomas Zander
 in KDE
 on Wednesday, March 18, 2009 @ 17:41

Quite some time ago, 3 summers some may count, the plan and work started on what was to become KOffice2.
We are reaching our first major milestone which is the 2.0 release. Minimal application functionality and lots of useful new technology, but most importantly lots of ability to extend and enhance the apps without having to work on the core libraries or applications.

The release of 2.0 will appeal mostly to users that want to play with the new concepts and the power of flake. ODF interoperability is a major drive, and will continue to be. At the cost of some user-level features. So apologies to those that enjoy mail merge. Thats postponed to a later version.
The upcoming 2.0 release will also be a technology breading ground. Combining the power of the Qt libraries with the power of Office applications has been our major goal from the beginning.

I expect that the 2.0 release is out or in its final phase when the Summer of Code of 2009 starts. This gives those students that want to apply a great many creative things to choose from, I bet most are so new or different that people have not really considered them.
So here is a list of things I came up with over the last years;

  • use qtwebkit to write a KOffice plugin that allows you to navigate openClipArt.org and download your clipart. It would naturally insert the clipart directly into your KOffice document.
  • Write text-shape plugins
    Just to give you some direction of what this implies, here are two examples;
    • A plugin that recognizes (media)wiki type markup and replaces it with KWord style markup.
    • Colorization plugin. For those that publish pieces with sourcecode, being able to colorize text is a really useful tool.
  • We have a music shape that was started in a previous Summer of code, but its not nearly reached its full potential.
  • The 2.0 release of KOffice lacks the formula component while the 1.x version had a pretty good one. We need to have someone create a formula flake-shape.
  • Create a flake-shape that downloads a vector based map from OpenStreetMap. The selection of the area can be done via marble or via qtwebkit and after downloading the flake shape should be able to paint the contents on screen allowing users to easilly insert a map into their KOffice documents.
  • Create various borders that can be added to any KoShape. There is a border plugin type that allows you to create any sort of border. No longer just silly lined borders.

On the topic of KOffice2.0 and its upcoming release; userbase.kde.org will be used more as a place to put information that the end user will find attractive. The first step has been the import of the KWord manual into http://userbase.kde.org/KWord/Manual . Big hand goes to Anne Wilson who has put a lot of time into that. As this manual is old we should get some interested people together to update the manual to the current version.

Anyone interested in any of the above things; please contact the koffice team at the mailinglist or on irc.freenode.org on #koffice

Morten Johan Sørvig
Qt
 in Qt
 on Wednesday, March 18, 2009 @ 09:42

OS X architectures: transitions within transitions within transitions

With the 4.5.0 release Qt gained 64-bit support on OS X using the Cocoa framework. The Mac binary package remained with Carbon for backwards compatibility, but at the same time there was no Cocoa binary package. This is probably extremely bad marketing on the Mac team part (creating a new feature and then not making it easily accessible), but then again none of us were hired for our marketing abilities.

So without further apologies, here’s a test version of the open source binary Cocoa package. The package is not officially supported. If everything goes according to plan, we’ll have supported commercial packages available for 4.5.1.

The package contains an universal build for 32/64/ppc/intel systems running OS X Leopard or higher. Four architectures is probably a bit too much for a binary package (the debug libs weigh in at 500 MB). x86_64 is here to stay, but which of the others should be removed? Leave a comment and we’ll see who gets voted off the island.

TomCooksey
Painting
Graphics
Posted by TomCooksey
 in Painting, Graphics
 on Friday, March 13, 2009 @ 17:32

I am one of our QWS developers. QWS, the Qt Window System, is the heart of Qt for Embedded Linux, formally Qtopia Core, formally Qt/Embedded. :-) What’s great about working on embedded is that you have a view of the system as a whole - the complete stack. So it’s my job to have a pretty good idea how QPainter commands you write in a widget’s paint event end up as voltage levels rapidly alternating between +3.3v and 0v on wires going to your LCD. While QWS handles all the usual window system tasks such as keyboard focus and mouse events, the biggest component is probably graphics. The window system is inherently part of the graphics stack and I actually spend a lot of my time working with the graphics team.

Over the last year our clear focus has been on performance. This performance push has been in all areas on all platforms and architectures. When it comes to graphics, there’s a very broad range of hardware Qt can expect to see - from a simple MMU-less ARM with only a frame-buffer all the way to scary gamer PCs with thousands of graphics cards & neon lights installed. Our lives are made complicated because if we’re not careful, one can end up writing code which runs faster on that little arm than it does on the gamer PC. This post hopes to explain why this is so.

Let’s begin by categorising the range of hardware available:

First, we need to differentiate Unified Memory Architecture (UMA) devices from those with dedicated graphics memory. Generally, high-end hardware will have dedicated graphics memory whereas low-end devices will just use system memory (sometimes reserving a memory region, sometimes not). This is pretty strait forward on PCs - You can almost tell from a PC’s price tag if it has dedicated graphics memory. Sadly, in the world of embedded devices, this is not the case. High-end devices often have UMA and low-end devices (especially set-top-boxes) have dedicated graphics memory.

The next differentiation is the graphics operations supported by the hardware. Generally they are wide ranging but can be loosely categorised as:

1) No acceleration (framebuffer only)
2) Blitter & alpha-blending hardware
3) Path based 2D vector graphics
4) Fixed-function 3D
5) Programmable 3D

Hardware with no acceleration whatsoever or a simple video overlay is the most common we see in embedded devices. This will always be the case until someone figures out how to design and manufacture silicon for free. Blitter and alpha-blending hardware is almost non-existent on desktops these days, but it does seem to still be around in the current generation of embedded hardware. Path based 2D vector graphics is pretty new and looks ready to replace blitter-only style hardware. NOTE: This does not refer to hardware which can draw a 1-pixel wide, non-anti-aliased, non-dashed, solid-colour line without clipping. Fixed-function 3D tends to be the older generation of desktop graphics processors. Generally, fixed function has pretty much been replaced with programmable 3D. This is even the case on mobile hardware.

So, there’s five categories of operations and two types of memory architecture leading to ten different overall types of graphics hardware. I’ve collected an example of each, just so you know we don’t make this stuff up. :-)

Type UMA Non-UMA
None Marvel PXA270 Various*
Blitter NXP PNX8935** Fujitsu Lime MB86276***
2D vector Freescale i.MX35
Fixed-3D Freescale i.MX31 nVidia GeForce 2
Programmable-3D TI OMAP3530 AMD Radeon HD 4600

* Various: Some devices use dedicated framebuffer memory to reduce load on the system memory bus
** NXP PNX8935: http://www.nxp.com/applications/set_top_box/ip_stb/stb225/
*** Fujitsu Lime MB86276: http://www.fujitsu.com/downloads/MICRO/fma/pdf/MB86276.pdf

The next question then becomes: How can Qt off-load graphics operations to these different types of hardware? Well this is done through Qt’s QPaintEngine API. The idea is that Qt applications (& Qt itself of course) always uses QPainter, which in turn uses one of the paint engines. To take advantage of graphics acceleration, we write a new paint engine (like the OpenGL ES 2.0 engine we’ve added in 4.5.0). The advantage is that existing applications can benefit from new rendering back ends and new applications can still work on older or less advanced hardware (albeit with lower performance). There seems to be a misconception in the community that Qt is out-of-date because it has no OpenGL scene graph API. While that statement is technically correct, Qt does have QGraphicsView scene graph API which uses QPainter. Because it uses QPainter, if OpenGL (for example) is available, it can be used as the rendering back end.

So, now that’s cleared up, what QPaintEngines are there and do we have all the hardware acceleration types covered by them?

Well, for devices with no acceleration, Qt will use it’s raster paint engine. The raster engine has seen some very impressive optimizations in Qt 4.5, as Gunnar has previously blogged about. For higher end graphics hardware, there’s usually a nice high-level API which is powerful enough to express all of QPainter. I.e. OpenGL & OpenVG. The trouble we’ve recently hit is the hardware in-between, I.e. those with blitters but not much else. Such hardware is not powerful enough to express the whole of QPainter, so we must fall back to the raster paint engine for unsupported operations. The raster paint engine needs a pointer to the memory it renders to (and reads from). On UMA systems, this is not a problem as the buffer is obviously in system memory (that’s all there is!). It’s on systems with dedicated graphics memory where the fun begins…

First, on many systems, you simply can not map graphics memory into your process’ address space - The architecture simply has no way to do it. On such systems, the buffer must be copied to system memory, rendered to with the raster engine, then copied back. If this happens _every_ time you switch between a fall-back and the hardware, it’s going to be _slow_!!

On some systems (particularly PowerPC for some reason?), the graphics controller sits on the SoC’s external bus and can be addressed directly by an application. All that needs to happen is for the kernel to configure the process’s page table to point to the graphics controller’s memory range. It’s then up to the graphics controller to access data in it’s dedicated memory on behalf of the host CPU. Although this kind of set-up does allow the raster paint engine to get a pointer to graphics memory, all accesses go over this external bus - which is usually slow. On PC/x86 architecture, things get more even more complicated, the kernel has to fiddle with lots more hardware, cache controllers, PCI bus controllers, IOMMUs, etc. However, in all cases, if you’re lucky enough to get a pointer to graphics memory, all access must go over a slower external bus.

So now we know what’s going on, what conclusion can we draw? Well, reading & writing to external graphics memory is slow. If your on non-UMA, don’t have OpenGL or OpenVG available, but do want to use your blitter then you’d better make sure your mostly using QPainter::drawPixmap(). NOTE: Graphics view’s cache modes can help you out a lot there - see Andreas’ previous posts! ;-) Otherwise falling back to the raster engine is going to be slow. Fortunatly, this type of hardware is (finally) on it’s way out.

NOTE: I should also mention that there’s a similar issue with X11. There’s no API to get a pointer to an X pixmap and X11 does not provide enough API to implement the whole of QPainter. While the X11 paint engine does not inherit from the raster paint engine, it does make use of software fall-backs which involve copying the pixmap, executing the fall-back and then uploading the result. It’s for that reason that we’ve added the raster graphics system which uses system memory (via the MITSHM extension) in Qt 4.5. On desktop, this is a fairly temporary measure until our OpenGL 2.0 engine & graphics system is in a fit state to take over all of Qt’s rendering. No promises, but we hope that can happen for Qt 4.6. For X11 on low-end embedded devices (like the n810), MITSHM provides a pretty decent long term solution.

So, when we look to the future of Qt’s graphics architecture and the required paint engines, I think we’re well on the way to having all the bases covered:

Type UMA Non-UMA
None Raster Raster*
Blitter DirectFB DirectFB**
2D vector OpenVG*** OpenVG***
Fixed-3D OpenGL (ES) 1.x OpenGL (ES) 1.x
Programmable-3D OpenGL (ES) 2.x OpenGL (ES) 2.x****

* When using raster on NUMA, rendering is actually done in system memory first, then flushed to VRAM
** This is the one which is going to be slow when doing anything other than QPainter::drawPixmap()
*** It shouldn’t be a big surprise we’re researching an OpenVG paint engine!
**** Qt 4.5 contains a new paint engine for OpenGL ES 2.x which we’re now making work on desktop OpenGL 2.0

I just want to finish by asking you to take another look at the above table. Do you notice anything interesting? All of the graphics systems (apart from DirectFB) are cross platform which means, when we make something faster in one engine, all platforms will benefit.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.