diff --git a/kmkernel.cpp b/kmkernel.cpp index 47a76d125..4ac25046e 100644 --- a/kmkernel.cpp +++ b/kmkernel.cpp @@ -537,11 +537,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->setShowUnreadCount(enabled); - GlobalSettings::self()->writeConfig(); + mSystemTray->setSystrayIconNotificationsEnabled( enabled ); } QStringList KMKernel::accounts() diff --git a/kmkernel.h b/kmkernel.h index 6425c7759..1056ef537 100644 --- a/kmkernel.h +++ b/kmkernel.h @@ -120,7 +120,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 5a51f7f12..43af5b214 100644 --- a/kmsystemtray.cpp +++ b/kmsystemtray.cpp @@ -63,6 +63,7 @@ KMSystemTray::KMSystemTray(QObject *parent) mMode( GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ), mCount( 0 ), mShowUnreadMailCount( true ), + mIconNotificationsEnabled( true ), mNewMessagesPopup( 0 ), mSendQueued( 0 ) { @@ -182,7 +183,7 @@ int KMSystemTray::mode() const */ void KMSystemTray::updateCount() { - if (mCount == 0) { + if (mCount == 0 || !mIconNotificationsEnabled) { setIconByName( "kmail" ); return; } @@ -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 4dd390b60..3258a572b 100644 --- a/kmsystemtray.h +++ b/kmsystemtray.h @@ -48,6 +48,14 @@ public: ~KMSystemTray(); 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; @@ -81,6 +89,8 @@ private: int mCount; bool mShowUnreadMailCount; + bool mIconNotificationsEnabled; + QMenu *mNewMessagesPopup; QAction *mSendQueued; };