1 /***************************************************************************
4 * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> *
5 * Copyright (C) 2008 Sebastian Kügler <sebas@kde.org> *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
21 ***************************************************************************/
23 #include "plasmoidtask.h"
26 #include <plasma/applet.h>
32 class PlasmoidTask::Private
35 Private(QString name
, PlasmoidTask
*q
)
41 if (!name
.isEmpty()) {
52 Plasma::Applet
*applet
;
56 PlasmoidTask::PlasmoidTask(QString appletname
)
57 : d(new Private(appletname
, this))
62 PlasmoidTask::~PlasmoidTask()
64 emit
taskDeleted(d
->typeId
);
69 bool PlasmoidTask::isEmbeddable() const
71 return d
->applet
!= 0;
74 bool PlasmoidTask::isValid() const
76 return !d
->name
.isEmpty();
79 QString
PlasmoidTask::name() const
85 QString
PlasmoidTask::typeId() const
91 QIcon
PlasmoidTask::icon() const
97 QGraphicsWidget
* PlasmoidTask::createWidget(Plasma::Applet
*host
)
100 return static_cast<QGraphicsWidget
*>(d
->applet
);
104 void PlasmoidTask::Private::setupApplet()
106 applet
= Plasma::Applet::load(name
);
109 kDebug() << "Could not load applet" << name
;
114 applet
->setParent(q
);
115 applet
->setFlag(QGraphicsItem::ItemIsMovable
, false);
117 //connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed(QObject*)));
119 applet
->setBackgroundHints(Plasma::Applet::NoBackground
);
121 // TODO: We'll need the preferred item size here
122 // The applet does need a size, otherwise it won't show up correctly.
123 applet
->setMinimumSize(22, 22);
124 kDebug() << applet
->name() << " Applet loaded";
129 #include "plasmoidtask.moc"