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

libplasma

applet.h

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2006-2007 by Aaron Seigo <aseigo@kde.org>
00003  *   Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
00004  *
00005  *   This program is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU Library General Public License as
00007  *   published by the Free Software Foundation; either version 2, or
00008  *   (at your option) any later version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details
00014  *
00015  *   You should have received a copy of the GNU Library General Public
00016  *   License along with this program; if not, write to the
00017  *   Free Software Foundation, Inc.,
00018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  */
00020 
00021 #ifndef PLASMA_APPLET_H
00022 #define PLASMA_APPLET_H
00023 
00024 #include <QtGui/QGraphicsItem>
00025 #include <QtGui/QWidget>
00026 
00027 #include <kplugininfo.h>
00028 #include <ksharedconfig.h>
00029 #include <kgenericfactory.h>
00030 
00031 #include <plasma/configxml.h>
00032 #include <plasma/plasma.h>
00033 #include <plasma/widgets/widget.h>
00034 
00035 namespace Plasma
00036 {
00037 
00038 class Containment;
00039 class DataEngine;
00040 class Package;
00041 
00058 class PLASMA_EXPORT Applet : public Widget
00059 {
00060     Q_OBJECT
00061 //    Q_PROPERTY( QRectF maxSizeHint READ maxSizeHint )
00062     Q_PROPERTY( bool hasConfigurationInterface READ hasConfigurationInterface WRITE setHasConfigurationInterface )
00063     Q_PROPERTY( QString name READ name )
00064     Q_PROPERTY( QString category READ category )
00065     Q_PROPERTY( bool immutable READ isImmutable WRITE setImmutable )
00066     Q_PROPERTY( bool drawStandardBackground READ drawStandardBackground WRITE setDrawStandardBackground )
00067     Q_PROPERTY( bool failedToLaunch READ failedToLaunch WRITE setFailedToLaunch )
00068     Q_PROPERTY( bool needsConfiguring READ needsConfiguring WRITE setNeedsConfiguring )
00069     Q_PROPERTY( QRectF boundingRect READ boundingRect )
00070     Q_PROPERTY( QRectF geometry READ geometry WRITE setGeometry )
00071     Q_PROPERTY( bool shouldConserveResources READ shouldConserveResources )
00072 
00073     public:
00074         typedef QList<Applet*> List;
00075         typedef QHash<QString, Applet*> Dict;
00076 
00084         explicit Applet(QGraphicsItem* parent = 0,
00085                         const QString& serviceId = QString(),
00086                         uint appletId = 0);
00087 
00098         Applet(QObject* parent, const QVariantList& args);
00099 
00100         ~Applet();
00101 
00108         virtual void init();
00109 
00113         uint id() const;
00114 
00122         KConfigGroup config() const;
00123 
00131         KConfigGroup config(const QString &group) const;
00132 
00136         void save(KConfigGroup* group) const;
00137 
00145         KConfigGroup globalConfig() const;
00146 
00153         ConfigXml* configXml() const;
00154 
00172         Q_INVOKABLE DataEngine* dataEngine(const QString& name) const;
00173 
00180         const Package* package() const;
00181 
00189         void updateConstraints(Plasma::Constraints constraints = Plasma::AllConstraints);
00190 
00203         virtual void constraintsUpdated(Plasma::Constraints constraints);
00204 
00210         virtual FormFactor formFactor() const;
00211 
00217         virtual Location location() const;
00218 
00222         QRectF contentRect() const;
00223 
00227         QSizeF contentSize() const;
00228 
00238         void setContentSize(const QSizeF &size);
00239 
00250         void setContentSize(int width, int height);
00251 
00263         virtual QSizeF contentSizeHint() const;
00264 
00268         void setMinimumContentSize(const QSizeF &minSize);
00269 
00276         void setMinimumContentSize(int minWidth, int minHeight);
00277 
00281         QSizeF minimumContentSize() const;
00282 
00286         void setMaximumContentSize(const QSizeF &maxSize);
00287 
00294         void setMaximumContentSize(int maxWidth, int maxHeight);
00295 
00299         QSizeF maximumContentSize() const;
00300 
00317         static KPluginInfo::List knownApplets(const QString &category = QString(),
00318                                               const QString &parentApp = QString());
00319 
00325         static KPluginInfo::List knownAppletsForMimetype(const QString &mimetype);
00326 
00339         static QStringList knownCategories(const QString &parentApp = QString(), bool visibleOnly = true);
00340 
00344         bool hasConfigurationInterface();
00345 
00359         static Applet* loadApplet(const QString &name, uint appletId = 0,
00360                                   const QVariantList& args = QVariantList());
00361 
00374         static Applet* loadApplet(const KPluginInfo& info, uint appletId = 0,
00375                                   const QVariantList& args = QVariantList());
00376 
00385         virtual void paintInterface(QPainter *painter,
00386                                     const QStyleOptionGraphicsItem *option,
00387                                     const QRect& contentsRect);
00388 
00395         QString name() const;
00396 
00400         QString pluginName() const;
00401 
00408         bool shouldConserveResources() const;
00409 
00413         QString icon() const;
00414 
00419         QString category() const;
00420 
00424         QColor color() const;
00425 
00431         static QString category(const KPluginInfo& applet);
00432 
00438         static QString category(const QString& appletName);
00439 
00443         bool isImmutable() const;
00444 
00448         bool isKioskImmutable() const;
00449 
00454         bool drawStandardBackground();
00455 
00462         void setDrawStandardBackground(bool drawBackground);
00463 
00469         bool failedToLaunch() const;
00470 
00483         void setFailedToLaunch(bool failed, const QString& reason = QString());
00484 
00489         bool needsConfiguring() const;
00490 
00503         void setNeedsConfiguring(bool needsConfiguring);
00504         enum { Type = Plasma::AppletType };
00505 
00509         int type() const;
00510 
00514         QRectF boundingRect () const;
00515 
00525         virtual QList<QAction*> contextActions();
00526 
00530         void setShadowShown(bool);
00534         bool isShadowShown() const;
00535 
00536         // reimplemented from LayoutItem
00537         // value is the same as contentSizeHint() if drawStandardBackground() is false
00538         // or contentSizeHint() plus the size of the border otherwise.
00539         virtual QSizeF sizeHint() const;
00540 
00545         void setGeometry(const QRectF &geometry);
00546 
00550         void setIsContainment(bool isContainment);
00551 
00555         bool isContainment() const;
00556 
00560         void resetConfigurationObject();
00561 
00562     Q_SIGNALS:
00576         void requestFocus( bool focus );
00577 
00582         void geometryChanged();
00583 
00592         void configNeedsSaving();
00593 
00594     public Q_SLOTS:
00600         void setImmutable(bool immutable);
00601 
00605         void destroy();
00606 
00614         virtual void showConfigurationInterface();
00615 
00620         void flushUpdatedConstraints();
00621 
00625         Containment* containment() const;
00626 
00627     protected:
00632         virtual void saveState(KConfigGroup* config) const;
00633 
00639         QString globalName() const;
00640 
00647         QString instanceName() const;
00648 
00657         void watchForFocus( QObject *widget, bool watch = true );
00658 
00668         void needsFocus(bool focus);
00669 
00679         void setHasConfigurationInterface(bool hasInterface);
00680 
00684         bool eventFilter( QObject *o, QEvent *e );
00685 
00689         QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00690 
00691     protected Q_SLOTS:
00695         void performSetupConfig();
00696 
00700         void checkImmutability();
00701 
00702     private:
00703         Q_DISABLE_COPY(Applet)
00704 
00705         
00708         void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
00709 
00710         class Private;
00711         Private* const d;
00712 };
00713 
00714 } // Plasma namespace
00715 
00719 #define K_EXPORT_PLASMA_APPLET(libname, classname) \
00720 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00721 K_EXPORT_PLUGIN(factory("plasma_applet_" #libname))
00722 
00723 #endif // multiple inclusion guard

libplasma

Skip menu "libplasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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