Strange ampersand in Plasma tooltips
Thomas Lübking
thomas.luebking at web.de
Tue Mar 2 16:16:34 CET 2010
Am Tuesday 02 March 2010 schrieb Mark Kretschmann:
> On Mon, Mar 1, 2010 at 4:02 PM, Thomas Lübking <thomas.luebking at web.de>
wrote:
> > First off, it's not in yesterdays build with 4.4.0
> >
> > Then:
> > the plasma::iconwidget in applet and and amarok::iconbutton are different
> > implementations and not based on each other, so it's unlikely in them.
> >
> > ==> The reason would be that the corrensponding QAction::text()'s contain
> > them, what's wrong.
> >
> > long story short: don't ever QAction::setText(&Mnemonic) but
> > QAction::setText(Mnemonic) QAction::setShortcut(Qt::Ctrl+Qt::Key_M)
> >
> > FYI, about mnemonics - "little nasty things with a little nasty name" ;-)
> > ------
> > the flags of QPainter::drawText() take (among others)
> > - Qt::TextShowMnemonic
> > - Qt::TextHideMnemonic
> >
> > where the first will print "&Last.fm: Love" as "_L_ast.fm: Love" and the
> > second as "Last.fm: Love"
> > If you omit them both, you'll just get the text as it is.
> >
> > If you want to support mnemonics AND ampersands, you'll have to pass
> > latter as "&&"
> >
> > Neither QLabel nor QToolTip by default support mnemonics*, so you'll have
> > to get rid of the mnemonic '&' when setting the tooltip, BUT if you pass
> > them by "set(Icon)Text" and "setShortcut" that's not necessary as the
> > action representation (menuitem, toolbutton) will make up mnemonic
> > string itself and pass it to the style for painting... (which can then
> > still decide to block them)
> >
> > *they call QStyle::DrawItemText() which does not support text flags, nor
> > widget types w/o hacking. also they're inactive.
>
> Sorry Thomas, I must admit you lost me here.
>
> Do you know how to fix this in Amarok, or not? If so, please try to
> explain how to fix it :)
Ok, after a short look into QAction, my info is meanwhile outdated, :-\
Qt meanwhile supports autoaccles from strings as well and the tooltip shall be
QAction::toolTip() -> gonna push a fix in a few hours, sorry.
If you'd like to display mnemonics in tooltips we'll have to override their
painting -> ask.
@Marco:
---------------
you want to set
q->setToolTip(action->toolTip());
rather than
q->setToolTip(KGlobal::locale()->removeAcceleratorMarker(action->text()));
as the action can have a tooltip entirely different from text() or iconText()
FYI: QAction::toolTip() and QAction::iconText() seem supposed to be accel free
while QAction::text() is not..
Cheers,
Thomas
More information about the Amarok-devel
mailing list