not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / systemtray / ui / extendertask.cpp
blobdac1438aa0082434f1026931d3cf98be7bd6ccbc
1 /***************************************************************************
2 * Copyright (C) 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
20 #include "extendertask.h"
21 #include <fixx11h.h>
23 #include <QtGui/QWidget> // QWIDGETSIZE_MAX
25 #include <plasma/popupapplet.h>
26 #include <plasma/widgets/iconwidget.h>
29 namespace SystemTray
32 class ExtenderTask::Private
34 public:
35 Private(Plasma::PopupApplet *systemTray, Task *q)
36 : q(q),
37 iconWidget(0),
38 systemTray(systemTray)
42 Task *q;
43 QString typeId;
44 QString iconName;
45 QIcon icon;
46 Plasma::IconWidget *iconWidget;
47 Plasma::PopupApplet *systemTray;
51 ExtenderTask::ExtenderTask(Plasma::PopupApplet *systemTray)
52 : d(new Private(systemTray, this))
54 setOrder(Last);
58 ExtenderTask::~ExtenderTask()
60 emit taskDeleted(d->typeId);
61 delete d;
65 bool ExtenderTask::isEmbeddable() const
67 return true;
70 bool ExtenderTask::isValid() const
72 return true;
75 bool ExtenderTask::isHideable() const
77 return false;
80 QString ExtenderTask::name() const
82 return i18n("Show or hide notifications and jobs");
86 QString ExtenderTask::typeId() const
88 //FIXME: what should we return here?
89 return "toggle_extender";
93 QIcon ExtenderTask::icon() const
95 return d->icon;
98 void ExtenderTask::setIcon(const QString &icon)
100 d->iconName = icon;
101 if (d->iconWidget) {
102 d->iconWidget->setIcon(icon);
106 QGraphicsWidget* ExtenderTask::createWidget(Plasma::Applet *host)
108 d->iconWidget = new Plasma::IconWidget(host);
109 d->iconWidget->setToolTip(i18n("Toggle visibility of notifications and jobs"));
110 d->iconWidget->setIcon(d->iconName);
111 d->iconWidget->setMinimumSize(22, 22);
112 d->iconWidget->setMaximumSize(26, QWIDGETSIZE_MAX);
113 connect(d->iconWidget, SIGNAL(clicked()), d->systemTray, SLOT(togglePopup()));
114 return d->iconWidget;
120 #include "extendertask.moc"