Middle Clicking on BookmarkBar and BookmarkMenu entries
David Faure
faure at kde.org
Mon Dec 13 19:37:34 GMT 2004
On Monday 13 December 2004 20:28, Daniel Teske wrote:
>
> >I added a KAction::activationReason() recently, which returns a value out of the enum:
> > enum ActivationReason { UnknownActivation, EmulatedActivation, AccelActivation, PopupMenuActivation, ToolBarActivation };
> >Feel free to replace ToolbarActivation with ToolbarLMBActivation, and add a ToolbarMMBActivation.
> >(This enum will be new in 3.4, it's still OK to change it).
> >Maybe we need PopupMenuLMBActivation and PopupMenuRMBActivation too?
>
>
> I'm not sure, what would be usefull to other applications.
I was thinking about KOffice, but I just remembered that some developers requested
double-click support (on toolbar buttons), not really MMB.
It would just seem consistent to have all methods (LMB/RMB/MMB/dbl-click) in KAction::activationReason().
> I think there needs to be a keyboard equivalent to middle clicking. Ctrl+Enter?
Well you can't give focus to a toolbar button... OK maybe for a popupmenu item
that might be useful.
> Well, I looked into it, and I intended to store it inside
> KToolbarButtonPrivate, and KAction asking KToolbarButton which button
> was presed.
> Basically inside KAction::slotActivated(), roughly:
>
> if(::qt_cast<KToolBarButton *>( senderObj ))
> d->state = senderObj->state();
Yes. I was just wondering if we could connect to another signal from KToolbarButton
instead (like in Stefan's patch).
> I was pretty sure that there was a way to add it for KPopupMenu, but
> looking at it again, I don't remember how.
Maybe the same there - adding a signal?
> >+ const QString & url = sender()->property("url").toString();
> >Looks dangerous to me - the ref could easily become dangling.
> >Better use "[const] QString url = ..." without the ref, we have implicit sharing anyway.
> >
> >
> I don't understand what you mean by dangling. That const reference is
> perfectly safe, it avoids the cost of one copy constructor.
Well if the compiler decides that the QString returned by toString() isn't useful
anymore, it might get rid of it - there is no other var holding the string anymore.
We've had crashes in KonqRun when keeping a reference to a QString, and the
object holding the QString got deleted - and the reference was dangling (i.e. pointing
to a deleted object).
> (Which for implicit shared is smaller than I thought.)
Yes, it's not worth it.
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kfm-devel
mailing list