Hi Gabriel, Thanks for the idea, that is indeed much more general than what I proposed. I'll give it a try and submit a patch if everything goes well.
Daiwei On Fri, Sep 13, 2013 at 2:38 AM, deDietrich Gabriel < gabriel.dedietr...@digia.com> wrote: > Hi Daiwei, > > On Sep 11, 2013, at 1:45 AM, Daiwei Li <daiwe...@gmail.com> wrote: > > > I'm investigating adding analytics to my QML application and would like > to differentiate between reasons why an action is triggered, e.g. from a > MenuItem vs keyboard shortcut vs Button press. Looking at qquickaction.cpp, > this information does not seem to be made available. > > > > What would be the best bet for getting access to this info? I'm thinking > of adding an eventSource parameter to the triggered signal that would > contain the objectName of the object or "shortcut+" + shortcut if it was > triggered by a shortcut, but would be happy to hear other suggestions. > > You could have QQuickAction::trigger() and QQuickAction::triggered() pass > the (QObject) sender as an optional parameter. Then, make sure that > QQuickMenuItem, BasicButton, etc. use this. (Remember that you should not > emit triggered() yourself, but call trigger() instead).This is a very > common pattern in other frameworks (Cocoa comes to mind), and could make > sense as an API for QQuickAction. Passing some string only solves your > particular problem, so that would not be acceptable as a general purpose > API. > > Best regards, > > Dr. Gabriel de Dietrich > Senior Software Developer > qt.digia.com > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest