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

List:       kde-commits
Subject:    playground/base/plasma/applets/systray-refactor
From:       Jason Stubbs <jasonbstubbs () gmail ! com>
Date:       2008-09-21 13:45:58
Message-ID: 1222004758.602209.11308.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 863224 by jstubbs:

Half merged the extendified_notify applet. Receipt and display of
notifications is working, although I've temporarily disabled actions.

Still to do:
* Get actions working again
* Allow closing of a notification without having to drag it away and close
  it as a regular applet
* Implement timeouts and other cases where a notification is closed without
  user interaction
* Figure out what to do about saving/restoring notifications across plasma
  restarts - especially when the notifying app is no longer running


 M  +2 -0      CMakeLists.txt  
 AM            Messages.sh  
 M  +13 -0     core/notification.cpp  
 M  +4 -2      core/notification.h  
 M  +2 -2      core/task.h  
 M  +2 -1      protocols/dbus/dbusnotificationprotocol.cpp  
 M  +27 -1     ui/applet.cpp  
 M  +4 -2      ui/applet.h  
 AM            ui/notificationwidget.cpp   \
trunk/playground/base/plasma/applets/extendified_notify/notificationwidget.cpp#863143 \
[License: LGPL (v2+)]  AM            ui/notificationwidget.h   \
trunk/playground/base/plasma/applets/extendified_notify/notificationwidget.h#863143 \
[License: LGPL (v2+)]  AM            ui/notifytextitem.cpp   \
trunk/playground/base/plasma/applets/extendified_notify/notifytextitem.cpp#863143 \
[License: LGPL (v2+)]  AM            ui/notifytextitem.h   \
trunk/playground/base/plasma/applets/extendified_notify/notifytextitem.h#863143 \
[License: LGPL (v2+)]


--- trunk/playground/base/plasma/applets/systray-refactor/CMakeLists.txt \
#863223:863224 @@ -26,6 +26,8 @@
     ui/applet.cpp
     ui/compactlayout.cpp
     ui/taskarea.cpp
+    ui/notificationwidget.cpp
+    ui/notifytextitem.cpp
 
     )
 
** trunk/playground/base/plasma/applets/systray-refactor/Messages.sh #property \
svn:executable  + *
--- trunk/playground/base/plasma/applets/systray-refactor/core/notification.cpp \
#863223:863224 @@ -38,6 +38,7 @@
     QString appName;
     QPixmap appIcon;
     QString message;
+    QString summary;
     int timeout;
 };
 
@@ -92,6 +93,18 @@
 }
 
 
+QString Notification::summary() const
+{
+    return d->summary;
+}
+
+
+void Notification::setSummary(const QString &summary)
+{
+    d->summary = summary;
+}
+
+
 int Notification::timeout() const
 {
     return d->timeout;
--- trunk/playground/base/plasma/applets/systray-refactor/core/notification.h \
#863223:863224 @@ -41,20 +41,22 @@
     QString appName() const;
     QPixmap appIcon() const;
     QString message() const;
+    QString summary() const;
     int timeout() const;
 
 signals:
-    void changed(SystemTray::Notification *notification);
+    void changed(SystemTray::Notification *notification = 0);
 
     /**
      * Emitted when the notification is about to be destroyed
      **/
-    void destroyed(SystemTray::Notification *notification);
+    void destroyed(SystemTray::Notification *notification = 0);
 
 protected:
     void setAppName(const QString &appName);
     void setAppIcon(const QPixmap &appIcon);
     void setMessage(const QString &message);
+    void setSummary(const QString &summary);
     void setTimeout(int timeout);
 
 private:
--- trunk/playground/base/plasma/applets/systray-refactor/core/task.h #863223:863224
@@ -91,12 +91,12 @@
     /**
      * Emitted when something about the task has changed
      **/
-    void changed(SystemTray::Task *task);
+    void changed(SystemTray::Task *task = 0);
 
     /**
      * Emitted when the task is about to be destroyed
      **/
-    void destroyed(SystemTray::Task *task);
+    void destroyed(SystemTray::Task *task = 0);
 
 protected:
     Task();
--- trunk/playground/base/plasma/applets/systray-refactor/protocols/dbus/dbusnotificationprotocol.cpp \
#863223:863224 @@ -99,8 +99,9 @@
     }
 
     Notification* notification = d->notifications[source];
-    // TODO: Support appIcon, summary, actions
+    // TODO: Support appIcon, actions
     notification->setAppName(data.value("appName").toString());
+    notification->setSummary(data.value("summary").toString());
     notification->setMessage(data.value("body").toString());
     notification->setTimeout(data.value("expireTimeout").toInt());
 
--- trunk/playground/base/plasma/applets/systray-refactor/ui/applet.cpp \
#863223:863224 @@ -22,6 +22,7 @@
 
 // Own
 #include "applet.h"
+#include "notificationwidget.h"
 #include "../core/manager.h"
 
 // KDE
@@ -35,6 +36,8 @@
 // Plasma
 #include <plasma/panelsvg.h>
 #include <plasma/theme.h>
+#include <plasma/extender.h>
+#include <plasma/extenderitem.h>
 
 
 namespace SystemTray
@@ -63,12 +66,15 @@
 
 
 Applet::Applet(QObject *parent, const QVariantList &arguments)
-    : Plasma::Applet(parent, arguments),
+    : Plasma::PopupApplet(parent, arguments),
       d(new Private())
 {
     d->background = new Plasma::PanelSvg(this);
     d->background->setImagePath("widgets/systemtray");
 
+    setPopupIcon(QIcon());
+    setAspectRatioMode(Plasma::KeepAspectRatio);
+
     setHasConfigurationInterface(true);
 }
 
@@ -92,6 +98,10 @@
     checkSizes();
 
     d->taskArea->syncTasks();
+
+    extender()->setEmptyExtenderMessage(i18n("No notifications..."));
+    connect(SystemTray::Manager::self(), \
SIGNAL(notificationAdded(SystemTray::Notification*)), +            this, \
SLOT(addNotification(SystemTray::Notification*)));  }
 
 
@@ -242,6 +252,22 @@
 }
 
 
+void Applet::addNotification(Notification *notification)
+{
+    Plasma::ExtenderItem *extenderItem = new Plasma::ExtenderItem(extender());
+    extenderItem->setWidget(new NotificationWidget(notification, extenderItem));
+    extenderItem->setIcon("preferences-desktop-notification");
+
+    if (!notification->summary().isEmpty()) {
+        extenderItem->setTitle(notification->summary());
+    } else {
+        extenderItem->setTitle(i18n("Notification from %1", \
notification->appName())); +    }
+
+    showPopup();
+}
+
+
 };
 
 #include "applet.moc"
--- trunk/playground/base/plasma/applets/systray-refactor/ui/applet.h #863223:863224
@@ -23,7 +23,7 @@
 #define APPLET_H
 
 // Plasma
-#include <plasma/applet.h>
+#include <plasma/popupapplet.h>
 
 // Qt
 #include <QGraphicsLinearLayout>
@@ -31,12 +31,13 @@
 // Own
 #include "taskarea.h"
 #include "../core/task.h"
+#include "../core/notification.h"
 
 
 namespace SystemTray
 {
 
-class Applet : public Plasma::Applet
+class Applet : public Plasma::PopupApplet
 {
     Q_OBJECT
 
@@ -54,6 +55,7 @@
     void configAccepted();
     void propogateSizeHintChange(Qt::SizeHint which);
     void checkSizes();
+    void addNotification(SystemTray::Notification *notification);
 
 private:
     class Private;
** trunk/playground/base/plasma/applets/systray-refactor/ui/notificationwidget.cpp \
#property svn:mergeinfo  + 
** trunk/playground/base/plasma/applets/systray-refactor/ui/notificationwidget.h \
#property svn:mergeinfo  + 
** trunk/playground/base/plasma/applets/systray-refactor/ui/notifytextitem.cpp \
#property svn:mergeinfo  + 
** trunk/playground/base/plasma/applets/systray-refactor/ui/notifytextitem.h \
#property svn:mergeinfo  + 


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

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