Strange ampersand in Plasma tooltips

Thomas Lübking thomas.luebking at web.de
Mon Mar 1 16:02:33 CET 2010


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.

Cheers,
Thomas

Am Monday 01 March 2010 schrieb Mark Kretschmann:
> Heya,
> 
> I'm having a weird issue here, and I wonder if it's just me, or if
> it's maybe a bug in Plasma:
> 
> Many of the tooltips of the Plasma::IconWidget buttons we use in
> Amarok (like in the toolbar and in applets) contain weird ampersand
> characters, that is "&". I assume they come from keyboard shortcuts,
> but surely they shouldn't be shown in the tooltip, no?
> 
> I've asked about this in the #plasma IRC channel before, but noone had
> an idea. Do you have any? :)
> 
> 
> Attaching a screenshot of this issue.



More information about the Amarok-devel mailing list