Applets
plasmoidtask.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "plasmoidtask.h"
00024 #include <fixx11h.h>
00025
00026 #include <plasma/applet.h>
00027
00028
00029 namespace SystemTray
00030 {
00031
00032 class PlasmoidTask::Private
00033 {
00034 public:
00035 Private(QString name, PlasmoidTask *q)
00036 : q(q),
00037 name(name),
00038 typeId(name),
00039 applet(0)
00040 {
00041 if (!name.isEmpty()) {
00042 setupApplet();
00043 }
00044 }
00045
00046 void setupApplet();
00047
00048 PlasmoidTask *q;
00049 QString name;
00050 QString typeId;
00051 QIcon icon;
00052 Plasma::Applet *applet;
00053 };
00054
00055
00056 PlasmoidTask::PlasmoidTask(QString appletname)
00057 : d(new Private(appletname, this))
00058 {
00059 }
00060
00061
00062 PlasmoidTask::~PlasmoidTask()
00063 {
00064 emit taskDeleted(d->typeId);
00065 delete d;
00066 }
00067
00068
00069 bool PlasmoidTask::isEmbeddable() const
00070 {
00071 return d->applet != 0;
00072 }
00073
00074 bool PlasmoidTask::isValid() const
00075 {
00076 return !d->name.isEmpty();
00077 }
00078
00079 QString PlasmoidTask::name() const
00080 {
00081 return d->name;
00082 }
00083
00084
00085 QString PlasmoidTask::typeId() const
00086 {
00087 return d->typeId;
00088 }
00089
00090
00091 QIcon PlasmoidTask::icon() const
00092 {
00093 return d->icon;
00094 }
00095
00096
00097 QGraphicsWidget* PlasmoidTask::createWidget(Plasma::Applet *host)
00098 {
00099 Q_UNUSED(host)
00100 return static_cast<QGraphicsWidget*>(d->applet);
00101 }
00102
00103
00104 void PlasmoidTask::Private::setupApplet()
00105 {
00106 applet = Plasma::Applet::load(name);
00107
00108 if (!applet) {
00109 kDebug() << "Could not load applet" << name;
00110 name = QString();
00111 return;
00112 }
00113
00114 applet->setParent(q);
00115 applet->setFlag(QGraphicsItem::ItemIsMovable, false);
00116
00117
00118 applet->init();
00119 applet->setBackgroundHints(Plasma::Applet::NoBackground);
00120
00121
00122
00123 applet->setMinimumSize(22, 22);
00124 kDebug() << applet->name() << " Applet loaded";
00125 }
00126
00127 }
00128
00129 #include "plasmoidtask.moc"