<br><br><div class="gmail_quote">On Sun, Jan 17, 2010 at 4:04 AM, Giulio Camuffo <span dir="ltr">&lt;<a href="mailto:giuliocamuffo@gmail.com">giuliocamuffo@gmail.com</a>&gt;</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>
&gt; On Sat, Jan 16, 2010 at 5:08 PM, Giulio Camuffo<br>
&lt;<a href="mailto:giuliocamuffo@gmail.com">giuliocamuffo@gmail.com</a>&gt;wrote:<br>
&gt; &gt; On Saturday 16 January 2010 05:36:41 Shantanu Tushar Jha wrote:<br>
&gt; &gt; &gt; Hello all,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     I wanted to make a simple PopupApplet which stays as an icon in the<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; panel and when clicked shows a popup allowing to enter username and<br>
&gt; &gt; &gt; password. The techbase extenders tutorial seems a bit overkill for this<br>
&gt; &gt; &gt; because it provides more functionality than what required in my case.<br>
&gt; &gt; &gt; So, looking at the PopupApplet API, I wrote the following code -<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; #include &quot;sifyclient.h&quot;<br>
&gt; &gt; &gt; K_EXPORT_PLASMA_APPLET(sifyclient, SifyClient)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; SifyClient::SifyClient(QObject *parent, const QVariantList &amp;args)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     : Plasma::PopupApplet(parent, args)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     topLevelWidget = new QGraphicsWidget;<br>
&gt; &gt; &gt;     usernameLabel = new Plasma::Label(topLevelWidget);<br>
&gt; &gt; &gt;     usernameEdit = new Plasma::LineEdit(topLevelWidget);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     usernameLabel-&gt;setText(&quot;Username&quot;);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     QGraphicsLinearLayout *usernameLayout = new<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; QGraphicsLinearLayout(Qt::Horizontal, topLevelWidget);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     dataTransferLayout-&gt;addItem(usernameLabel);<br>
&gt; &gt; &gt;     dataTransferLayout-&gt;addItem(usernameEdit);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     topLevelWidget-&gt;setLayout(dataTransferLayout);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; SifyClient::~SifyClient()<br>
&gt; &gt; &gt; {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     delete topLevelWidget;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; void SifyClient::init()<br>
&gt; &gt; &gt; {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     setPopupIcon(&quot;device-notifier&quot;);    //just for testing, will<br>
&gt; &gt; &gt;     replace<br>
&gt; &gt;<br>
&gt; &gt; by<br>
&gt; &gt;<br>
&gt; &gt; &gt; appropriate one later<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; QGraphicsWidget *SifyClient::graphicsWidget()<br>
&gt; &gt; &gt; {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     return topLevelWidget;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; #include &quot;sifyclient.moc&quot;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; From the API, I expected this to display &#39;device-notifier&#39; icon when<br>
&gt; &gt;<br>
&gt; &gt; placed<br>
&gt; &gt;<br>
&gt; &gt; &gt; in panel and show the username label and line edit when clicked.<br>
&gt; &gt; &gt; Instead<br>
&gt; &gt;<br>
&gt; &gt; it<br>
&gt; &gt;<br>
&gt; &gt; &gt; displays the label and line edit directly inside the panel. What am I<br>
&gt; &gt;<br>
&gt; &gt; doing<br>
&gt; &gt;<br>
&gt; &gt; &gt; wrong? How to get the effect I&#39;m trying to achieve?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks<br>
&gt; &gt;<br>
&gt; &gt; Try setting a a minimum size for the topLevelWidget. It should work that<br>
&gt; &gt; way.<br>
&gt;<br>
&gt; Thanks, that worked! I used &#39;topLevelWidget-&gt;setMinimumSize(250, 250);&#39; in<br>
&gt; the constructor and now it shows the icon in the panel.<br>
&gt; But now, If I click the icon, nothing pops up. Only If I move the applet<br>
&gt; from the panel to the desktop (when it shows the topLevelWidget with a<br>
&gt; label and lineEdit inside it) and then move it back into the panel, the<br>
&gt; popup shows on clicking the icon. Every time I do this, the following is<br>
&gt; output to the terminal -<br>
&gt;<br>
&gt; plasma-desktop(5365)/plasma ItemSpace::resizeItem: Resizing QRectF(787,637<br>
&gt; 32x32) to QRectF(787,637 278x278)<br>
&gt;<br>
&gt; Any idea what I&#39;m missing?<br>
&gt;<br>
&gt; Thanks<br>
&gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Plasma-devel mailing list<br>
&gt; &gt; <a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
&gt; &gt; <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 &quot;topLevelWidget =<br>
new QGraphicsWidget;&quot; with &quot;topLevelWidget = new QGraphicsWidget(this);&quot;. <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 &amp;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 &quot;Creating a Simple PopupApplet&quot; 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>