User:Chani/DevTips: Difference between revisions

From KDE TechBase
No edit summary
m (remove some irrelevent stuff and try to get more important stuff at the top)
 
Line 1: Line 1:
this is just a collection of various little tips that haven't been put into a proper tutorial or anything
this is just a collection of various little tips that haven't been put into a proper tutorial or anything
don’t sync the config; that’s plasma’s responsibility. you can, however, emit configNeedsSaving().


sizing: when you’re an applet doing your own stuff, you want to use functions with Content in them, so that you don’t have the borders added in. when you’re acting on another applet, you use the ones without, so that the border is taken into account. other than that, I’m really quite confused. I feel like we really shouldn’t need two functions for every type of sizing. but I don’t have time to investigate that right now.
sizing: when you’re an applet doing your own stuff, you want to use functions with Content in them, so that you don’t have the borders added in. when you’re acting on another applet, you use the ones without, so that the border is taken into account. other than that, I’m really quite confused. I feel like we really shouldn’t need two functions for every type of sizing. but I don’t have time to investigate that right now.
Line 14: Line 16:


however… layouts may not like not being in the constructor. can someone explain how these two bits of information fit together?
however… layouts may not like not being in the constructor. can someone explain how these two bits of information fit together?
don’t sync the config; that’s plasma’s responsibility. you can, however, emit configNeedsSaving().


there’s stuff to be done when accepting mouseclicks so that the event doesn’t get completely swallowed all the time - but I’ve forgotten the details and just can’t find the information any more.
there’s stuff to be done when accepting mouseclicks so that the event doesn’t get completely swallowed all the time - but I’ve forgotten the details and just can’t find the information any more.
setVisibility() does the same thing as show() and hide() - so don’t use both at once :P
if your function name starts with “got”, or you’re having trouble commenting the function in the header, chances are your design is suboptimal.

Latest revision as of 13:27, 1 February 2008

this is just a collection of various little tips that haven't been put into a proper tutorial or anything

don’t sync the config; that’s plasma’s responsibility. you can, however, emit configNeedsSaving().

sizing: when you’re an applet doing your own stuff, you want to use functions with Content in them, so that you don’t have the borders added in. when you’re acting on another applet, you use the ones without, so that the border is taken into account. other than that, I’m really quite confused. I feel like we really shouldn’t need two functions for every type of sizing. but I don’t have time to investigate that right now.

If you need to be notified when your plasmoid is resized, then implement constraintsUpdated() and check for a sizeconstraint. your new size is given by contentSize().

avoid reimplementing functions that return a size. only override contentSizeHint if you really need to (eg. controlling the aspect ratio).

if you know you’ll always need a certain amount of space, then setMinimumContentSize

when creating an applet, do as little as possible in the constructor. set a default size, and preferably no more. your ui creation, config reading, etc. should all go in init() instead. don’t read your size from the config, it’s done for you.

if your applet is useless without some configuration, then setNeedsConfiguring(true) - but judging by the documentation this could have some annoying side-effects. I should try it in twitter at some point and see what breaks.

however… layouts may not like not being in the constructor. can someone explain how these two bits of information fit together?

there’s stuff to be done when accepting mouseclicks so that the event doesn’t get completely swallowed all the time - but I’ve forgotten the details and just can’t find the information any more.