This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[Solved] Sizing problems in Plasma on KDE 4.3

Tags: None
(comma "," separated)
chrizz
Registered Member
Posts
4
Karma
0
OS
Hi All,
maybe someone of you can help me.
Since the good old KNewsTicker died, i took some time and reanimated it and rewrote parts of it to work on KDE 4.2+.
You can find it [url="http://kde-apps.org/content/show.php/NetNewsTicker?content=101699"]here.[/url]
But on KDE 4.3 RC2 i ran into sizing problems if the applet is put onto a panel.
If i put the applet on a panel, the applet takes up the whole panel, this is correct.
But sometimes the plasma-desktop crashes and when it comes back, the applet only takes up ~10% of the panel.
In my source code i use the call
Code: Select all
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

in my paintInterface(...) method. This call causes that my applet eats up all available space on the panel (at least i think it does).
But it won't work after plasma is restarted. The workaround is to remove the applet, restart plasma-desktop and then readd the applet again.
I guess this is not a problem of kde 4.3 itself, but a problem of my code. Since i never really found out on how to handle the resizing of applets the way it should be.

Can anyone please advise me a good tutorial on using the correct sizing technique?
Or someone can tell me where i'm wrong?

Many thanks in advance
Greetings, -chris-

Last edited by chrizz on Mon Jul 27, 2009 7:23 am, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Size policy does not need to be set each time, it should be done in the constructor, or when you perform initial setup of the plasmoid.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
chrizz
Registered Member
Posts
4
Karma
0
OS
Thanks for your comment. But your suggested way does not work for me. If i set the policy in the constructor or in the initialization, nothing will happen and the applet stays very small.
I tried this before since i thought, setting the policy on every paint is very redundant.

Greetings, -chris-
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Just checked your code...
it appears you are not calling resize() anywhere.... or setAspectRatioMode(). you may wish to try adding them to your constructor.

Try moving setSizePolicy() into the init() function also.

You should be able to change the following line:
Code: Select all
#include "../build/netnewsticker.moc"

to the following also:
Code: Select all
#include "netnewsticker.moc"


There seem to be a few headers included that aren't actually needed also.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
chrizz
Registered Member
Posts
4
Karma
0
OS
Thanks again, but it won't work.
Even if i do
Code: Select all
resize(70, 1280);                                                           
setAspectRatioMode(Plasma::IgnoreAspectRatio);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 

in the initialization, the applet always shows up only on ~10% of the space in the panel. There are no additional applets in the panel.
If i add a "variable spacer" to the panel, all works nearly the way it's expected. But i guess it should work also without any other applet.

Maybe i should look in the source code for the "variable spacer" and check what 'magic' they do to get the correct behaviour. Do you know where i find this code. I looked through the websvn.kde.org but didn't find this piece of code.

Greetings, -chris-
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
It will be located in /trunk/KDE/kdebase/workspace/plasma/applets.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
chrizz
Registered Member
Posts
4
Karma
0
OS
I think i found the sufficient solution.
I put
Code: Select all
setAspectRatioMode(Plasma::IgnoreAspectRatio);

in the ctor and now the sizing problems are gone.
Maybe the default aspect ratio of an applet is to keep the ratio. But i really don't know why my applet now works. Sadly i did not find any good documentation how the sizing of an applet is handled by plasma.

Many thanks for your help!!

Greetings, -chris-


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]