22 #ifndef PLASMA_APPLET_H
23 #define PLASMA_APPLET_H
25 #include <QtGui/QGraphicsItem>
26 #include <QtGui/QGraphicsWidget>
27 #include <QtGui/QIcon>
29 #include <kconfiggroup.h>
30 #include <kgenericfactory.h>
31 #include <kplugininfo.h>
32 #include <kshortcut.h>
45 class KActionCollection;
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)
85 Q_PROPERTY(
bool hasFailedToLaunch READ hasFailedToLaunch WRITE setFailedToLaunch)
86 Q_PROPERTY(
bool isBusy READ isBusy WRITE setBusy)
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)
106 StandardBackground = 1,
107 TranslucentBackground = 2,
109 DefaultBackground = StandardBackground
112 Q_DECLARE_FLAGS(BackgroundHints, BackgroundHint)
133 KConfigGroup config()
const;
142 KConfigGroup config(
const QString &group)
const;
154 virtual void save(KConfigGroup &group)
const;
164 virtual void restore(KConfigGroup &group);
173 KConfigGroup globalConfig()
const;
200 Q_INVOKABLE
DataEngine *dataEngine(
const QString &name)
const;
208 const Package *package()
const;
223 QRectF mapFromView(
const QGraphicsView *view,
const QRect &rect)
const;
230 QRect mapToView(
const QGraphicsView *view,
const QRectF &rect)
const;
238 QPoint popupPosition(
const QSize &s)
const;
248 QPoint popupPosition(
const QSize &s, Qt::AlignmentFlag alignment)
const;
305 static KPluginInfo::List listAppletInfo(
const QString &category = QString(),
306 const QString &parentApp = QString());
313 static KPluginInfo::List listAppletInfoForMimetype(
const QString &mimetype);
321 static KPluginInfo::List listAppletInfoForUrl(
const QUrl &url);
334 static QStringList listCategories(
const QString &parentApp = QString(),
335 bool visibleOnly =
true);
343 void setCustomCategories(
const QStringList &categories);
349 QStringList customCategories();
365 static Applet *loadPlasmoid(
const QString &path, uint appletId = 0,
366 const QVariantList &args = QVariantList());
381 static Applet *load(
const QString &name, uint appletId = 0,
382 const QVariantList &args = QVariantList());
397 static Applet *load(
const KPluginInfo &info, uint appletId = 0,
398 const QVariantList &args = QVariantList());
405 static QString category(
const KPluginInfo &applet);
412 static QString category(
const QString &appletName);
422 virtual void paintInterface(QPainter *painter,
424 const QRect &contentsRect);
432 QString name()
const;
442 QString pluginName()
const;
450 bool shouldConserveResources()
const;
455 QString icon()
const;
461 QString category()
const;
468 void paintWindowFrame(QPainter *painter,
476 bool hasFailedToLaunch()
const;
487 bool configurationRequired()
const;
492 bool hasConfigurationInterface()
const;
503 virtual QList<QAction*> contextualActions();
508 Q_INVOKABLE QAction *action(QString name)
const;
513 void addAction(QString name, QAction *action);
520 void setBackgroundHints(
const BackgroundHints hints);
526 BackgroundHints backgroundHints()
const;
531 bool isContainment()
const;
542 QRect screenRect()
const;
560 void setGlobalShortcut(
const KShortcut &shortcut);
566 KShortcut globalShortcut()
const;
573 virtual bool isPopupShowing()
const;
579 virtual void addAssociatedWidget(
QWidget *widget);
585 virtual void removeAssociatedWidget(
QWidget *widget);
613 explicit Applet(QGraphicsItem *parent = 0,
614 const QString &serviceId = QString(),
624 explicit Applet(
const KPluginInfo &info, QGraphicsItem *parent = 0, uint appletId = 0);
636 explicit Applet(QGraphicsItem *parent,
637 const QString &serviceId,
639 const QVariantList &args);
646 bool destroyed()
const;
671 virtual void createConfigurationInterface(KConfigDialog *parent);
678 bool hasAuthorization(
const QString &constraint)
const;
691 void setAssociatedApplication(
const QString &
string);
700 void setAssociatedApplicationUrls(
const KUrl::List &urls);
706 QString associatedApplication()
const;
712 KUrl::List associatedApplicationUrls()
const;
718 bool hasValidAssociatedApplication()
const;
727 void releaseVisualFocus();
729 #if QT_VERSION >= 0x040700
731 void geometryChanged();
737 void geometryChanged();
744 void appletTransformedByUser();
749 void appletTransformedItself();
754 void sizeHintChanged(Qt::SizeHint which);
764 void configNeedsSaving();
815 virtual void destroy();
830 virtual void showConfigurationInterface();
840 void showConfigurationInterface(
QWidget *widget);
846 bool isUserConfiguring()
const;
862 void flushPendingConstraintsEvents();
879 virtual void configChanged();
885 void setBusy(
bool busy);
891 QVariantList startupArguments()
const;
911 void publish(Plasma::AnnouncementMethods methods,
const QString &resourceName);
915 bool isPublished()
const;
925 void runAssociatedApplication();
952 void setFailedToLaunch(
bool failed,
const QString &reason = QString());
963 virtual void saveState(KConfigGroup &config)
const;
974 void setHasConfigurationInterface(
bool hasInterface);
987 void setConfigurationRequired(
bool needsConfiguring,
const QString &reason = QString());
1003 void showMessage(
const QIcon &icon,
const QString &message,
const Plasma::MessageButtons buttons);
1023 virtual void constraintsEvent(Plasma::Constraints constraints);
1034 void registerAsDragHandle(QGraphicsItem *item);
1041 void unregisterAsDragHandle(QGraphicsItem *item);
1047 bool isRegisteredAsDragHandle(QGraphicsItem *item);
1057 bool eventFilter(
QObject *o, QEvent *e);
1062 bool sceneEventFilter (QGraphicsItem *watched, QEvent *event);
1067 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
1072 void focusInEvent(QFocusEvent *event);
1077 void resizeEvent(QGraphicsSceneResizeEvent *event);
1082 QVariant itemChange(GraphicsItemChange change,
const QVariant &value);
1087 QPainterPath shape()
const;
1092 QSizeF sizeHint(Qt::SizeHint which,
const QSizeF & constraint = QSizeF())
const;
1097 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
1102 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
1107 void timerEvent (QTimerEvent *event);
1119 Applet(
const QString &packagePath, uint appletId,
const QVariantList &args);
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))
1139 AppletPrivate *const d;
1143 friend class CoronaPrivate;
1145 friend class ContainmentPrivate;
1147 friend class AppletHandle;
1148 friend class AppletPrivate;
1149 friend class AccessAppletJobPrivate;
1152 friend class PopupAppletPrivate;
1153 friend class AssociatedApplicationManager;
1157 friend class ExtenderGroupPrivate;
1158 friend class ExtenderPrivate;
1164 Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::
Applet::BackgroundHints)
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)
1174 #endif // multiple inclusion guard
ImmutabilityType
Defines the immutability of items like applets, corona and containments they can be free to modify...
Extends applets to allow detachable parts.
BackgroundHint
Description on how draw a background for the applet.
Location
The Location enumeration describes where on screen an element, such as an Applet or its managing cont...
KSharedPtr< PackageStructure > Ptr
Data provider for plasmoids (Plasma plugins)
FormFactor
The FormFactor enumeration describes how a Plasma::Applet should arrange itself.
Provides a restricted interface for scripted applets.
object representing an installed Plasmagik package
This is an abstract base class which defines an interface to which Plasma's Applet Loading logic can ...
static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
Allows for grouping of extender items.
The base class for plugins that provide backgrounds and applet grouping containers.
ItemStatus
Status of an applet.
Provides detachable items for an Extender.
PackageStructure::Ptr packageStructure(const QString &language, ComponentType type)
Loads an appropriate PackageStructure for the given language and type.
QHash< QString, Applet * > Dict
A QGraphicsScene for Plasma::Applets.
AspectRatioMode
Defines the aspect ratio used when scaling an applet.