Review Request 120025: Have KStandardAction::create(...) call KActionCollection::setDefaultShortcuts()

David Faure faure at kde.org
Mon Sep 1 07:55:17 UTC 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/120025/#review65624
-----------------------------------------------------------


You wrote: "I have not yet completely grasped the concept of the default shortcuts and why they are set only explicitely via KActionCollection::setDefaultShortcuts."

I think the concept is simple. QAction only knows "the current shortcuts, those that will trigger the action". Now imagine that the user configures the shortcut for the quit action (default Ctrl+Q) to use something else instead (Ctrl+E for exit, whatever). QAction will then only know about Ctrl+E, the actual active shortcut. But the shortcut configuration dialog needs to know that the default shortcut was Ctrl+Q, so that we can offer "revert to default", for instance (and to show that the shortcut was manually modified).
This information API is in KActionCollection because, well, there's no KAction anymore, and it stores the default shortcut into the QAction as a dynamic property.

Well, this means another solution could be to just set the dynamic property in KStandardAction, without going through KActionCollection via invokeMethod. That would probably more robust,
including the case of creating an action without a collection as parent, and then putting it into a collection later on.

Good thing I wrote the explanation, it made me realize that there is a better solution :-)

- David Faure


On Aug. 31, 2014, 4:40 p.m., Friedrich W. H. Kossebau wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/120025/
> -----------------------------------------------------------
> 
> (Updated Aug. 31, 2014, 4:40 p.m.)
> 
> 
> Review request for KDE Frameworks.
> 
> 
> Bugs: 338222
>     https://bugs.kde.org/show_bug.cgi?id=338222
> 
> 
> Repository: kconfigwidgets
> 
> 
> Description
> -------
> 
> As e.g. reported in https://bugs.kde.org/show_bug.cgi?id=338222 ("False positive critical warnings for KStandardActions") currently KXMLGUIFactoryPrivate::saveDefaultActionProperties complains about lots of actions that have been created properly via KStandardActions with a KActionCollection as parent. Just grep the log of your favourite XMLGUI-based KF5-ported program to see yourself.
> 
> I have not yet completely grasped the concept of the default shortcuts and why they are set only explicitely via KActionCollection::setDefaultShortcuts. But to me it makes some sense to have this automatically called for all standardactions which are created directly with a KActionCollection as parent.
> I decided not to change KActionCollection::addAction because I had even less idea what all might be affected by that.
> 
> So this is what this patch does:
> * add a call to KActionCollection::setDefaultShortcuts if there is a standard shortcut (via QMetaObject::invokeMethod, like done for KActionCollection::addAction)
> * also move code which only should be done in case of a created action into one, same branch
> 
> Needs https://git.reviewboard.kde.org/r/120024/ to make KActionCollection::setDefaultShortcuts() invokable.
> 
> 
> Diffs
> -----
> 
>   src/kstandardaction.cpp a18527b 
> 
> Diff: https://git.reviewboard.kde.org/r/120025/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Friedrich W. H. Kossebau
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20140901/97c4e9fe/attachment.html>


More information about the Kde-frameworks-devel mailing list