On Saturday 04 October 2008, Jason Stubbs wrote:
> Aaron J. Seigo wrote:
> > On Friday 03 October 2008, Rob Scheepmaker wrote:
> >> On Thursday 02 October 2008 22:08:41 Aaron J. Seigo wrote:
> >>> systray-refactor - needs the plasmoid protocol finished out, but
> >>> generally there. (notifications?)
> >>>   kuiserver - should be added to the systemtray?
> >>
> >> Or maybe just keep as a seperate plasmoid which can of course be used
> >> through the systray's plasmoid protocal.
>
> This would mean that kuiserver's extender would be different to
> systray's thus negating the purpose of integrating the two.
>
> >> Because as opposed to the
> >> notifications applet, the kuiserver applet really needs an icon to
> >> open/close the popup. Transfers often take a while, and you don't want
> >> to have the popup open all the time while a transfer of multiple hours
> >> is running, while you do want to open it sometimes to take a look at how
> >> for the transfer is.
>
> I hadn't considered this.
>
> > the KUIServer protocol in systray-refactor could create the icon, which
> > the systray would then add
>
> This is definitely a possibility, but I'm not sure it's really possible
> to accomplish by October 19th. Assuming that the icon would show/hide
> the extender, there are issues such as the interaction between the
> kuiserver hide/show and knotify notifications, or how an icon adding
> through the Task protocol can even get access to the extender.

the attached patch addresses this issue. (along with a couple of other minor 
items, like removing the direct use of the Manager from the TaskArea class)

i also realized while writing the patch that the plasmoid protocol has a fatal 
flaw: it creates one widget per task, but the tasks are global (shared between 
all instances of the tray). part of the solution here is to actually implement 
configuration management which we can do more easily once we have access to the 
applet object in question, which this patch brings us one step closer to.

(it also doesn't allow more than one of the same applet, but that's another 
matter =)

i think we will need to pass in a KConfigGroup to Protocol::init, and not 
create the protocols when the manager is created but have an init on the 
Manager class as well.

most of the awkwardness in systray-refactor comes from parts of it being 
written as if it were a 3rd party library to be re-used elsewhere when that 
really isn't the case. a bit more coupling in the right places between the 
core/ and ui/ classes will make things a lot easier.

which is all to say that the barrier to adding something like the KUIServer 
stuff to this is absolutely solvable, is completely orthogonal to any other 
stabilization work that would be left to do and that i'm willing to put the 
work in to make it happen over the next 5 weeks.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Software

Index: protocols/fdo/fdotask.h
===================================================================
--- protocols/fdo/fdotask.h	(revision 869638)
+++ protocols/fdo/fdotask.h	(working copy)
@@ -47,7 +47,7 @@
     void taskDeleted(WId winId);
 
 protected:
-    virtual QGraphicsWidget* createWidget();
+    virtual QGraphicsWidget* createWidget(Plasma::Applet *applet);
 
 private:
     class Private;
Index: protocols/fdo/fdotask.cpp
===================================================================
--- protocols/fdo/fdotask.cpp	(revision 869638)
+++ protocols/fdo/fdotask.cpp	(working copy)
@@ -94,8 +94,10 @@
 }
 
 
-QGraphicsWidget* Task::createWidget()
+QGraphicsWidget* Task::createWidget(Plasma::Applet *applet)
 {
+    Q_UNUSED(applet)
+
     QGraphicsWidget *widget = new GraphicsWidget(d->winId);
     connect(widget, SIGNAL(clientClosed()),
             this, SLOT(deleteLater()));
Index: protocols/plasmoid/plasmoidtask.h
===================================================================
--- protocols/plasmoid/plasmoidtask.h	(revision 869638)
+++ protocols/plasmoid/plasmoidtask.h	(working copy)
@@ -39,6 +39,7 @@
     Task(QString appletName);
     virtual ~Task();
 
+    bool isValid() const;
     virtual bool isEmbeddable() const;
     virtual QString name() const;
     virtual QString typeId() const;
@@ -48,7 +49,7 @@
     void taskDeleted(QString typeId);
 
 protected:
-    virtual QGraphicsWidget* createWidget();
+    virtual QGraphicsWidget* createWidget(Plasma::Applet *applet);
 
 private:
     class Private;
Index: protocols/plasmoid/plasmoidtask.cpp
===================================================================
--- protocols/plasmoid/plasmoidtask.cpp	(revision 869638)
+++ protocols/plasmoid/plasmoidtask.cpp	(working copy)
@@ -74,6 +74,10 @@
     return d->applet != 0;
 }
 
+bool Task::isValid() const
+{
+    return !d->name.isEmpty();
+}
 
 QString Task::name() const
 {
@@ -93,8 +97,9 @@
 }
 
 
-QGraphicsWidget* Task::createWidget()
+QGraphicsWidget* Task::createWidget(Plasma::Applet *host)
 {
+    Q_UNUSED(host)
     return static_cast<QGraphicsWidget*>(d->applet);
 }
 
@@ -105,6 +110,7 @@
 
     if (!applet) {
         kDebug() << "Could not load applet" << name;
+        name = QString();
         return;
     }
 
Index: protocols/plasmoid/plasmoidtaskprotocol.cpp
===================================================================
--- protocols/plasmoid/plasmoidtaskprotocol.cpp	(revision 869638)
+++ protocols/plasmoid/plasmoidtaskprotocol.cpp	(working copy)
@@ -74,7 +74,7 @@
     kDebug() << "Registering task with the manager" << appletName;
     Task *task = new Task(appletName);
 
-    if (!task->widget()) {
+    if (!task->isValid()) {
         // we failed to load our applet *sob*
         delete task;
         return;
Index: core/manager.h
===================================================================
--- core/manager.h	(revision 869638)
+++ core/manager.h	(working copy)
@@ -28,12 +28,7 @@
 {
     class Notification;
     class Task;
-}
 
-
-namespace SystemTray
-{
-
 /**
  * @short Creator and amalgamator of the supported system tray specifications
  **/
@@ -45,19 +40,19 @@
     class Singleton;
 
     /**
-     * Returns the global Manager instance
+     * @return the global Manager instance
      **/
     static Manager* self();
 
     /**
-     * Returns a list of all known Task instances
+     * @return a list of all known Task instances
      **/
-    QList<Task*> tasks();
+    QList<Task*> tasks() const;
 
     /**
-     * Returns a list of all known Task instances
+     * @return a list of all known Task instances
      **/
-    QList<Notification*> notifications();
+    QList<Notification*> notifications() const;
 
 signals:
     /**
Index: core/task.cpp
===================================================================
--- core/task.cpp	(revision 869638)
+++ core/task.cpp	(working copy)
@@ -48,10 +48,12 @@
 }
 
 
-QGraphicsWidget* Task::widget()
+QGraphicsWidget* Task::widget(Plasma::Applet *host)
 {
+    Q_ASSERT(host);
+
     QGraphicsWidget *widget;
-    widget = createWidget();
+    widget = createWidget(host);
     d->associatedWidgets.append(widget);
     connect(widget, SIGNAL(destroyed()), this, SLOT(widgetDeleted()));
     connect(this, SIGNAL(destroyed()), widget, SLOT(deleteLater()));
Index: core/task.h
===================================================================
--- core/task.h	(revision 869638)
+++ core/task.h	(working copy)
@@ -28,6 +28,10 @@
 
 class QGraphicsWidget;
 
+namespace Plasma
+{
+    class Applet;
+} // namespace Plasma
 
 namespace SystemTray
 {
@@ -50,7 +54,7 @@
      *
      * isEmbeddable() should be checked before creating a new widget.
      **/
-    QGraphicsWidget* widget();
+    QGraphicsWidget* widget(Plasma::Applet *host);
 
     /**
      * Returns the current list of graphics widgets that have been created
@@ -109,7 +113,7 @@
      * created widget is handled automatically so subclasses should not
      * delete the created widget.
      **/
-    virtual QGraphicsWidget* createWidget() = 0;
+    virtual QGraphicsWidget* createWidget(Plasma::Applet *host) = 0;
 
 private slots:
     void widgetDeleted();
Index: core/manager.cpp
===================================================================
--- core/manager.cpp	(revision 869638)
+++ core/manager.cpp	(working copy)
@@ -23,6 +23,8 @@
 
 #include <KGlobal>
 
+#include <plasma/applet.h>
+
 #include "notification.h"
 #include "notificationprotocol.h"
 #include "task.h"
@@ -33,7 +35,6 @@
 #include "../protocols/fdo/fdotaskprotocol.h"
 #include "../protocols/plasmoid/plasmoidtaskprotocol.h"
 
-
 namespace SystemTray
 {
 
@@ -50,8 +51,8 @@
 class Manager::Private
 {
 public:
-    Private(Manager *q)
-        : q(q)
+    Private(Manager *manager)
+        : q(manager)
     {
         registerTaskProtocol(new Plasmoid::TaskProtocol(q));
         registerTaskProtocol(new FDO::TaskProtocol(q));
@@ -73,20 +74,18 @@
     return &singleton->instance;
 }
 
-
 Manager::Manager()
     : d(new Private(this))
 {
 }
 
-
 Manager::~Manager()
 {
     delete d;
 }
 
 
-QList<Task*> Manager::tasks()
+QList<Task*> Manager::tasks() const
 {
     return d->tasks;
 }
@@ -147,6 +146,10 @@
     emit notificationRemoved(notification);
 }
 
+QList<Notification*> Manager::notifications() const
+{
+    return d->notifications;
+}
 
 }
 
Index: ui/taskarea.h
===================================================================
--- ui/taskarea.h	(revision 869638)
+++ ui/taskarea.h	(working copy)
@@ -24,26 +24,27 @@
 
 #include <QGraphicsWidget>
 
-namespace SystemTray
+namespace Plasma
 {
-    class Task;
-}
+    class Applet;
+} // namespace Plasma
 
-
 namespace SystemTray
 {
 
+class Task;
+
 class TaskArea : public QGraphicsWidget
 {
     Q_OBJECT
 
 public:
-    TaskArea(QGraphicsItem *parent = 0);
+    TaskArea(Plasma::Applet *parent);
     ~TaskArea();
 
     void setHiddenTypes(const QStringList &hiddenTypes);
     bool isHiddenType(const QString &typeId) const;
-    void syncTasks();
+    void syncTasks(const QList<SystemTray::Task*> &tasks);
 
 public slots:
     void addTask(SystemTray::Task *task);
Index: ui/applet.cpp
===================================================================
--- ui/applet.cpp	(revision 869638)
+++ ui/applet.cpp	(working copy)
@@ -91,6 +91,12 @@
 
     d->taskArea = new TaskArea(this);
     d->setTaskAreaGeometry();
+    connect(Manager::self(), SIGNAL(taskAdded(SystemTray::Task*)),
+            d->taskArea, SLOT(addTask(SystemTray::Task*)));
+    connect(Manager::self(), SIGNAL(taskChanged(SystemTray::Task*)),
+            d->taskArea, SLOT(addTask(SystemTray::Task*)));
+    connect(Manager::self(), SIGNAL(taskRemoved(SystemTray::Task*)),
+            d->taskArea, SLOT(removeTask(SystemTray::Task*)));
 
     d->taskArea->setHiddenTypes(hiddenTypes);
     connect(d->taskArea, SIGNAL(sizeHintChanged(Qt::SizeHint)),
@@ -100,7 +106,7 @@
             this, SLOT(checkSizes()));
     checkSizes();
 
-    d->taskArea->syncTasks();
+    d->taskArea->syncTasks(Manager::self()->tasks());
 
     extender()->setEmptyExtenderMessage(i18n("No notifications..."));
     connect(SystemTray::Manager::self(), SIGNAL(notificationAdded(SystemTray::Notification*)),
@@ -274,7 +280,7 @@
     }
 
     d->taskArea->setHiddenTypes(hiddenTypes);
-    d->taskArea->syncTasks();
+    d->taskArea->syncTasks(Manager::self()->tasks());
 
     KConfigGroup cg = config();
     cg.writeEntry("hidden", hiddenTypes);
Index: ui/taskarea.cpp
===================================================================
--- ui/taskarea.cpp	(revision 869638)
+++ ui/taskarea.cpp	(working copy)
@@ -19,13 +19,14 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
  ***************************************************************************/
 
-#include "compactlayout.h"
 #include "taskarea.h"
 
 #include <QtCore/QSet>
 
-#include "../core/manager.h"
+#include <plasma/applet.h>
+
 #include "../core/task.h"
+#include "compactlayout.h"
 
 
 namespace SystemTray
@@ -35,30 +36,25 @@
 class TaskArea::Private
 {
 public:
-    Private()
-        : layout(new CompactLayout())
+    Private(Plasma::Applet *h)
+        : host(h),
+          layout(new CompactLayout())
     {
     }
 
     QGraphicsWidget* findWidget(Task *task);
 
+    Plasma::Applet *host;
     CompactLayout *layout;
     QSet<QString> hiddenTypes;
 };
 
 
-TaskArea::TaskArea(QGraphicsItem *parent)
+TaskArea::TaskArea(Plasma::Applet *parent)
     : QGraphicsWidget(parent),
-      d(new Private())
+      d(new Private(parent))
 {
     setLayout(d->layout);
-
-    connect(Manager::self(), SIGNAL(taskAdded(SystemTray::Task*)),
-            this, SLOT(addTask(SystemTray::Task*)));
-    connect(Manager::self(), SIGNAL(taskChanged(SystemTray::Task*)),
-            this, SLOT(addTask(SystemTray::Task*)));
-    connect(Manager::self(), SIGNAL(taskRemoved(SystemTray::Task*)),
-            this, SLOT(removeTask(SystemTray::Task*)));
 }
 
 
@@ -80,9 +76,9 @@
 }
 
 
-void TaskArea::syncTasks()
+void TaskArea::syncTasks(const QList<SystemTray::Task*> &tasks)
 {
-    foreach (Task *task, Manager::self()->tasks()) {
+    foreach (Task *task, tasks) {
         if (isHiddenType(task->typeId())) {
             QGraphicsWidget *widget = d->findWidget(task);
             if (widget) {
@@ -99,7 +95,7 @@
 void TaskArea::addTask(Task *task)
 {
     if (task->isEmbeddable() && !isHiddenType(task->typeId()) && !d->findWidget(task)) {
-        d->layout->addItem(task->widget());
+        d->layout->addItem(task->widget(d->host));
         emit sizeHintChanged(Qt::PreferredSize);
     }
 }

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to