• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • plasma
applet.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2007 by Aaron Seigo <aseigo@kde.org>
3  * Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
4  * Copyright 2008 by Ménard Alexis <darktears31@gmail.com>
5 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Library General Public License as
8  * published by the Free Software Foundation; either version 2, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef PLASMA_APPLET_H
23 #define PLASMA_APPLET_H
24 
25 #include <QtGui/QGraphicsItem>
26 #include <QtGui/QGraphicsWidget>
27 #include <QtGui/QIcon>
28 
29 #include <kconfiggroup.h>
30 #include <kgenericfactory.h>
31 #include <kplugininfo.h>
32 #include <kshortcut.h>
33 
34 #include <plasma/configloader.h>
35 #include <plasma/packagestructure.h>
36 #include <plasma/plasma.h>
37 #include <plasma/animator.h>
38 #include <plasma/version.h>
39 #include <plasma/framesvg.h>
40 
41 class QWidget;
42 
43 class KConfigDialog;
44 class QGraphicsView;
45 class KActionCollection;
46 
47 namespace Plasma
48 {
49 
50 class AppletPrivate;
51 class Containment;
52 class Context;
53 class DataEngine;
54 class Extender;
55 class ExtenderItem;
56 class Package;
57 
58 
77 class PLASMA_EXPORT Applet : public QGraphicsWidget
78 {
79  Q_OBJECT
80  Q_PROPERTY(bool hasConfigurationInterface READ hasConfigurationInterface)
81  Q_PROPERTY(QString name READ name CONSTANT)
82  Q_PROPERTY(QString pluginName READ pluginName CONSTANT)
83  Q_PROPERTY(QString category READ category CONSTANT)
84  Q_PROPERTY(ImmutabilityType immutability READ immutability WRITE setImmutability)
85  Q_PROPERTY(bool hasFailedToLaunch READ hasFailedToLaunch WRITE setFailedToLaunch)
86  Q_PROPERTY(bool isBusy READ isBusy WRITE setBusy) //KDE5: remove
87  Q_PROPERTY(bool busy READ isBusy WRITE setBusy)
88  Q_PROPERTY(bool configurationRequired READ configurationRequired WRITE setConfigurationRequired)
89  Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
90  Q_PROPERTY(bool shouldConserveResources READ shouldConserveResources)
91  Q_PROPERTY(uint id READ id CONSTANT)
92  Q_PROPERTY(bool userConfiguring READ isUserConfiguring)
93  Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints)
94  Q_ENUMS(BackgroundHints)
95 
96  public:
97  typedef QList<Applet*> List;
98  typedef QHash<QString, Applet*> Dict;
99 
103  enum BackgroundHint {
104  NoBackground = 0,
106  StandardBackground = 1,
107  TranslucentBackground = 2,
109  DefaultBackground = StandardBackground
111  };
112  Q_DECLARE_FLAGS(BackgroundHints, BackgroundHint)
113 
114  ~Applet();
115 
119  static PackageStructure::Ptr packageStructure();
120 
124  uint id() const;
125 
133  KConfigGroup config() const;
134 
142  KConfigGroup config(const QString &group) const;
143 
154  virtual void save(KConfigGroup &group) const;
155 
164  virtual void restore(KConfigGroup &group);
165 
173  KConfigGroup globalConfig() const;
174 
181  ConfigLoader *configScheme() const;
182 
200  Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
201 
208  const Package *package() const;
209 
216  QGraphicsView *view() const;
217 
223  QRectF mapFromView(const QGraphicsView *view, const QRect &rect) const;
224 
230  QRect mapToView(const QGraphicsView *view, const QRectF &rect) const;
231 
238  QPoint popupPosition(const QSize &s) const;
239 
248  QPoint popupPosition(const QSize &s, Qt::AlignmentFlag alignment) const;
249 
257  void updateConstraints(Plasma::Constraints constraints = Plasma::AllConstraints);
258 
264  virtual FormFactor formFactor() const;
265 
271  virtual Location location() const;
272 
276  Context *context() const;
277 
281  Plasma::AspectRatioMode aspectRatioMode() const;
282 
286  void setAspectRatioMode(Plasma::AspectRatioMode);
287 
305  static KPluginInfo::List listAppletInfo(const QString &category = QString(),
306  const QString &parentApp = QString());
307 
313  static KPluginInfo::List listAppletInfoForMimetype(const QString &mimetype);
314 
321  static KPluginInfo::List listAppletInfoForUrl(const QUrl &url);
322 
334  static QStringList listCategories(const QString &parentApp = QString(),
335  bool visibleOnly = true);
336 
343  void setCustomCategories(const QStringList &categories);
344 
349  QStringList customCategories();
350 
365  static Applet *loadPlasmoid(const QString &path, uint appletId = 0,
366  const QVariantList &args = QVariantList());
367 
381  static Applet *load(const QString &name, uint appletId = 0,
382  const QVariantList &args = QVariantList());
383 
397  static Applet *load(const KPluginInfo &info, uint appletId = 0,
398  const QVariantList &args = QVariantList());
399 
405  static QString category(const KPluginInfo &applet);
406 
412  static QString category(const QString &appletName);
413 
422  virtual void paintInterface(QPainter *painter,
423  const QStyleOptionGraphicsItem *option,
424  const QRect &contentsRect);
425 
432  QString name() const;
433 
437  QFont font() const;
438 
442  QString pluginName() const;
443 
450  bool shouldConserveResources() const;
451 
455  QString icon() const;
456 
461  QString category() const;
462 
466  ImmutabilityType immutability() const;
467 
468  void paintWindowFrame(QPainter *painter,
469  const QStyleOptionGraphicsItem *option, QWidget *widget);
470 
476  bool hasFailedToLaunch() const;
477 
481  bool isBusy() const;
482 
487  bool configurationRequired() const;
488 
492  bool hasConfigurationInterface() const;
493 
503  virtual QList<QAction*> contextualActions();
504 
508  Q_INVOKABLE QAction *action(QString name) const;
509 
513  void addAction(QString name, QAction *action);
514 
520  void setBackgroundHints(const BackgroundHints hints);
521 
526  BackgroundHints backgroundHints() const;
527 
531  bool isContainment() const;
532 
542  QRect screenRect() const;
543 
547  int type() const;
548  enum {
549  Type = Plasma::AppletType
550  };
551 
555  Containment *containment() const;
556 
560  void setGlobalShortcut(const KShortcut &shortcut);
561 
566  KShortcut globalShortcut() const;
567 
573  virtual bool isPopupShowing() const;
574 
579  virtual void addAssociatedWidget(QWidget *widget);
580 
585  virtual void removeAssociatedWidget(QWidget *widget);
586 
604  virtual void initExtenderItem(ExtenderItem *item);
605 
613  explicit Applet(QGraphicsItem *parent = 0,
614  const QString &serviceId = QString(),
615  uint appletId = 0);
616 
624  explicit Applet(const KPluginInfo &info, QGraphicsItem *parent = 0, uint appletId = 0);
625 
636  explicit Applet(QGraphicsItem *parent,
637  const QString &serviceId,
638  uint appletId,
639  const QVariantList &args);
640 
641 
646  bool destroyed() const;
647 
671  virtual void createConfigurationInterface(KConfigDialog *parent);
672 
678  bool hasAuthorization(const QString &constraint) const;
679 
691  void setAssociatedApplication(const QString &string);
692 
700  void setAssociatedApplicationUrls(const KUrl::List &urls);
701 
706  QString associatedApplication() const;
707 
712  KUrl::List associatedApplicationUrls() const;
713 
718  bool hasValidAssociatedApplication() const;
719 
720  Q_SIGNALS:
727  void releaseVisualFocus();
728 
729 #if QT_VERSION >= 0x040700
730  protected:
731  void geometryChanged(); // in QGraphicsWidget now; preserve BC
732 #else
733 
737  void geometryChanged();
738 #endif
739 
740  Q_SIGNALS:
744  void appletTransformedByUser();
745 
749  void appletTransformedItself();
750 
754  void sizeHintChanged(Qt::SizeHint which);
755 
764  void configNeedsSaving();
765 
770  void activate();
771 
779  void messageButtonPressed(const Plasma::MessageButton button);
780 
784  void appletDestroyed(Plasma::Applet *applet);
785 
790  void newStatus(Plasma::ItemStatus status);
791 
795  void extenderItemRestored(Plasma::ExtenderItem *item);
796 
801  void immutabilityChanged(Plasma::ImmutabilityType immutable);
802 
803  public Q_SLOTS:
809  void setImmutability(const ImmutabilityType immutable);
810 
815  virtual void destroy();
816 
830  virtual void showConfigurationInterface();
831 
840  void showConfigurationInterface(QWidget *widget);
841 
846  bool isUserConfiguring() const;
847 
851  void raise();
852 
856  void lower();
857 
862  void flushPendingConstraintsEvents();
863 
874  virtual void init();
875 
879  virtual void configChanged();
880 
885  void setBusy(bool busy);
886 
891  QVariantList startupArguments() const;
892 
897  ItemStatus status() const;
898 
903  void setStatus(const ItemStatus stat);
904 
911  void publish(Plasma::AnnouncementMethods methods, const QString &resourceName);
912 
913  void unpublish();
914 
915  bool isPublished() const;
916 
925  void runAssociatedApplication();
926 
927  protected:
938  Applet(QObject *parent, const QVariantList &args);
939 
952  void setFailedToLaunch(bool failed, const QString &reason = QString());
953 
963  virtual void saveState(KConfigGroup &config) const;
964 
974  void setHasConfigurationInterface(bool hasInterface);
975 
987  void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
988 
1003  void showMessage(const QIcon &icon, const QString &message, const Plasma::MessageButtons buttons);
1004 
1023  virtual void constraintsEvent(Plasma::Constraints constraints);
1024 
1034  void registerAsDragHandle(QGraphicsItem *item);
1035 
1041  void unregisterAsDragHandle(QGraphicsItem *item);
1042 
1047  bool isRegisteredAsDragHandle(QGraphicsItem *item);
1048 
1052  Extender *extender() const;
1053 
1057  bool eventFilter(QObject *o, QEvent *e);
1058 
1062  bool sceneEventFilter (QGraphicsItem *watched, QEvent *event);
1063 
1067  void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
1068 
1072  void focusInEvent(QFocusEvent *event);
1073 
1077  void resizeEvent(QGraphicsSceneResizeEvent *event);
1078 
1082  QVariant itemChange(GraphicsItemChange change, const QVariant &value);
1083 
1087  QPainterPath shape() const;
1088 
1092  QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
1093 
1097  void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
1098 
1102  void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
1103 
1107  void timerEvent (QTimerEvent *event);
1108 
1109 
1110  private:
1119  Applet(const QString &packagePath, uint appletId, const QVariantList &args);
1120 
1121  Q_PRIVATE_SLOT(d, void setFocus())
1122  Q_PRIVATE_SLOT(d, void themeChanged())
1123  Q_PRIVATE_SLOT(d, void cleanUpAndDelete())
1124  Q_PRIVATE_SLOT(d, void selectItemToDestroy())
1125  Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect))
1126  Q_PRIVATE_SLOT(d, void destroyMessageOverlay())
1127  Q_PRIVATE_SLOT(d, void configDialogFinished())
1128  Q_PRIVATE_SLOT(d, void updateShortcuts())
1129  Q_PRIVATE_SLOT(d, void publishCheckboxStateChanged(int state))
1130  Q_PRIVATE_SLOT(d, void globalShortcutChanged())
1131  Q_PRIVATE_SLOT(d, void propagateConfigChanged())
1132  Q_PRIVATE_SLOT(d, void handleDisappeared(AppletHandle *handle))
1133 
1137  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
1138 
1139  AppletPrivate *const d;
1140 
1141  //Corona needs to access setFailedToLaunch and init
1142  friend class Corona;
1143  friend class CoronaPrivate;
1144  friend class Containment;
1145  friend class ContainmentPrivate;
1146  friend class AppletScript;
1147  friend class AppletHandle;
1148  friend class AppletPrivate;
1149  friend class AccessAppletJobPrivate;
1150  friend class PluginLoader;
1151  friend class PopupApplet;
1152  friend class PopupAppletPrivate;
1153  friend class AssociatedApplicationManager;
1154 
1155  friend class Extender;
1156  friend class ExtenderGroup;
1157  friend class ExtenderGroupPrivate;
1158  friend class ExtenderPrivate;
1159  friend class ExtenderItem;
1160 };
1161 
1162 } // Plasma namespace
1163 
1164 Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Applet::BackgroundHints)
1165 
1169 #define K_EXPORT_PLASMA_APPLET(libname, classname) \
1170 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
1171 K_EXPORT_PLUGIN(factory("plasma_applet_" #libname)) \
1172 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
1173 
1174 #endif // multiple inclusion guard
Plasma::ImmutabilityType
ImmutabilityType
Defines the immutability of items like applets, corona and containments they can be free to modify...
Definition: plasma.h:197
Plasma::Extender
Extends applets to allow detachable parts.
Definition: extender.h:65
QWidget
Plasma::Context
Definition: context.h:33
Plasma::MessageButton
MessageButton
Definition: plasma.h:243
QObject
Plasma::Applet::BackgroundHint
BackgroundHint
Description on how draw a background for the applet.
Definition: applet.h:103
Plasma::Applet
The base Applet class.
Definition: applet.h:77
Plasma::Location
Location
The Location enumeration describes where on screen an element, such as an Applet or its managing cont...
Definition: plasma.h:108
Plasma::PopupApplet
Allows applets to automatically 'collapse' into an icon when put in an panel, and is a convenient bas...
Definition: popupapplet.h:52
Plasma::PackageStructure::Ptr
KSharedPtr< PackageStructure > Ptr
Definition: packagestructure.h:77
Plasma::AllConstraints
Definition: plasma.h:54
Plasma::DataEngine
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:58
Plasma::FormFactor
FormFactor
The FormFactor enumeration describes how a Plasma::Applet should arrange itself.
Definition: plasma.h:64
Plasma::AppletScript
Provides a restricted interface for scripted applets.
Definition: appletscript.h:51
Plasma::Package
object representing an installed Plasmagik package
Definition: package.h:42
configloader.h
version.h
Plasma::PluginLoader
This is an abstract base class which defines an interface to which Plasma's Applet Loading logic can ...
Definition: pluginloader.h:51
plasma.h
Plasma::Applet::List
QList< Applet * > List
Definition: applet.h:97
Plasma::type
static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
Definition: easingcurve.cpp:63
framesvg.h
packagestructure.h
QGraphicsView
Plasma::ExtenderGroup
Allows for grouping of extender items.
Definition: extendergroup.h:50
Plasma::Containment
The base class for plugins that provide backgrounds and applet grouping containers.
Definition: containment.h:72
Plasma::ItemStatus
ItemStatus
Status of an applet.
Definition: plasma.h:256
animator.h
Plasma::ConfigLoader
Definition: configloader.h:75
Plasma::AppletType
Definition: plasma.h:188
Plasma::ExtenderItem
Provides detachable items for an Extender.
Definition: extenderitem.h:80
QStyleOptionGraphicsItem
Plasma::packageStructure
PackageStructure::Ptr packageStructure(const QString &language, ComponentType type)
Loads an appropriate PackageStructure for the given language and type.
Definition: scriptengine.cpp:274
Plasma::Applet::Dict
QHash< QString, Applet * > Dict
Definition: applet.h:98
Plasma::Corona
A QGraphicsScene for Plasma::Applets.
Definition: corona.h:48
Plasma::AspectRatioMode
AspectRatioMode
Defines the aspect ratio used when scaling an applet.
Definition: plasma.h:208
QGraphicsWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal