On October 10, 2009 11:13:05 Yuen Hoe Lim wrote: > Thought I'd post a quick question here since I'm not making much > headway with pinning down exactly where I should be injecting code to > add a contextual menu item. I've been putting kDebug() statements into > places like contextMenuEvent() in Plasma::Containment and somehow it's > looking like the default Containment method implementations never get > called when I right click the desktop (the debug messages don't show > up - and they do when I right click the, for example, panel instead). > The desktop is just a containment, correct? So it looks to me like > whatever exact containment (subclass?) the desktop is using is > overriding the default containment context menu methods. > > Is this the case? If so, I can't seem to find what or where this > subclass is. If not, well, might someone know what I'm doing/figuring > wrong? :) >
it's a quirk of qgraphicsscene: mousepress and release events (for the clicked item and all its parent items!) get called before contextmenu event, and if one of them accepts the event, there is no contextmenuevent. my mouse plugin stuff handles rightclick in the mousereleaseevent function, so it's accepting the clicks. however, you don't want to be mucking with *event* functions, partially because of that plugin stuff. what you want to do is go look at Containment::contextualActions() ... oh, which doesn't actually exist because it's inherited from Applet... so go look at Applet's documentation of that function. then, there are two ways you could do this: 1) create QList<QAction*> Containment::contextualActions() and have it return wallpaper()->contextualActions() by default and edit every desktop-containment plasmoid (desktop and folderview at least) to add wallpaper()- >contextualActions() to its own contextualActions (assuming the function already exists there). 2) edit the contextmenu mouse plugin to add containment()->wallpaper()- >contextualActions() to its actions the same way it adds containment()- >contextualActions(). which way you choose depends on whether you think containment plasmoids should have control over whether the wallpaper's actions are included in the contextmenu. and of course, either way the contextualActions function has to be added to Wallpaper too... er, except it can't be virtual because that's BIC, damnit. so you'll have to find a more creative way of letting wallpaper plugins specify what their actions are. but hopefully in a way that gets hidden inside the Wallpaper class so that all the other classes have to do is call contextualActions() and get the list they need. -- This message brought to you by eevil bananas and the number 3. www.chani3.com
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel