Commit 3ecdfc96 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add settings to specify which infos to display (settings dialog in 4.12)

parent 4c370db2
......@@ -86,6 +86,49 @@ NewMailNotifierAgent::NewMailNotifierAgent( const QString &id )
//qDebug()<<" NewMailNotifierAgent::NewMailNotifierAgent:"<<id;
}
void NewMailNotifierAgent::setShowPhoto(bool show)
{
NewMailNotifierAgentSettings::setShowPhoto(show);
NewMailNotifierAgentSettings::self()->writeConfig();
}
bool NewMailNotifierAgent::showPhoto() const
{
return NewMailNotifierAgentSettings::showPhoto();
}
void NewMailNotifierAgent::setShowFrom(bool show)
{
NewMailNotifierAgentSettings::setShowFrom(show);
NewMailNotifierAgentSettings::self()->writeConfig();
}
bool NewMailNotifierAgent::showFrom() const
{
return NewMailNotifierAgentSettings::showFrom();
}
void NewMailNotifierAgent::setShowSubject(bool show)
{
NewMailNotifierAgentSettings::setShowSubject(show);
NewMailNotifierAgentSettings::self()->writeConfig();
}
bool NewMailNotifierAgent::showSubject() const
{
return NewMailNotifierAgentSettings::showSubject();
}
void NewMailNotifierAgent::setShowFolderName(bool show)
{
NewMailNotifierAgentSettings::setShowFolder(show);
NewMailNotifierAgentSettings::self()->writeConfig();
}
bool NewMailNotifierAgent::showFolderName() const
{
return NewMailNotifierAgentSettings::showFolder();
}
void NewMailNotifierAgent::setEnableNotifier(bool enabled)
{
......
......@@ -49,6 +49,19 @@ public:
void setBeepOnNewMails(bool b);
bool beepOnNewMails() const;
void setShowPhoto(bool b);
bool showPhoto() const;
void setShowFrom(bool b);
bool showFrom() const;
void setShowSubject(bool b);
bool showSubject() const;
void setShowFolderName(bool b);
bool showFolderName() const;
void printDebug();
protected:
......
......@@ -13,5 +13,18 @@
<entry name="enabled" key="enabled" type="Bool">
<default>true</default>
</entry>
<entry name="showPhoto" key="showPhoto" type="Bool">
<default>true</default>
</entry>
<entry name="showFrom" key="showFrom" type="Bool">
<default>true</default>
</entry>
<entry name="showSubject" key="showSubject" type="Bool">
<default>true</default>
</entry>
<entry name="showFolder" key="showFolder" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>
......@@ -19,6 +19,30 @@
<method name="beepOnNewMails" >
<arg type="b" direction="out"/>
</method>
<method name="setShowPhoto" >
<arg type="b" direction="in"/>
</method>
<method name="showPhoto" >
<arg type="b" direction="out"/>
</method>
<method name="setShowFrom" >
<arg type="b" direction="in"/>
</method>
<method name="showFrom" >
<arg type="b" direction="out"/>
</method>
<method name="setShowSubject" >
<arg type="b" direction="in"/>
</method>
<method name="showSubject" >
<arg type="b" direction="out"/>
</method>
<method name="setShowFolderName" >
<arg type="b" direction="in"/>
</method>
<method name="showFolderName" >
<arg type="b" direction="out"/>
</method>
<method name="printDebug" />
</interface>
</node>
......@@ -17,6 +17,7 @@
#include "specialnotifierjob.h"
#include "util.h"
#include "newmailnotifieragentsettings.h"
#include <Akonadi/Contact/ContactSearchJob>
#include <Akonadi/ItemFetchJob>
......@@ -64,14 +65,18 @@ void SpecialNotifierJob::slotItemFetchJobDone(KJob *job)
deleteLater();
return;
}
const KMime::Message::Ptr mb = item.payload<KMime::Message::Ptr>();
const KMime::Message::Ptr mb = item.payload<KMime::Message::Ptr>();
mFrom = mb->from()->asUnicodeString();
mSubject = mb->subject()->asUnicodeString();
Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob( this );
job->setLimit( 1 );
job->setQuery( Akonadi::ContactSearchJob::Email, KPIMUtils::firstEmailAddress(mFrom).toLower(), Akonadi::ContactSearchJob::ExactMatch );
connect( job, SIGNAL(result(KJob*)), SLOT(slotSearchJobFinished(KJob*)) );
if (NewMailNotifierAgentSettings::showPhoto()) {
Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob( this );
job->setLimit( 1 );
job->setQuery( Akonadi::ContactSearchJob::Email, KPIMUtils::firstEmailAddress(mFrom).toLower(), Akonadi::ContactSearchJob::ExactMatch );
connect( job, SIGNAL(result(KJob*)), SLOT(slotSearchJobFinished(KJob*)) );
} else {
emitNotification(Util::defaultPixmap());
}
} else {
kdWarning()<<" Found item different from 1: "<<lst.count();
deleteLater();
......@@ -92,10 +97,10 @@ void SpecialNotifierJob::slotSearchJobFinished( KJob *job )
const KABC::Addressee addressee = searchJob->contacts().first();
const KABC::Picture photo = addressee.photo();
const QImage image = photo.data();
if (!image.isNull()) {
emitNotification(QPixmap::fromImage(image));
} else {
if (image.isNull()) {
emitNotification(Util::defaultPixmap());
} else {
emitNotification(QPixmap::fromImage(image));
}
} else {
emitNotification(Util::defaultPixmap());
......@@ -110,6 +115,7 @@ void SpecialNotifierJob::emitNotification(const QPixmap &pixmap)
subject.truncate(80);
subject += QLatin1String("...");
}
//TODO 4.12 use showFrom/showFolder/showSubject
emit displayNotification(pixmap, i18n("from: %1 <br>Subject: %2<br>In: %3",Qt::escape(mFrom), Qt::escape(subject), mPath));
}
......
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