Plasmoid plugin signal handling

Sebastian Kügler sebas at kde.org
Wed Jun 14 11:30:14 UTC 2017


On Wed, 14 Jun 2017 10:39:04 +0200
Rastislav Marko <cdfghglz at gmail.com> wrote:

> Thank you for the hints, I made the semantics more meaningful (in
> fact I have another class named ActiivtyJumper).
> 
> On utorok, 13. júna 2017 16:49:26 CEST Sebastian Kügler wrote:
> > 
> > The signal isn't defined in "Item", you need to create a DBusObject
> > object in your QML code, then you can add a signal handler.  
> 
> I can not really find a reference to DBusObject, what should it
> represent?

Sorry, I meant "DBusInterface", that's the class name your C++ code,
which you rename to ActivityJumper in the qmlRegisterType statement.
(Might I suggest a less general, more meaningful name for
DBusInterface?)

> > > ---------- main.qml
> > > 
> > > Item {
> > > 
> > >     id: main
> > >     
> > >     ActivityJumper {
> > >     
> > >         id: activityJumper  
> > 
> > Here, it'll be found:
> > 
> > 	 		onSignalDesktopChanged: print("desktop   
> changed!")
> >   
> 
> I tried this before, but I was appearently missing a proper import
> (import org.kde.private.activityjumper 1.0) in the main.qml. Then I
> tried to use the Connections as a workaround. With the import the
> handler works from the object instance in main.qml like charm.

Yes, you need to use that import whenever you use your objects /
classes defined within the scope of that import.

Connection works as well, but it's way clearer to put the signal
handler within the object that defines it, keeps code nicely grouped
and reduces the creation of an unnecessary Connection object.

> Thanks!

Cheers,
-- 
sebas

    http://vizZzion.org   ⦿    http://www.kde.org


More information about the Plasma-devel mailing list