Bug 279279 - (KStatusNotifierItem): Message Counts in KMail tray icon don't show when using a plasma themed svg icon
Summary: (KStatusNotifierItem): Message Counts in KMail tray icon don't show when usin...
Status: RESOLVED DUPLICATE of bug 377521
Alias: None
Product: kmail2
Classification: Applications
Component: UI (show other bugs)
Version: 5.1.2
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-03 11:34 UTC by Kubicle
Modified: 2018-01-28 14:40 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kubicle 2011-08-03 11:34:14 UTC
Version:           2.1.0 (using KDE 4.7.0) 
OS:                Linux

Kmail2 now uses KStatusNotifierItem for the tray icon, which means the icon is plasma themable by adding a kmail.svg(z) file in a plasma theme.

The svg icon works fine, but the unread email overlays don't show on the icon when using a svg icon, probably because of the way the overlay is drawn in kmsystemtray.cpp:

[quote]
// Paint the number in a pixmap
  QPixmap overlayPixmap( overlaySize, overlaySize );
  overlayPixmap.fill( Qt::transparent );

  QPainter p( &overlayPixmap );
  p.setFont( countFont );
  KColorScheme scheme( QPalette::Active, KColorScheme::View );

  p.setBrush( Qt::NoBrush );
  p.setPen( scheme.foreground( KColorScheme::LinkText ).color() );
  p.setOpacity( 1.0 );
  p.drawText( overlayPixmap.rect(), Qt::AlignCenter, countString );
  p.end();

  QPixmap iconPixmap = mIcon.pixmap(overlaySize, overlaySize);

  QPainter pp(&iconPixmap);
  pp.drawPixmap(0, 0, overlayPixmap);
  pp.end();

  setIconByPixmap( iconPixmap );
[/quote]

Because of this, a user cannot tell whether there is new mail by looking at the tray icon.

Possible ways to fix:
1. draw the message count overlay in an plasma theme (svg) friendly way, if possible, or
2. use a different icon (mail-unread-new, for example) when there is new mail. This won't show the email counts either, but provides visual feedback for the user when there are new mails.

Reproducible: Always

Steps to Reproduce:
1. Create a valid plasma themed kmail.svg icon in your plasma themes icon folder. 
2. Configure kmail to always show the tray icon
3. Restart plasma and kmail if necessary to show the new icon
4. Wait for new mail

Actual Results:  
New message count is not shown on the tray icon.

Expected Results:  
Message count is shown on the icon when there are new mails.

The above is also true for akregator's icon (when using a plasma themed svg), I can report a new bug report for akregator if requested.

If you need more information, I'd be happy to provide it.

Thanks for your time.
Comment 1 Aaron J. Seigo 2011-08-03 12:59:40 UTC
currently theming system tray icons with SVGs and application custom-painting are mutually exclusive. for now, i recommend not using a themed svg for kmail if you wish to see the count. (that customization combined with the status removing "always show this icon" modification makes this already seem a bit fishy: the user has carefully removed all means of status change notification. :)

we may in future support something along the lines of (limited) custom overlays (such as counts) to status notifiers.
Comment 2 Kubicle 2011-08-03 15:08:11 UTC
Thanks for a quick response.

Yes, this more of a minor nuisance (not many plasma themes include kmail/akregator icons), with a number of workarounds available (like using a customized regular png icon for theming).

The use case for "always show icon" is that this is the only way (that I know of) to keep kmail loaded and running in the background when closing it's window, so it would be nice to have some new message feedback even with an svg icon (even if message counts are off the table at this point).

For example, kopete handles svg icon files nicely by switching "kopete" and "kopete-offline" icons when necessary (and can even load the small status overlays over the svgs).
Comment 3 Kubicle 2011-08-04 07:22:47 UTC
The simplest way to "solve" the problem could be just switching the icon when there's new mail (diff below):

74c74
<   mIcon = KIcon( "kmail" );
---
>   mIcon = KIcon( "mail-unread-new" );
184a185
>   setIconByName( "mail-unread-new" );

Of course this could be configurable in a similar way that user's can choose their own icons for mail folders. And a few more changes would be required to reflect the new mail status in the tray icon tooltip as well.
Comment 4 Kubicle 2011-09-22 08:02:50 UTC
Another option could be toggling the active/passive mode in the StatusNotifierItem based on whether there is mail or not.

(That seems to be the tendency in StatusNotifierItems, go active when there is something noteworthy and remain passive [hidden] otherwise).

This shouldn't be a problem for those that wish to have the icon always shown, as "always show icon" can be forced in the notification tray settings.
Comment 5 Laurent Montel 2012-03-30 11:30:34 UTC
Git commit 487cace7ac63c51e89585475a808abcdf5ff86ae by Montel Laurent.
Committed on 30/03/2012 at 13:29.
Pushed by mlaurent into branch 'master'.

Change icon when we have unread emails

M  +3    -1    kmail/kmsystemtray.cpp

http://commits.kde.org/kdepim/487cace7ac63c51e89585475a808abcdf5ff86ae
Comment 6 Laurent Montel 2012-03-30 11:31:47 UTC
Git commit 9d579cdb3ea4765f373563f00648d9577473edf2 by Montel Laurent.
Committed on 30/03/2012 at 13:29.
Pushed by mlaurent into branch 'KDE/4.8'.

Change icon when we have unread emails
(cherry picked from commit 487cace7ac63c51e89585475a808abcdf5ff86ae)

M  +3    -1    kmail/kmsystemtray.cpp

http://commits.kde.org/kdepim/9d579cdb3ea4765f373563f00648d9577473edf2
Comment 7 Kubicle 2012-04-05 08:54:35 UTC
Much appreciated...

Looking forward to the change in 4.9 and 4.8.3 (If I've understood the commits correctly?)
Comment 8 Laurent Montel 2012-04-05 10:11:16 UTC
yes in 4.8.2/4.9
Comment 9 Hrvoje Senjan 2012-10-25 19:48:11 UTC
I'm not sure how to interpret this correctly. It's still unconfirmed, and it does not work, but according to messages it is supposed to be fixed?
Comment 10 manutortosa@gmail.com 2012-11-24 18:38:28 UTC
The issue is still present using kde 4.10 beta1
Comment 11 Björn Bidar 2016-03-10 01:17:52 UTC
still the case in latest kmail: 15.12.2-1
Comment 12 Jonathan Marten 2018-01-28 14:40:56 UTC

*** This bug has been marked as a duplicate of bug 377521 ***