proposed KAction/KActionCollection API changes

Simon Hausmann hausmann at kde.org
Wed Jan 3 08:02:08 GMT 2007


On Tuesday 02 January 2007 23:36, Richard Moore wrote:
> On 1/2/07, Thomas Zander <zander at kde.org> wrote:
> > On Tuesday 02 January 2007 22:57, Richard Moore wrote:
> > 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 that name.
> > Similar to having QHash::insert() get a name as well as the value.
>
> I see where you're coming from, but this seems different to me. This
> name will also be used to identify the action in other contexts such
> as DBUS access to the actions, scripting actions and of course XMLGUI
> merging. Using it in all these different contexts makes it feel very
> different to me than a simple name/value lookup in the action
> collection.

Well, for scripting this makes even more sense to me. Here's an example:

mainWindow.actionCollection["fileNew"].triggered.connect( function() {
    ...
    handle it
    ...
} );

Or when creating a new Action wouldn't you rather write:

a = KAction()
a.text = "foobar"
a.icon = KIcon("blub")
a.triggered.connect( function() {
    ...
}
mainWindow.actionCollection["meh"] = a

So in both cases it appears to me that the name fits just right with to the 
actioncollection.

On the other hand the current API doesn't read that nice to me when creating 
it with

a = KAction(mainWindow.actionCollection, "myname")
a.text = ...
a.icon = ...

but then later access it through

mainWindow.actionCollection["myname"]

?



Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070103/9d9cd890/attachment.sig>


More information about the kde-core-devel mailing list