cat /dev/maxilys

A glance in the mind of a KDE/Linux developer to see how ideas turn into code.

2006-03-28

KDE: Breaking the limits

OK, don't listen to me when I say I can't do something, I can always do more. ;-)

Yesterday, I was looking for a way to improve the titlebar of the floating toolboxes. I found something. I improved the icons of the titlebar buttons but I stumbled on another problem. These icons are XPM images and handled as such by the underlying engine --i.e. as an array of strings. XPM also means that the colors are fixed and they are actually fixed to black in KDE. That's a big problem if I want them to have the color of the button labels --whatever it is. I could have change these XPM into private bitmaps but there would still be one icon --on which I have no control-- with the wrong color. I had to find something.

The first solution that came to my mind was to rebuild the XPM on demand. Well, do you know an easy way to turn a QColor into an hexadecimal string? For a moment, I thought about writing a tiny subroutine for this task. For exactly 0.6 second. ;-) I remembered that this very thing already exists somewhere in Qt which stores the QColor's as hexa strings in its config files. A few more seconds to remember where I already used this stuff...

That was in Senerity window decoration. I once wondered why storing a QColor was so complicate for a windec and I tried to use the same method than for a style. But it didn't work. Nevermind. All that matters is that I retrieved what I wanted: QColor::name().

With this I became able to rebuild the XPM string that contains the color... and the miracle happened! When KDE or my style request one of the XPM, its color get automagically changed on the fly. And that means a lot! It works with all colorschemes including the dark ones which aren't condemned to unusable buttons any more. (These images are minimized floating toolboxes in KDevelop Designer.) As you can see, the mini-titlebars reproduce the behavior of the regular ones: Toggle buttons like the minimizer act like checkboxes, they stay pressed when activated. When I first saw this, my reaction was "Amaaaazing!" :-D I couldn't resist to the urge to brag about it.

Something else: The mouseover effect over the checkbox and radiobutton labels. This story turned into a nightmare. I managed to do a few things but I'm still gonna have to give a deep thought to it. QtCurve engine isn't that similar to Serenity's one. I was able to cut and paste but the result was too weird to be left within Serenity. The mouseover effect worked perfectly on the labels but the buttons of the checkboxes or radiobuttons didn't react as expected. They stayed hovered while the mouse was over the widget and not only the actual area to activate them. I'll re-try to work on this later. There are still plenty of version numbers beyond 0.4. ;-) I should already be satisfied I let the mouseover effect acknowledge multi-line labels and pixmaps as labels. Not all styles can do this.

Any way, Serenity 0.4 is released. There's already been around 20 downloads. I can sit and wait for the bug reports...

0 Comments:

Post a Comment

<< Home