diff --git a/kmkernel.cpp b/kmkernel.cpp index 18ce37a05..705587539 100644 --- a/kmkernel.cpp +++ b/kmkernel.cpp @@ -458,11 +458,9 @@ void KMKernel::checkMail () //might create a new reader but won't show!! } } -void KMKernel::setSystrayUnreadCountEnabled(bool enabled) +void KMKernel::setSystrayIconNotificationsEnabled( bool enabled ) { - GlobalSettings::self()->systemTrayShowUnreadItem()->setValue(enabled); - mSystemTray->setShowUnread(enabled); - GlobalSettings::self()->writeConfig(); + mSystemTray->setSystrayIconNotificationsEnabled( enabled ); } QStringList KMKernel::accounts() @@ -2019,7 +2017,7 @@ void KMKernel::toggleSystemTray() // Set mode of systemtray. If mode has changed, tray will handle this. if ( mSystemTray ) { mSystemTray->setMode( GlobalSettings::self()->systemTrayPolicy() ); - mSystemTray->setShowUnread( GlobalSettings::self()->systemTrayShowUnread() ); + mSystemTray->setShowUnreadCount( GlobalSettings::self()->systemTrayShowUnread() ); } } diff --git a/kmkernel.h b/kmkernel.h index 17f131a15..b2fa24d77 100644 --- a/kmkernel.h +++ b/kmkernel.h @@ -118,7 +118,11 @@ public Q_SLOTS: Q_SCRIPTABLE void checkMail(); Q_SCRIPTABLE void openReader() { openReader( false ); } - Q_SCRIPTABLE void setSystrayUnreadCountEnabled(bool enabled); + /** + * Enables/disables systray icon changing when mail arrives. + * With this disabled the systray icon will always be the same. + */ + Q_SCRIPTABLE void setSystrayIconNotificationsEnabled( bool enabled ); /** * Pauses all background jobs and does not diff --git a/kmsystemtray.cpp b/kmsystemtray.cpp index 29c53b30c..1d3668ae3 100644 --- a/kmsystemtray.cpp +++ b/kmsystemtray.cpp @@ -62,7 +62,8 @@ KMSystemTray::KMSystemTray(QObject *parent) mDesktopOfMainWin( 0 ), mMode( GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ), mCount( 0 ), - mShowUnreadMail( true ), + mShowUnreadMailCount( true ), + mIconNotificationsEnabled( true ), mNewMessagesPopup( 0 ), mSendQueued( 0 ) { @@ -142,11 +143,11 @@ KMSystemTray::~KMSystemTray() { } -void KMSystemTray::setShowUnread(bool showUnread) +void KMSystemTray::setShowUnreadCount(bool showUnreadCount) { - if (mShowUnreadMail == showUnread) + if (mShowUnreadMailCount == showUnreadCount) return; - mShowUnreadMail = showUnread; + mShowUnreadMailCount = showUnreadCount; updateSystemTray(); } @@ -182,11 +183,11 @@ int KMSystemTray::mode() const */ void KMSystemTray::updateCount() { - if (mCount == 0) { + if (mCount == 0 || !mIconNotificationsEnabled) { setIconByName( QLatin1String("kmail") ); return; } - if (mShowUnreadMail) { + if (mShowUnreadMailCount) { const int overlaySize = KIconLoader::SizeSmallMedium; const QString countString = QString::number( mCount ); @@ -229,6 +230,13 @@ void KMSystemTray::updateCount() } } +void KMSystemTray::setSystrayIconNotificationsEnabled( bool enabled ) +{ + if ( enabled != mIconNotificationsEnabled ) { + mIconNotificationsEnabled = enabled; + updateSystemTray(); + } +} /** * On left mouse click, switch focus to the first KMMainWidget. On right diff --git a/kmsystemtray.h b/kmsystemtray.h index 427a9ff16..7ce970e30 100644 --- a/kmsystemtray.h +++ b/kmsystemtray.h @@ -41,7 +41,15 @@ public: /** destructor */ ~KMSystemTray(); - void setShowUnread(bool showUnread); + void setShowUnreadCount(bool showUnreadCount); + + /** + * Use this method to disable any systray icon changing. + * By default this is enabled and you'll see the "new e-mail" icon whenever there's + * new e-mail. + */ + void setSystrayIconNotificationsEnabled(bool enable); + void setMode(int mode); int mode() const; @@ -73,7 +81,9 @@ private: int mMode; int mCount; - bool mShowUnreadMail; + bool mShowUnreadMailCount; + bool mIconNotificationsEnabled; + QMenu *mNewMessagesPopup; QAction *mSendQueued; };