Monday, August 23, 2010

Oxygen rewrite and Dragging tabs around

This is a technical post, with a small video for entertainment.

Today, a major change to the oxygen code was committed to SVN, so that the style now derives from QCommonStyle as opposed to KStyle in the past. This is the first (and most difficult) step towards writing a fork of the oxygen widget style that would depend on Qt only, and not on KDE, so that one could, for instance, use oxygen natively on Windows (TM) for all Qt applications. Additionally, this change also results in better performances in painting widgets, and a more maintainable code.

This effectively constitutes a quasi-complete rewrite of the oxygen core code, as illustrated by the number of lines removed and added, from the svn commit log:
M +6227 -5224 oxygenstyle.cpp
M +886 -310 oxygenstyle.h
Hopefully no functionality have been lost and no regression introduced, although to be honest, further testing is needed, and more pairs of eyes than just mine (hence the commit).

While rewriting, some of the remaining oxygen visual bugs that I know of have been fixed, concerning notably how tabs are displayed when the active tab is being dragged around. (Tab widgets are by far the most difficult Qt widgets to render properly in the style). The result is illustrated in the following screencast.

  • the animation itself is provided by Qt, not by oxygen;
  • it was already supported in kde4.4 and kde4.5. Unfortunately it had some visual glitches that are now fixed;
  • the application used for the demonstration is oxygen-demo, from kde svn trunk (it has been modified since kde4.5 to handle movable tabs). It is available from the command line since KDE4.5.0, serves as a showcase on how widgets are rendered with oxygen (or any other style), and as a visual debugging tool for me;
  • the same feature is available in e.g. Dolphin, and kmail;
  • unfortunately (in my opinion), other applications such as konqueror and konsole, use their own private mechanism to drag tabs around. I wish they would rely on Qt only instead, for consistency across applications, and since it is a 'one line of code', literally, namely:
tabBar->setMovable( true );