[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: QActions in QML
From: Daker Fernandes Pinheiro <dakerfp () gmail ! com>
Date: 2012-10-29 12:26:59
Message-ID: CAHhpqga1itrATjQSCZC81XYN3_aC-=dBagntZgbw3O6_s93f6w () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
2012/10/28 Aleix Pol <aleixpol@kde.org>
> On Mon, Oct 29, 2012 at 1:33 AM, Daker Fernandes Pinheiro
> <dakerfp@gmail.com> wrote:
> > Sebas,
> >
> > This just worked:
> > http://paste.kde.org/584660/
> > Where QAction is
> > http://paste.kde.org/584672/
> >
> > Cheers,
> >
> > Daker Fernandes Pinheiro
> > http://codecereal.blogspot.com
> >
> >
> > 2012/10/28 Sebastian K=C3=BCgler <sebas@kde.org>
> >>
> >> On Thursday, October 25, 2012 20:00:25 Aaron J. Seigo wrote:
> >> > not automatically, no. but QActions are QObjects, so you can attach =
to
> >> > their
> >> > signals in the QML.
> >>
> >> And it's quite wonky, for example offering a list of QActions
> >> (QDeclarativeListProperty or QList, even with the payload casted to
> >> QObjects)
> >> does not seem to work. There's one, corrupt and therefore unusable ent=
ry
> >> in
> >> the returned data in the best case, no data at all in the worst.
> >>
> >> A workaround I've found is to send a list of QActions (.name()) in a
> >> QStringList to the runtime, and offer a Q_INVOKABLE QAction*
> >> action(QString);
> >> accessor which returns a QAction* to the runtime.
> >>
> >> Your button has the following:
> >>
> >> property QtObject action
> >>
> >> onClicked: action.trigger()
> >>
> >> Then, in your delegate, you retrieve the action via the key you get in
> >> your
> >> "listmodel":
> >>
> >> delegate: ActionButton {
> >> action: cpppluginthing.action(modelData)
> >> }
> >>
> >> Not the most beautiful thing in the world, but it seems to work at
> least.
> >> I'm
> >> of course open to better solutions.
> >> --
> >> sebas
> >>
> >> http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9
> >> _______________________________________________
> >> Plasma-devel mailing list
> >> Plasma-devel@kde.org
> >> https://mail.kde.org/mailman/listinfo/plasma-devel
> >
> >
> >
> > _______________________________________________
> > Plasma-devel mailing list
> > Plasma-devel@kde.org
> > https://mail.kde.org/mailman/listinfo/plasma-devel
> >
>
> Wouldn't it be better to qmlRegisterType<QAction> directly?
>
That's definetely true.
I got this snippet from another project and it re-implemented trigger.
But that's not the case.
>
> Aleix
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
Br,
Daker Fernandes Pinheiro
http://codecereal.blogspot.com
[Attachment #5 (text/html)]
2012/10/28 Aleix Pol <span dir="ltr"><<a href="mailto:aleixpol@kde.org" \
target="_blank">aleixpol@kde.org</a>></span><br><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Mon, Oct 29, 2012 at 1:33 AM, Daker Fernandes \
Pinheiro<br> <<a href="mailto:dakerfp@gmail.com">dakerfp@gmail.com</a>> \
wrote:<br> > Sebas,<br>
><br>
> This just worked:<br>
> <a href="http://paste.kde.org/584660/" \
target="_blank">http://paste.kde.org/584660/</a><br> > Where QAction is<br>
> <a href="http://paste.kde.org/584672/" \
target="_blank">http://paste.kde.org/584672/</a><br> ><br>
> Cheers,<br>
><br>
> Daker Fernandes Pinheiro<br>
> <a href="http://codecereal.blogspot.com" \
target="_blank">http://codecereal.blogspot.com</a><br> ><br>
><br>
> 2012/10/28 Sebastian Kügler <<a \
href="mailto:sebas@kde.org">sebas@kde.org</a>><br> >><br>
>> On Thursday, October 25, 2012 20:00:25 Aaron J. Seigo wrote:<br>
>> > not automatically, no. but QActions are QObjects, so you can attach \
to<br> >> > their<br>
>> > signals in the QML.<br>
>><br>
>> And it's quite wonky, for example offering a list of QActions<br>
>> (QDeclarativeListProperty or QList, even with the payload casted to<br>
>> QObjects)<br>
>> does not seem to work. There's one, corrupt and therefore unusable \
entry<br> >> in<br>
>> the returned data in the best case, no data at all in the worst.<br>
>><br>
>> A workaround I've found is to send a list of QActions (.name()) in a<br>
>> QStringList to the runtime, and offer a Q_INVOKABLE QAction*<br>
>> action(QString);<br>
>> accessor which returns a QAction* to the runtime.<br>
>><br>
>> Your button has the following:<br>
>><br>
>> property QtObject action<br>
>><br>
>> onClicked: action.trigger()<br>
>><br>
>> Then, in your delegate, you retrieve the action via the key you get in<br>
>> your<br>
>> "listmodel":<br>
>><br>
>> delegate: ActionButton {<br>
>> action: cpppluginthing.action(modelData)<br>
>> }<br>
>><br>
>> Not the most beautiful thing in the world, but it seems to work at \
least.<br> >> I'm<br>
>> of course open to better solutions.<br>
>> --<br>
>> sebas<br>
>><br>
>> <a href="http://www.kde.org" target="_blank">http://www.kde.org</a> | <a \
href="http://vizZzion.org" target="_blank">http://vizZzion.org</a> | GPG Key ID: 9119 \
0EF9<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>
><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>
<br>
</div></div>Wouldn't it be better to qmlRegisterType<QAction> \
directly?<br></blockquote><div><br>That's definetely true.<br>I got this snippet \
from another project and it re-implemented trigger.<br>But that's not the \
case.<br>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"> <span class="HOEnZb"><font color="#888888"><br>
Aleix<br>
</font></span><div class="HOEnZb"><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>Br,<br><br>Daker Fernandes Pinheiro<br><a \
href="http://codecereal.blogspot.com" \
target="_blank">http://codecereal.blogspot.com</a><br><br>
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic