1 /***************************************************************************
4 * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
20 ***************************************************************************/
22 #ifndef SYSTEMTRAYTASK_H
23 #define SYSTEMTRAYTASK_H
25 #include <QtCore/QObject>
27 #include <QtGui/QIcon>
29 class QGraphicsWidget
;
40 * @short System tray task base class
42 * To support a new system tray protocol, Protocol and this class should
45 class Task
: public QObject
50 enum Order
{ First
, Normal
, Last
};
55 * Creates a new graphics widget for this task
57 * isEmbeddable() should be checked before creating a new widget.
59 QGraphicsWidget
* widget(Plasma::Applet
*host
);
62 * Returns the current list of graphics widgets that have been created
63 * for this task and have not yet been deleted
65 QList
<QGraphicsWidget
*> associatedWidgets() const;
68 * Returns whether this task can be embeddable
70 * Depending on the protocol, there may be circumstances under which
71 * a new widget can not be created. isEmbeddable() will return false
72 * under these circumstances.
74 virtual bool isEmbeddable() const = 0;
77 * Returns the name of this task that should be presented to the user
79 virtual QString
name() const = 0;
82 * Returns a unique identifier for this task
84 * The identifier is valid between restarts and so is safe to save
86 virtual QString
typeId() const = 0;
89 * Returns an icon that can be associated with this task
91 * The icon returned is not necessarily the same icon that appears
92 * in the tray icon itself.
94 virtual QIcon
icon() const = 0;
97 * Returns whether the task is currently hideable by the user or not
99 virtual bool isHideable() const;
102 * Returns the order this Task should be placed in: first, normal or last
107 * Sets which order this task should be placed in, relative to other Tasks
109 * @arg order the order to set this Task to
111 void setOrder(Order order
);
115 * Emitted when something about the task has changed
117 void changed(SystemTray::Task
*task
= 0);
120 * Emitted when the task is about to be destroyed
122 void destroyed(SystemTray::Task
*task
= 0);
128 * Called when a new widget is required
130 * Subclasses should implement this to return a graphics widget that
131 * handles all user interaction with the task. Ownership of the
132 * created widget is handled automatically so subclasses should not
133 * delete the created widget.
135 virtual QGraphicsWidget
* createWidget(Plasma::Applet
*host
) = 0;
138 void widgetDeleted();