proposed KAction/KActionCollection API changes
zander at kde.org
Tue Jan 2 22:24:01 GMT 2007
On Tuesday 02 January 2007 22:57, Richard Moore wrote:
> On 1/2/07, Simon Hausmann <hausmann at kde.org> wrote:
> > 2) Actions need to be explicitly added to the actioncollection. The name
> > used for extraction from the actioncollection (and with xmlgui) is
> > specified when adding the action to the collection, for symmetry. We
> > would like to use KActionCollection::addAction(const QString &name,
> > QAction *action) for that.
> I don't really like this, it seems to me the name should be property
> of the QAction object itself. This API introduces a number of
> potential ambiguities:
Having a name/value pair in the action collection makes a lot of sense to me.
I don't find it logical at all that I have to set a name on an object to be
able to insert it and retrieve it from some (semi)generic container under
Similar to having QHash::insert() get a name as well as the value.
> > [ 4) Get rid of the ugly setObjectName() hiding in KAction ]
> Don't really understand this either - is this just a name clash?
The QObject::setObjectName has basically been abused for the name of the
action while IMO (as I said above) its not the responsibility of the object
to remember which key is used for storage.
Stopping that practice makes it possible to reuse the name without risking
that users set a different object name without the actionCollection finding
out. (which was why it was private).
Now piece and unity has been restored.
> > Or alternatively:
> > KAction *a = actionCollection()->addAction("view_reload");
> > a->setShortcut(Qt::ControlModifier + Qt::Key_F5);
> > connect(a, SIGNAL(triggered()), this, SLOT(reload());
> How does this work for types derived from KAction?
You'd use the other (longer) version.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the kde-core-devel