[Development] QSystemTrayIcon label (so-called title) on OS X

Ilya Kowalewski illya.kovalevskyy at gmail.com
Mon Jan 26 00:52:51 CET 2015


The label itself has nothing to do with messages or notifications. As you
can see on the screenshot, it's informative string assigned to the icon
itself. A possible usecase I keep in mind is to display number of unread
messages there (for a messaging application). Adding this to public API is
absolutely fine to me, but as far as I understood from what Thiago said,
this won't get accepted, since it's a platform-wise feature, not available
on other platforms.

On Mon Jan 26 2015 at 1:46:39 AM Allan Sandfeld Jensen <kde at carewolf.com>
wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150125/b6d66ac9/attachment.html>


More information about the Development mailing list