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

Plasma

  • 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
41class QWidget;
42
43class KConfigDialog;
44class QGraphicsView;
45class KActionCollection;
46
47namespace Plasma
48{
49
50class AppletPrivate;
51class Containment;
52class Context;
53class DataEngine;
54class Extender;
55class ExtenderItem;
56class Package;
57
58
77class 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
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
1164Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Applet::BackgroundHints)
1165
1169#define K_EXPORT_PLASMA_APPLET(libname, classname) \
1170K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
1171K_EXPORT_PLUGIN(factory("plasma_applet_" #libname)) \
1172K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
1173
1174#endif // multiple inclusion guard
animator.h
Plasma::AppletScript
Provides a restricted interface for scripted applets.
Definition: appletscript.h:52
Plasma::Applet
The base Applet class.
Definition: applet.h:78
Plasma::Applet::appletTransformedItself
void appletTransformedItself()
Emitted when the applet changes its own geometry or transform.
Plasma::Applet::BackgroundHint
BackgroundHint
Description on how draw a background for the applet.
Definition: applet.h:103
Plasma::Applet::messageButtonPressed
void messageButtonPressed(const Plasma::MessageButton button)
Emitted when the user clicked on a button of the message overlay.
Plasma::Applet::newStatus
void newStatus(Plasma::ItemStatus status)
Emitted when the applet status changes.
Plasma::Applet::configNeedsSaving
void configNeedsSaving()
Emitted when an applet has changed values in its configuration and wishes for them to be saved at the...
Plasma::Applet::List
QList< Applet * > List
Definition: applet.h:97
Plasma::Applet::releaseVisualFocus
void releaseVisualFocus()
This signal indicates that an application launch, window creation or window focus event was triggered...
Plasma::Applet::Dict
QHash< QString, Applet * > Dict
Definition: applet.h:98
Plasma::Applet::geometryChanged
void geometryChanged()
Emitted whenever the applet makes a geometry change, so that views can coordinate themselves with the...
Plasma::Applet::sizeHintChanged
void sizeHintChanged(Qt::SizeHint which)
Emitted by Applet subclasses when they change a sizeHint and wants to announce the change.
Plasma::Applet::activate
void activate()
Emitted when activation is requested due to, for example, a global keyboard shortcut.
Plasma::Applet::appletDestroyed
void appletDestroyed(Plasma::Applet *applet)
Emitted when the applet is deleted.
Plasma::Applet::extenderItemRestored
void extenderItemRestored(Plasma::ExtenderItem *item)
Emitted when an ExtenderItem in a scripting applet needs to be initialized.
Plasma::Applet::immutabilityChanged
void immutabilityChanged(Plasma::ImmutabilityType immutable)
Emitted when the immutability changes.
Plasma::Applet::appletTransformedByUser
void appletTransformedByUser()
Emitted when the user completes a transformation of the applet.
Plasma::ConfigLoader
Definition: configloader.h:76
Plasma::Containment
The base class for plugins that provide backgrounds and applet grouping containers.
Definition: containment.h:73
Plasma::Context
Definition: context.h:34
Plasma::Corona
A QGraphicsScene for Plasma::Applets.
Definition: corona.h:49
Plasma::DataEngine
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:59
Plasma::ExtenderGroup
Allows for grouping of extender items.
Definition: extendergroup.h:51
Plasma::ExtenderItem
Provides detachable items for an Extender.
Definition: extenderitem.h:81
Plasma::Extender
Extends applets to allow detachable parts.
Definition: extender.h:66
Plasma::PackageStructure::Ptr
KSharedPtr< PackageStructure > Ptr
Definition: packagestructure.h:77
Plasma::Package
object representing an installed Plasmagik package
Definition: package.h:43
Plasma::PluginLoader
This is an abstract base class which defines an interface to which Plasma's Applet Loading logic can ...
Definition: pluginloader.h:52
Plasma::PopupApplet
Allows applets to automatically 'collapse' into an icon when put in an panel, and is a convenient bas...
Definition: popupapplet.h:53
QGraphicsView
QGraphicsWidget
QObject
QStyleOptionGraphicsItem
QWidget
configloader.h
framesvg.h
Plasma
Namespace for everything in libplasma.
Definition: abstractdialogmanager.cpp:25
Plasma::ImmutabilityType
ImmutabilityType
Defines the immutability of items like applets, corona and containments they can be free to modify,...
Definition: plasma.h:197
Plasma::AppletType
@ AppletType
Definition: plasma.h:188
Plasma::AspectRatioMode
AspectRatioMode
Defines the aspect ratio used when scaling an applet.
Definition: plasma.h:208
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::Location
Location
The Location enumeration describes where on screen an element, such as an Applet or its managing cont...
Definition: plasma.h:108
Plasma::ItemStatus
ItemStatus
Status of an applet.
Definition: plasma.h:256
Plasma::AllConstraints
@ AllConstraints
Definition: plasma.h:54
Plasma::FormFactor
FormFactor
The FormFactor enumeration describes how a Plasma::Applet should arrange itself.
Definition: plasma.h:64
Plasma::MessageButton
MessageButton
Definition: plasma.h:243
packagestructure.h
plasma.h
version.h
<Plasma/Version>
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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