Commit 4af112b9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove duplicate code

parent ad2b984f
......@@ -260,7 +260,8 @@ void NewMailNotifierAgent::showNotifications()
}
}
if (numberOfEmail == 1) {
new SpecialNotifierJob(item, this);
SpecialNotifierJob *job = new SpecialNotifierJob(item, this);
connect(job, SIGNAL(displayNotification(QPixmap,QString)), SLOT(slotDisplayNotification(QPixmap,QString)));
mNewMails.clear();
return;
} else {
......@@ -272,16 +273,20 @@ void NewMailNotifierAgent::showNotifications()
kDebug() << message;
Util::showNotification(Util::defaultPixmap(), message);
if ( mBeepOnNewMails ) {
KNotification::beep();
}
slotDisplayNotification(Util::defaultPixmap(), message);
mNewMails.clear();
}
void NewMailNotifierAgent::slotDisplayNotification(const QPixmap &pixmap, const QString &message)
{
Util::showNotification(pixmap, message);
if ( mBeepOnNewMails ) {
KNotification::beep();
}
}
void NewMailNotifierAgent::slotInstanceStatusChanged(const Akonadi::AgentInstance &instance)
{
......
......@@ -60,6 +60,7 @@ private slots:
void configure(WId windowId);
void slotInstanceStatusChanged(const Akonadi::AgentInstance &instance);
void slotInstanceRemoved(const Akonadi::AgentInstance &instance);
void slotDisplayNotification(const QPixmap &pixmap, const QString &message);
private:
void clearAll();
......
......@@ -53,7 +53,7 @@ void SpecialNotifierJob::slotItemFetchJobDone(KJob *job)
return;
}
Akonadi::Item::List lst = qobject_cast<Akonadi::ItemFetchJob*>( job )->items();
const Akonadi::Item::List lst = qobject_cast<Akonadi::ItemFetchJob*>( job )->items();
if (lst.count() == 1) {
Akonadi::Item item = lst.first();
if ( !item.hasPayload<KMime::Message::Ptr>() ) {
......@@ -79,7 +79,7 @@ void SpecialNotifierJob::slotSearchJobFinished( KJob *job )
const Akonadi::ContactSearchJob *searchJob = qobject_cast<Akonadi::ContactSearchJob*>( job );
if ( searchJob->error() ) {
kWarning() << "Unable to fetch contact:" << searchJob->errorText();
Util::showNotification(Util::defaultPixmap(), i18n("from: %1 \nSubject: %2",mFrom, mSubject));
emit displayNotification(Util::defaultPixmap(), i18n("from: %1 \nSubject: %2",mFrom, mSubject));
deleteLater();
return;
}
......@@ -87,9 +87,9 @@ void SpecialNotifierJob::slotSearchJobFinished( KJob *job )
const KABC::Addressee addressee = searchJob->contacts().first();
const KABC::Picture photo = addressee.photo();
const QImage image = photo.data();
Util::showNotification(QPixmap::fromImage(image), i18n("from: %1 \nSubject: %2",mFrom, mSubject));
emit displayNotification(QPixmap::fromImage(image), i18n("from: %1 \nSubject: %2",mFrom, mSubject));
} else {
Util::showNotification(Util::defaultPixmap(), i18n("from: %1 \nSubject: %2",mFrom, mSubject));
emit displayNotification(Util::defaultPixmap(), i18n("from: %1 \nSubject: %2",mFrom, mSubject));
}
deleteLater();
}
......
......@@ -30,6 +30,9 @@ public:
explicit SpecialNotifierJob(Akonadi::Item::Id id, QObject *parent = 0);
~SpecialNotifierJob();
Q_SIGNALS:
void displayNotification(const QPixmap &pixmap, const QString &message);
private Q_SLOTS:
void slotSearchJobFinished( KJob *job );
void slotItemFetchJobDone(KJob*);
......
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