Hi,
I like the idea of having a KDE L&F, although the GTK L&F combined with oxygen-gtk
almost do the job.
The screenshots look very promising.
I think the best way of doing this is letting KDE do all the drawing. This would mean the
program would still look native even if someone is not running the Oxygen style.
However this means that almost everything would have to be done in C++.
Since you say you are not skilled in C++ yet, that means it would probably take longer
to implement.
I had a quick look at your native code and found a few issues:
You instantiate a new QApplication everytime the method is called, you should only be doing this once.
I.e. add a new native method that you call from the static class initializer.
This method could also look up all the field/method IDs so you have them cached.
There are two memory leaks:
QImage* qimage = new QImage(width, 30, QImage::Format_ARGB32);
QPainter* painter = new QPainter(qimage)
You don't delete these, so they leak (C++ has no GC)
Better way of doing it is allocating them on the stack:
QImage qimage(width, 30, QImage::Format_ARGB32);
QPainter painter(&qimage);
You set the BufferedImage pixel by pixel. Calls from C++ to Java/Java to C++ are a lot more expensive
than C++ to C++/Java to Java since they cannot be inlined and hava some additional overhead
compared to and ordinary function call (registers get saved, etc). It would be better to use the
setRGB method that takes an int[].
Printing strings may not work if they contain non-latin1 characters
when you call painter->drawText() the const char* is implicitly converted to
a QString, which doesn't always assume UTF8 as encoding for const char*
QString::fromUtf8() would do the job.
However this is inefficent because QString and java.lang.String both
use UTF16 characters, so it would be better to use env->GetStringChars(),
then QString::fromRawData to get a QString, and once it has been drawn
env->ReleaseStringChars().
Alex
I agree that using the gtk binding to java swing + oxygen-gtk is far
from perfect (many widgets are not themed; many oxygen-gtk features have
to be turned off, etc.) and that your screenshots look more promising.
Good luck !
Hugo
> Alex: huge thanks for looking at our code! As I mentioned above, we
> are definitely aware of the GTK L&F. I completely agree with you about
> letting KDE render everything. The only real reason we are not doing
> that right now is that we simply didn't/don't know how to get that to
> work. And even if one gets it to work, it should be fast, since you
> don't want a L&F to make a GUI slow (well, not slower than an average
> Java GUI is at least), which is hard for infant C++ programmers I
> suppose. We will certainly have a look at it though, certainly now we
> have this small piece of code working for the text rendering. Then
> again, thanks a lot for your feedback on our tiny piece of code, that
> contains so many bugs apparently :) We have fixed most things you
> mentioned (I believe Willem did yesterday, but I think he didn't
> commit the changes yet), although I'm not sure if Willem already
> managed to make the 'image copying process' faster already and if he
> worked on the strings. He did say not creating a new QApplication on
> every call made the drawing lots and lots faster already, so that's
> good. In any case, the changes will be on Git soon and I think we are
> going to let more components be drawn by KDE soon as well.
>
> Thom
What about open/save dialogs?
Notifications?
SWT?
:33 Thanks and great job !
> Notifications?
By notifications, you mean the 'global' notification system? We didn't
really think about implementing that yet.. I'll talk about it with
Willem. Good suggestion!
> SWT?
That's a tricky one. SWT uses, AFAIK, Gnome widgets. At least it is
not trivial to apply a custom styling. Joxy is, at the moment, a L&F,
which means only Java Swing applications are targeted. If there is a
way to style SWT we would like to here about it. Maybe an idea for
some sort of side-project... Joxy-SWT :) Oh wait, Joxy is a
side-project of my study already :)