How to make a simple PopupApplet

Giulio Camuffo giuliocamuffo at gmail.com
Sat Jan 16 12:38:42 CET 2010


On Saturday 16 January 2010 05:36:41 Shantanu Tushar Jha wrote:
> 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"
> 
> 
> From the API, I expected this to display 'device-notifier' icon when placed
> in panel and show the username label and line edit when clicked. Instead it
> displays the label and line edit directly inside the panel. What am I doing
> wrong? How to get the effect I'm trying to achieve?
> 
> Thanks

Try setting a a minimum size for the topLevelWidget. It should work that way.


More information about the Plasma-devel mailing list