cat /dev/maxilys

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

2006-04-25

KDE: Resistance is futile!

It's been a while since my last post. Last week I was thinking about making an entry with the title "Nothing to say" ;-) ...but I didn't. I waited for some real news and here there are: Serenity has been updated (again).

The first thing I did was to change the separators in the popup menus. Somebody told me they looked too much like in Plastik. I couldn't stand this insult! ;-) While I was at it, I reduced a little the mouseover frame around the menu entries and I added round corners. I also changed the popup titles to an absolutely flat area. Good bye Plastik look! ;-)

The only problem is that the popup titles in K-Menu don't react as expected. That's really strange. These popup titles are QHeader's and I check if their parent looks like a popup. It works everywhere except with that stupid K-Menu which apparently isn't a popup! I'm gonna have to dig a little more into the sources.

Digging has become a kind of habit. That's amazing all you can find, especially all the possible twisted ways to misuse a widget!

For some times I was thinking about finding a solution to the sunken lines used instead of a regular KSeparator. I had a Kate session to open the QFrame sources along Serenity's ones. They were there but I didn't really look at them... until I decided to make an experiment. I intercepted all painting actions of a QFrame in Serenity's event filter and I draw a rectangle instead.

That was the most brilliant idea I've ever had. I discovered (visually) that these ugly HLine and VLine (the sunken separators) are indeed QFrame's but there was more. The groupboxes are also QFrame's. The sunken separator with a title is also a QFrame. And in fact, there was too many frames! All those frames that I patiently removed were back! Arrrghh! :-D It's was high time to look at the sources of QFrame!

Well, things turned out easier than I thought. All I had to do was to look at the frameshape() property to sort out the various frames. I took care of the HLine's and the VLine's first. That was easy since there's not much to draw. But that wasn't enough. The sunken separator with a title was still here. A quick look in the sources of the style configuration module and I got what I wanted to know: This ugly thing is indeed a groupbox with an isFlat() property. That was it. A little bit of fontMetrics() and I could redraw it the serene way: A line with a rounded frame in the middle to contain the title. Done.

That was almost too easy. Since I was dealing with the groupboxes, I totally changed the drawing of the regular ones. I once dreamt about putting a plain box behind the title but that wasn't possible because, when drawn in the regular way, the title erases its background. In the eventFilter(), I can do all that I want. The title is now in a plain box inside the frame of the groupbox and I also added a checkbox in the config dialog to deactivate all this and fall back to the regular drawing. Any way, I need this fall back since I can't handle checkable groupboxes (yet).

I now kinda think that nothing is impossible. I'm gonna "serenitify" the last widgets that resist me. "Resistance is futile" I said.

0 Comments:

Post a Comment

<< Home