[Development] QSystemTrayIcon label (so-called title) on OS X
Allan Sandfeld Jensen
kde at carewolf.com
Mon Jan 26 00:46:36 CET 2015
On Monday 26 January 2015, Ilya Kowalewski wrote:
> Hiho there,
>
> I was wondering how to implement support for QSystemTrayIcon label feature
> we have here on OS X in Qt. For those of you who are not familiar with this
> feature it's an optional text label on the right to the tray icon (
> http://i.imgur.com/c98Nn08.png — red rectangle).
>
> After a discussion with thiago and richmoore1 on IRC, I got the whole
> picture of the problem. So, here we go. In Cocoa, tray icon is represented
> with NSStatusItem, which is created and maintained in QCocoaSystemTrayIcon
> (a child of QPlatformSystemTrayIcon interface), which is itself created
> somewhere in qpa cocoa plugin. So by introducing
> QCocoaSystemTrayIcon::setTitle(const
> QString&) we could implement the feature itself.
>
> The problem appears when we try to use it in public API. As you might
> noticed, QSystemTrayIcon's public API has nothing to do with
> QPlatformSystemTrayIcon
> at all. A possible solution would be to add a public API method
> QSystemTrayIcon::setTitle(const
> QString&), that would actually work on OS X only, but that's not the way to
> go (we don't want platform-wise features in public api, yeah?).
>
> Then the only visible solution I can think of is adding a friendly class to
> QtMacExtras, which will access private d-pointer of passed QSystemTrayIcon*
> instance, in order to get its QPlatformSystemTrayIcon (later casted to
> QCocoaSystemTrayIcon).
>
> Still I am not sure what's the way to go here. So guys, what do you think?
Is the label supposed to change according to messages, or is fixed?
If it changes, then you could control it with the message title. If not I
would suggest adding it to the API, and just document where it works. I know
there are other parts of that particular API that doesn't work on OS X either.
Regards
`Allan
More information about the Development
mailing list