• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Applets

plasmoidtask.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   plasmoidtask.cpp                                                      *
00003  *                                                                         *
00004  *   Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com>              *
00005  *   Copyright (C) 2008 Sebastian Kügler <sebas@kde.org>                   *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
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     //connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed(QObject*)));
00118     applet->init();
00119     applet->setBackgroundHints(Plasma::Applet::NoBackground);
00120 
00121     // TODO: We'll need the preferred item size here
00122     // The applet does need a size, otherwise it won't show up correctly.
00123     applet->setMinimumSize(22, 22);
00124     kDebug() << applet->name() << " Applet loaded";
00125 }
00126 
00127 }
00128 
00129 #include "plasmoidtask.moc"

Applets

Skip menu "Applets"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal