How to make a simple PopupApplet
Shantanu Tushar Jha
jhahoneyk at gmail.com
Sat Jan 16 22:12:41 CET 2010
On Sat, Jan 16, 2010 at 5:08 PM, Giulio Camuffo <giuliocamuffo at gmail.com>wrote:
> 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.
>
Thanks, that worked! I used 'topLevelWidget->setMinimumSize(250, 250);' in
the constructor and now it shows the icon in the panel.
But now, If I click the icon, nothing pops up. Only If I move the applet
from the panel to the desktop (when it shows the topLevelWidget with a label
and lineEdit inside it) and then move it back into the panel, the popup
shows on clicking the icon. Every time I do this, the following is output to
the terminal -
plasma-desktop(5365)/plasma ItemSpace::resizeItem: Resizing QRectF(787,637
32x32) to QRectF(787,637 278x278)
Any idea what I'm missing?
Thanks
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
--
Shantanu Tushar (UTC +0530)
http://www.shantanutushar.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/plasma-devel/attachments/20100117/f1795106/attachment.htm
More information about the Plasma-devel
mailing list