Difference between revisions of "User:Chani/DevTips"

Jump to: navigation, search
(dump of data from blog)
 
m (remove some irrelevent stuff and try to get more important stuff at the top)
 
(One intermediate revision by the same user not shown)
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 11: Line 13:
 
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.
 
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 there’s a special thing you should set, but I forget what it is; I should do this for twitter at some point.
+
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?
 
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.


This page was last edited on 1 February 2008, at 13:27. Content is available under Creative Commons License SA 4.0 unless otherwise noted.