<br><br><div class="gmail_quote">On Sun, Jan 17, 2010 at 4:04 AM, Giulio Camuffo <span dir="ltr"><<a href="mailto:giuliocamuffo@gmail.com">giuliocamuffo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Saturday 16 January 2010 21:12:41 Shantanu Tushar Jha wrote:<br>
> On Sat, Jan 16, 2010 at 5:08 PM, Giulio Camuffo<br>
<<a href="mailto:giuliocamuffo@gmail.com">giuliocamuffo@gmail.com</a>>wrote:<br>
> > On Saturday 16 January 2010 05:36:41 Shantanu Tushar Jha wrote:<br>
> > > Hello all,<br>
> > ><br>
> > > I wanted to make a simple PopupApplet which stays as an icon in the<br>
> > ><br>
> > > panel and when clicked shows a popup allowing to enter username and<br>
> > > password. The techbase extenders tutorial seems a bit overkill for this<br>
> > > because it provides more functionality than what required in my case.<br>
> > > So, looking at the PopupApplet API, I wrote the following code -<br>
> > ><br>
> > > #include "sifyclient.h"<br>
> > > K_EXPORT_PLASMA_APPLET(sifyclient, SifyClient)<br>
> > ><br>
> > > SifyClient::SifyClient(QObject *parent, const QVariantList &args)<br>
> > ><br>
> > > : Plasma::PopupApplet(parent, args)<br>
> > ><br>
> > > {<br>
> > ><br>
> > > topLevelWidget = new QGraphicsWidget;<br>
> > > usernameLabel = new Plasma::Label(topLevelWidget);<br>
> > > usernameEdit = new Plasma::LineEdit(topLevelWidget);<br>
> > ><br>
> > > usernameLabel->setText("Username");<br>
> > ><br>
> > > QGraphicsLinearLayout *usernameLayout = new<br>
> > ><br>
> > > QGraphicsLinearLayout(Qt::Horizontal, topLevelWidget);<br>
> > ><br>
> > > dataTransferLayout->addItem(usernameLabel);<br>
> > > dataTransferLayout->addItem(usernameEdit);<br>
> > ><br>
> > > topLevelWidget->setLayout(dataTransferLayout);<br>
> > ><br>
> > > }<br>
> > ><br>
> > > SifyClient::~SifyClient()<br>
> > > {<br>
> > ><br>
> > > delete topLevelWidget;<br>
> > ><br>
> > > }<br>
> > ><br>
> > > void SifyClient::init()<br>
> > > {<br>
> > ><br>
> > > setPopupIcon("device-notifier"); //just for testing, will<br>
> > > replace<br>
> ><br>
> > by<br>
> ><br>
> > > appropriate one later<br>
> > > }<br>
> > ><br>
> > > QGraphicsWidget *SifyClient::graphicsWidget()<br>
> > > {<br>
> > ><br>
> > > return topLevelWidget;<br>
> > ><br>
> > > }<br>
> > ><br>
> > > #include "sifyclient.moc"<br>
> > ><br>
> > ><br>
> > > From the API, I expected this to display 'device-notifier' icon when<br>
> ><br>
> > placed<br>
> ><br>
> > > in panel and show the username label and line edit when clicked.<br>
> > > Instead<br>
> ><br>
> > it<br>
> ><br>
> > > displays the label and line edit directly inside the panel. What am I<br>
> ><br>
> > doing<br>
> ><br>
> > > wrong? How to get the effect I'm trying to achieve?<br>
> > ><br>
> > > Thanks<br>
> ><br>
> > Try setting a a minimum size for the topLevelWidget. It should work that<br>
> > way.<br>
><br>
> Thanks, that worked! I used 'topLevelWidget->setMinimumSize(250, 250);' in<br>
> the constructor and now it shows the icon in the panel.<br>
> But now, If I click the icon, nothing pops up. Only If I move the applet<br>
> from the panel to the desktop (when it shows the topLevelWidget with a<br>
> label and lineEdit inside it) and then move it back into the panel, the<br>
> popup shows on clicking the icon. Every time I do this, the following is<br>
> output to the terminal -<br>
><br>
> plasma-desktop(5365)/plasma ItemSpace::resizeItem: Resizing QRectF(787,637<br>
> 32x32) to QRectF(787,637 278x278)<br>
><br>
> Any idea what I'm missing?<br>
><br>
> Thanks<br>
><br>
> > _______________________________________________<br>
> > Plasma-devel mailing list<br>
> > <a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
> > <a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
<br>
</div></div>I had a similar problem, some time ago, and if I remeber correctly the problem<br>
was that the parent of graphicWidget() was 0. Try to change "topLevelWidget =<br>
new QGraphicsWidget;" with "topLevelWidget = new QGraphicsWidget(this);". <br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
On a side note it is better to instantiate those pointers in this way:<br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
SifyClient::SifyClient(QObject *parent, const QVariantList &args)<br>
: Plasma::PopupApplet(parent, args),<br>
</div> topLevelWidget(new QGraphicsWidget(this)),<br>
...<br>
{<br></blockquote><div><br>Yay! That worked :) Thanks a lot. I wonder If these things should be added to the API reference or techbase somewhere. Should we add a "Creating a Simple PopupApplet" tutorial to the techbase?<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">_______________________________________________<br>
Plasma-devel mailing list<br>
<a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Shantanu Tushar (UTC +0530)<br><a href="http://www.shantanutushar.com">http://www.shantanutushar.com</a><br>