[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-10-05 4:24:17
Message-ID: 1223180657.257032.11841.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 867958 by jstubbs:

Remove all actions on destroyed notifications and the automatic "close"
action on actionless notifications for notifications that have been
detached. This essentially means that a destroyed notification will
remain open if it has been detached but can no longer be interacted with.


 M  +0 -2      TODO  
 M  +24 -5     ui/notificationwidget.cpp  
 M  +3 -1      ui/notificationwidget.h  
 M  +6 -0      ui/notifytextitem.cpp  
 M  +1 -0      ui/notifytextitem.h  


--- trunk/playground/base/plasma/applets/systray-refactor/TODO #867957:867958
@@ -1,6 +1,4 @@
 * Detached notifications don't close.
-  - Leave open but remove all action buttons
-  - Remove "close" button immediately upon detaching
   - Also re-add support for saving/restoring detached notifications
 
 * Style fixes
--- trunk/playground/base/plasma/applets/systray-refactor/ui/notificationwidget.cpp \
#867957:867958 @@ -27,6 +27,7 @@
 #include <QStyleOptionGraphicsItem>
 #include <QGraphicsSceneResizeEvent>
 #include <KGlobalSettings>
+#include <Plasma/Extender>
 #include <Plasma/ExtenderItem>
 
 #include <plasma/theme.h>
@@ -52,21 +53,22 @@
 public:
     Private()
         : notification(0),
-          textWidget(0)
+          textWidget(0),
+          destroyOnClose(true)
     {
     }
 
     KIcon applicationIcon;
     SystemTray::Notification *notification;
     NotifyTextItem *textWidget;
+    bool destroyOnClose;
 };
 
 
-NotificationWidget::NotificationWidget(SystemTray::Notification *notification, \
QGraphicsItem *parent) \
+NotificationWidget::NotificationWidget(SystemTray::Notification *notification, \
Plasma::ExtenderItem *parent)  : QGraphicsWidget(parent),
       d(new Private())
 {
-    kDebug() << "created widget!";
     setMinimumSize(QSizeF(275, desiredMinimumHeight()));
 
     d->notification = notification;
@@ -78,6 +80,8 @@
             this, SLOT(destroy()));
     connect(d->textWidget, SIGNAL(actionInvoked(const QString&)),
             this, SLOT(checkAction(const QString&)));
+    connect(parent->extender(), SIGNAL(itemDetached(Plasma::ExtenderItem*)),
+            this, SLOT(removeCloseActionIfSelf(Plasma::ExtenderItem*)));
 
     updateNotification();
 }
@@ -94,7 +98,7 @@
     d->applicationIcon = KIcon(d->notification->applicationIcon());
 
     d->textWidget->setBody(d->notification->message());
-    if (!d->notification->actions().isEmpty()) {
+    if (!d->notification->actions().isEmpty() || !d->destroyOnClose) {
         d->textWidget->setActions(d->notification->actions(), \
d->notification->actionOrder());  } else {
         QHash<QString, QString> actions;
@@ -142,9 +146,13 @@
 {
     Plasma::ExtenderItem *extenderItem = dynamic_cast<Plasma::ExtenderItem \
*>(parentItem());  
-    if (extenderItem) {
+    if (d->destroyOnClose && extenderItem) {
         extenderItem->destroy();
+    } else {
+        d->textWidget->clearActions();
     }
+
+    d->notification = 0;
 }
 
 
@@ -158,4 +166,15 @@
 }
 
 
+void NotificationWidget::removeCloseActionIfSelf(Plasma::ExtenderItem *extenderItem)
+{
+    if (extenderItem != parentWidget()) {
+        return;
+    }
+
+    d->destroyOnClose = false;
+    updateNotification();
+}
+
+
 #include "notificationwidget.moc"
--- trunk/playground/base/plasma/applets/systray-refactor/ui/notificationwidget.h \
#867957:867958 @@ -34,6 +34,7 @@
     class Svg;
     class Icon;
     class PanelSvg;
+    class ExtenderItem;
 } // namespace Plasma
 
 class QToolButton;
@@ -50,7 +51,7 @@
 public:
     static int desiredMinimumHeight();
 
-    NotificationWidget(SystemTray::Notification *notification, QGraphicsItem \
*parent); +    NotificationWidget(SystemTray::Notification *notification, \
Plasma::ExtenderItem *parent);  ~NotificationWidget();
 
     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget \
*widget = 0); @@ -59,6 +60,7 @@
     void updateNotification();
     void destroy();
     void checkAction(const QString &actionId);
+    void removeCloseActionIfSelf(Plasma::ExtenderItem *extenderItem);
 
 private:
     void resizeEvent(QGraphicsSceneResizeEvent *event);
--- trunk/playground/base/plasma/applets/systray-refactor/ui/notifytextitem.cpp \
#867957:867958 @@ -188,6 +188,12 @@
 }
 
 
+void NotifyTextItem::clearActions()
+{
+    setActions(QHash<QString, QString>(), QStringList());
+}
+
+
 void NotifyTextItem::updateActionRects()
 {
     QFont smallFont = KGlobalSettings::smallestReadableFont();
--- trunk/playground/base/plasma/applets/systray-refactor/ui/notifytextitem.h \
#867957:867958 @@ -43,6 +43,7 @@
     void setSize(qreal width, qreal height);
     void setBody(const QString &body);
     void setActions(const QHash<QString, QString> &actions, const QStringList \
&actionOrder); +    void clearActions();
 
 signals:
     void actionInvoked(const QString &action);


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

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