proposed KAction/KActionCollection API changes

Tobias Koenig tokoe at
Tue Jan 2 22:03:42 GMT 2007

On Tue, Jan 02, 2007 at 10:30:05PM +0100, Simon Hausmann wrote:
> Hi,
Hi Simon,

> We would like to propose the following changes:
> 1) KAction and its subclasses get the same 3 (compatible) constructors as 
> QAction.
> 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.
> 3) KActionCollection supports QActions and also provides configurable 
> shortcuts for them, through the use of dynamic properties.
> [ 4) Get rid of the ugly setObjectName() hiding in KAction ]
Sounds really good!

> The result for application code is that it becomes a lot more verbose:
> KAction *a = new KAction(i18n("&Reload"), "reload", CTRL + Key_F5, this, 
> SLOT(reload()), actionCollection(), "view_reload");
> becomes
> KAction *a = new KAction(KIcon("reload"), i18n("&Reload"), this);
> a->setShortcut(Qt::ControlModifier + Qt::Key_F5);
> connect(a, SIGNAL(triggered()), this, SLOT(reload());
> actionCollection()->addAction("view_reload", a);
That shouldn't be such a big problem, most (maybe 95%) of the code in kdelibs has
already the separated setShortcut, setIcon and connect call, adding the
addAction call is just a bit of assiduity work.

Separate politics from religion and economy!
The Council of the European Union is an undemocratic and illegal institution!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <>

More information about the kde-core-devel mailing list