10 rules for a plasma widgets developer

  1. Don’t call updateGeometry() during a size constraintsEvent and don’t call resize.
    If you want to keep the same aspect ratio you may be interested in Applet::setAspectRatioMode( ).
  2. If you want to write a new clock widget, you should inherit from libplasmaclock ClockApplet.
  3. Don’t do custom things: use default plasma methods and widgets when possible.
    Some useful methods are: Applet::setBusy( ) if your applet is busy, Applet::setConfigurationRequired( ) if user needs to configure the widget, etc…
    Some useful widgets are: Plasma::CheckBox, Plasma::ComboBox, Plasma::LineEdit, Plasma::PushButton, Plasma::RadioButton, etc…
  4. Don’t reimplement Applet::showConfigurationInterface, reimplement Applet::createConfigurationInterface instead.

    void MyApplet:createConfigurationInterface(KConfigDialog *parent)
    {
    QWidget *widget = new QWidget();
    ui.setupUi(widget); //ui is your configuration interface
    parent->addPage(widget, i18n("General"), icon());
    connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
    connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
    }
  5. Use Plasma::Animator and fast animations (not slower than 150 milliseconds).
  6. Use a standard background when possible.
  7. Avoid installing custom svg graphics when possible.
  8. Load graphics using Plasma::Svg.
  9. Don’t forget that the theme may change while your widget is running.
  10. paintInterface() might be called before init().

Tags: ,

4 Responses to “10 rules for a plasma widgets developer”

  1. randomguy3 says:

    Definitely a useful list – is it on Techbase? If not, can it be?

  2. Hans says:

    11. Don’t use that sliding widget crap as as seen in the weather forecast plasmoid. It fails badly in being usable.

  3. Uninstall says:

    > Definitely a useful list – is it on Techbase? If not, can it be?
    1) no, it isn’t on techbase.
    2) yes, sure :)

  4. alediaferia says:

    Great guide Davide, really useful!! ;)

Leave a Reply