How to make a simple PopupApplet

Shantanu Tushar Jha jhahoneyk at gmail.com
Sat Jan 16 06:36:41 CET 2010


Hello all,
    I wanted to make a simple PopupApplet which stays as an icon in the
panel and when clicked shows a popup allowing to enter username and
password. The techbase extenders tutorial seems a bit overkill for this
because it provides more functionality than what required in my case. So,
looking at the PopupApplet API, I wrote the following code -

#include "sifyclient.h"
K_EXPORT_PLASMA_APPLET(sifyclient, SifyClient)

SifyClient::SifyClient(QObject *parent, const QVariantList &args)
    : Plasma::PopupApplet(parent, args)
{
    topLevelWidget = new QGraphicsWidget;
    usernameLabel = new Plasma::Label(topLevelWidget);
    usernameEdit = new Plasma::LineEdit(topLevelWidget);

    usernameLabel->setText("Username");

    QGraphicsLinearLayout *usernameLayout = new
QGraphicsLinearLayout(Qt::Horizontal, topLevelWidget);
    dataTransferLayout->addItem(usernameLabel);
    dataTransferLayout->addItem(usernameEdit);

    topLevelWidget->setLayout(dataTransferLayout);
}

SifyClient::~SifyClient()
{
    delete topLevelWidget;
}

void SifyClient::init()
{
    setPopupIcon("device-notifier");    //just for testing, will replace by
appropriate one later
}

QGraphicsWidget *SifyClient::graphicsWidget()
{
    return topLevelWidget;
}

#include "sifyclient.moc"




More information about the Plasma-devel mailing list