[Kde-pim] KMail System Tray Idea

ComputerDruid computerdruid at gmail.com
Thu Apr 16 03:24:08 BST 2009


Hi, this is my first list post, and my first real foray into KDE contribution.

I was wondering about a feature for kmail's system tray Icon:
I use gmail with IMAP, which has an "All Mail" folder as well as an "Inbox" 
folder, and when a new mail arrives, 2 unread messages show up, one in each. 
In the main kmail window there is the "favorite folders" section which shows 
the important bits (but allows me to move the messages to other folders, 
etc.). But in the system tray, it just shows up as a number. So in this case, 
the number shown is generally 2x the number of unread mails. So I was 
wondering if it would be a good idea to have an option where only favorite 
folders are counted towards this number. It isn't that hard to implement (I 
have a basic patch without configuration and stuff) would this be useful in 
other situations outside the gmail usecase? Is this worth including or is a 
feature that would only be useful to me?

My first attempt at coding this up (this works, but isn't as configurable as 
I'd like):

diff --git a/kmsystemtray.cpp b/kmsystemtray.cpp
index 57888e3..a87d09f 100644
--- a/kmsystemtray.cpp
+++ b/kmsystemtray.cpp
@@ -481,16 +481,22 @@ void KMSystemTray::updateNewMessages()
     QMap<QPointer<KMFolder>, int>::Iterator it = mFoldersWithUnread.find( fldr );
     bool unmapped = ( it == mFoldersWithUnread.end() );
 
-    // If the folder is not mapped yet, increment count by numUnread
-    // in folder
-    if ( unmapped )
-      mCount += unread;
-
-    //Otherwise, get the difference between the numUnread in the folder and
-    // our last known version, and adjust mCount with that difference
-    else {
-      int diff = unread - it.value();
-      mCount += diff;
+    int idx = GlobalSettings::self()->favoriteFolderIds().indexOf( fldr->id() );
+    if ( idx >= 0 ) {
+      // In favorites. Only count it since we don't want the non-favorite
+      // folders in the count
+
+      // If the folder is not mapped yet, increment count by numUnread
+      // in folder
+      if ( unmapped )
+        mCount += unread;
+
+      //Otherwise, get the difference between the numUnread in the folder and
+      // our last known version, and adjust mCount with that difference
+      else {
+        int diff = unread - it.value();
+        mCount += diff;
+      }
     }
 
     if ( unread > 0 ) {


Thanks,
-- 
-ComputerDruid

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090415/d9d8e78d/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list