From kde-core-devel Fri Sep 28 17:20:07 2001 From: Bernd Gehrmann Date: Fri, 28 Sep 2001 17:20:07 +0000 To: kde-core-devel Subject: Re: Questions about KDCOPActionProxy... X-MARC-Message: https://marc.info/?l=kde-core-devel&m=100169763320139 On Fri, 28 Sep 2001, David Faure wrote: > > With Qt3, you can actually extend the DCOP-QObject bridge such that > > you can call any slot in any QObject via DCOP, without the programmer > > having to add anything. > > Hrm, this is already the case, with the current DCOP-Qt bridge ! Hmm, which 'current' do you mean? The version in HEAD only supports parameter-less slots AFAICS. qt_invoke can do much more. > > The remaining problem then is only to give objects meaningful names. > > Yes, this is always the one thing the programmer has to think about. > Not a problem with actions though. What I meant is that you can easily extend DCOPClient such that you can make any QObject DCOP-accessible with a meaningful name _without_ having to write dcopidl interfaces, add DCOPObjects or other heavy stuff. Basically, one could add a QMap qobjecMap variable to DCOPClient and a method: DCOPClient::publish(QCString name, QObject *obj) { qobjectMap[name] = obj; connect(obj, SIGNAL(destroyed()), this, SLOT(qobjectDestroyed())); // for removing objects from the map when they are destroyed } Now add some code to the (objId="DCOPClient", fun="objects()") section in DCOPClient::receive() to add the qobjectMap keys to the list of objects. Furthermore, add some code which checks whether objId is in qobjectMap and run DCOPClient::receiveQtObject() for it then. Now, when that is done, you can simply make a button in a dialog accesible by writing QPushButton *okbutton = new QPushButton("OK", this); DCOPClient::publish("FooDialog/AcceptButton", okbutton); I think this would lower the barrier to adding such things a lot :-) Alternatively, one could get even rid of the overhead of DCOPClient::publish() and instead modify the QObject bridge such that it detects certain QObjects::name() prefixes as a marker for DCOP object names. Then the above example would read QPushButton *okbutton = new QPushButton("OK", this, "DCOP:FooDialog/AcceptButton"); Now, when a DCOP call for the DCOP object "FooDialog/AcceptButton" comes in, it would automatically be dispatched to the okbutton object. Advantage: no overhead, and user interface elements can be made DCOP accesible by simply marking them appropriately in the name column in Qt designer. Bernd.