Commit 55050fcf authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add beep on new mail (as in kmail)

parent 3274c74e
......@@ -51,7 +51,8 @@ using namespace Akonadi;
NewMailNotifierAgent::NewMailNotifierAgent( const QString &id )
: AgentBase( id ),
mNotifierEnabled(true),
mVerboseNotification(true)
mVerboseNotification(true),
mBeepOnNewMails(false)
{
KGlobal::locale()->insertCatalog( "newmailnotifieragent" );
Akonadi::AttributeFactory::registerAttribute<NewMailNotifierAttribute>();
......@@ -83,6 +84,7 @@ NewMailNotifierAgent::NewMailNotifierAgent( const QString &id )
KConfigGroup group( KGlobal::config(), "General" );
mNotifierEnabled = group.readEntry( "enabled", true);
mVerboseNotification = group.readEntry("verboseNotification", true);
mBeepOnNewMails = group.readEntry( "beepOnNewMails", false);
if (mNotifierEnabled) {
mTimer.setSingleShot( true );
......@@ -104,9 +106,11 @@ void NewMailNotifierAgent::setEnableNotifier(bool b)
void NewMailNotifierAgent::setVerboseMailNotification(bool b)
{
mVerboseNotification = b;
KConfigGroup group( KGlobal::config(), "General" );
group.writeEntry( "verboseNotification", mVerboseNotification);
if (mVerboseNotification != b) {
mVerboseNotification = b;
KConfigGroup group( KGlobal::config(), "General" );
group.writeEntry( "verboseNotification", mVerboseNotification);
}
}
bool NewMailNotifierAgent::verboseMailNotification() const
......@@ -114,6 +118,21 @@ bool NewMailNotifierAgent::verboseMailNotification() const
return mVerboseNotification;
}
void NewMailNotifierAgent::setBeepOnNewMails(bool b)
{
if (mBeepOnNewMails != b) {
mBeepOnNewMails = b;
KConfigGroup group( KGlobal::config(), "General" );
group.writeEntry( "beepOnNewMails", mBeepOnNewMails);
}
}
bool NewMailNotifierAgent::beepOnNewMails() const
{
return mBeepOnNewMails;
}
void NewMailNotifierAgent::clearAll()
{
mNewMails.clear();
......@@ -247,6 +266,10 @@ void NewMailNotifierAgent::showNotifications()
KNotification::CloseOnTimeout,
KGlobal::mainComponent());
if ( mBeepOnNewMails ) {
KNotification::beep();
}
mNewMails.clear();
}
......
......@@ -46,6 +46,8 @@ public:
void setVerboseMailNotification(bool b);
bool verboseMailNotification() const;
void setBeepOnNewMails(bool b);
bool beepOnNewMails() const;
void printDebug();
......@@ -67,6 +69,7 @@ private:
QStringList mInstanceNameInProgress;
bool mNotifierEnabled;
bool mVerboseNotification;
bool mBeepOnNewMails;
};
#endif
......@@ -13,6 +13,12 @@
<method name="verboseMailNotification" >
<arg type="b" direction="out"/>
</method>
<method name="setBeepOnNewMails" >
<arg type="b" direction="in"/>
</method>
<method name="beepOnNewMails" >
<arg type="b" direction="out"/>
</method>
<method name="printDebug" />
</interface>
</node>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment