[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim-runtime] agents/newmailnotifier: Add settings to specify which infos to display (settings di
From:       Montel Laurent <montel () kde ! org>
Date:       2013-06-28 18:04:26
Message-ID: E1Usd22-00044E-4b () scm ! kde ! org
[Download RAW message or body]

Git commit 3ecdfc965a41257bc0657c22385ab179a611078d by Montel Laurent.
Committed on 28/06/2013 at 18:03.
Pushed by mlaurent into branch 'master'.

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

M  +43   -0    agents/newmailnotifier/newmailnotifieragent.cpp
M  +13   -0    agents/newmailnotifier/newmailnotifieragent.h
M  +13   -0    agents/newmailnotifier/newmailnotifieragentsettings.kcfg
M  +24   -0    agents/newmailnotifier/org.freedesktop.Akonadi.NewMailNotifier.xml
 M  +14   -8    agents/newmailnotifier/specialnotifierjob.cpp

http://commits.kde.org/kdepim-runtime/3ecdfc965a41257bc0657c22385ab179a611078d


diff --git a/agents/newmailnotifier/newmailnotifieragent.cpp \
b/agents/newmailnotifier/newmailnotifieragent.cpp index b76f1c9..f7e1478 \
                100644
--- a/agents/newmailnotifier/newmailnotifieragent.cpp
+++ b/agents/newmailnotifier/newmailnotifieragent.cpp
@@ -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)
 {
diff --git a/agents/newmailnotifier/newmailnotifieragent.h \
b/agents/newmailnotifier/newmailnotifieragent.h index f7f83aa..eaac561 \
                100644
--- a/agents/newmailnotifier/newmailnotifieragent.h
+++ b/agents/newmailnotifier/newmailnotifieragent.h
@@ -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:
diff --git a/agents/newmailnotifier/newmailnotifieragentsettings.kcfg \
b/agents/newmailnotifier/newmailnotifieragentsettings.kcfg index \
                d5e749f..1dd6425 100644
--- a/agents/newmailnotifier/newmailnotifieragentsettings.kcfg
+++ b/agents/newmailnotifier/newmailnotifieragentsettings.kcfg
@@ -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>
diff --git a/agents/newmailnotifier/org.freedesktop.Akonadi.NewMailNotifier.xml \
b/agents/newmailnotifier/org.freedesktop.Akonadi.NewMailNotifier.xml index \
                1647ea9..f45e5d9 100644
--- a/agents/newmailnotifier/org.freedesktop.Akonadi.NewMailNotifier.xml
+++ b/agents/newmailnotifier/org.freedesktop.Akonadi.NewMailNotifier.xml
@@ -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>
diff --git a/agents/newmailnotifier/specialnotifierjob.cpp \
b/agents/newmailnotifier/specialnotifierjob.cpp index cb59e71..6c47c09 \
                100644
--- a/agents/newmailnotifier/specialnotifierjob.cpp
+++ b/agents/newmailnotifier/specialnotifierjob.cpp
@@ -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));  }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic