Plasma::Applet
#include <Plasma/Applet>

Properties | |
Plasma::Types::BackgroundHints | backgroundHints |
bool | busy |
Plasma::Types::ContainmentDisplayHints | containmentDisplayHints |
Plasma::Types::BackgroundHints | effectiveBackgroundHints |
Plasma::Types::FormFactor | formFactor |
QString | icon |
Plasma::Types::ImmutabilityType | immutability |
Plasma::Types::Location | location |
Plasma::Types::ItemStatus | status |
QString | title |
Plasma::Types::BackgroundHints | userBackgroundHints |
![]() | |
objectName | |
Signals | |
void | activated () |
void | appletDeleted (Plasma::Applet *applet) |
void | backgroundHintsChanged () |
void | busyChanged (bool busy) |
void | configNeedsSaving () |
void | configurationRequiredChanged (bool needsConfig, const QString &reason) |
void | containmentDisplayHintsChanged (Plasma::Types::ContainmentDisplayHints hints) |
void | contextualActionsAboutToShow () |
void | destroyedChanged (bool destroyed) |
void | effectiveBackgroundHintsChanged () |
void | formFactorChanged (Plasma::Types::FormFactor formFactor) |
void | iconChanged (const QString &icon) |
void | immutabilityChanged (Plasma::Types::ImmutabilityType immutable) |
void | locationChanged (Plasma::Types::Location location) |
void | statusChanged (Plasma::Types::ItemStatus status) |
void | titleChanged (const QString &title) |
void | userBackgroundHintsChanged () |
void | userConfiguringChanged (bool configuring) |
Public Slots | |
virtual void | configChanged () |
void | destroy () |
void | flushPendingConstraintsEvents () |
virtual void | init () |
void | runAssociatedApplication () |
void | setImmutability (const Types::ImmutabilityType immutable) |
void | setLaunchErrorMessage (const QString &reason=QString()) |
void | setStatus (const Types::ItemStatus stat) |
Static Public Member Functions | |
static Applet * | loadPlasmoid (const QString &path, uint appletId=0) |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions | |
Applet (QObject *parent, const QVariantList &args) | |
virtual void | constraintsEvent (Plasma::Types::Constraints constraints) |
virtual void | saveState (KConfigGroup &config) const |
void | setConfigurationRequired (bool needsConfiguring, const QString &reason=QString()) |
void | setHasConfigurationInterface (bool hasInterface) |
void | timerEvent (QTimerEvent *event) override |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
Additional Inherited Members | |
![]() | |
typedef | QObjectList |
Detailed Description
The base Applet class.
Applet provides several important roles for add-ons widgets in Plasma.
First, it is the base class for the plugin system and therefore is the interface to applets for host applications. It also handles the life time management of data engines (e.g. all data engines accessed via Applet::dataEngine(const QString&) are properly deref'd on Applet destruction), background painting (allowing for consistent and complex look and feel in just one line of code for applets), loading and starting of scripting support for each applet, providing access to the associated plasmoid package (if any) and access to configuration data.
See techbase.kde.org for tutorials on writing Applets using this class.
Property Documentation
◆ backgroundHints
|
readwrite |
◆ effectiveBackgroundHints
|
read |
◆ userBackgroundHints
|
readwrite |
Constructor & Destructor Documentation
◆ Applet() [1/5]
Plasma::Applet::Applet | ( | QObject * | parentObject, |
const KPluginMetaData & | data, | ||
const QVariantList & | args | ||
) |
This constructor can be used with the KCoreAddons plugin loading system.
The argument list is expected to have contain the KPackage of the applet, the meta data file path (for compatibility) and an applet ID which must be a base 10 number.
- Parameters
-
parent a QObject parent; you probably want to pass in 0 data,KPluginMetaData used to create this plugin args a list of strings containing the applet id @Since 5.86
Definition at line 128 of file applet.cpp.
◆ Applet() [2/5]
|
explicit |
- Parameters
-
parent the QObject this applet is parented to serviceId the name of the .desktop file containing the information about the widget appletId a unique id used to differentiate between multiple instances of the same Applet type
- Deprecated:
- Since 5.86, use Applet(QObject *, KPluginMetaData, QVariantList) instead
Definition at line 77 of file applet.cpp.
◆ Applet() [3/5]
|
explicit |
- Parameters
-
parent the QObject this applet is parented to info the plugin information object for this Applet appletId a unique id used to differentiate between multiple instances of the same Applet type
- Since
- 4.6
- Deprecated:
- Since 5.28, prefer using KPluginMetaData
Definition at line 71 of file applet.cpp.
◆ Applet() [4/5]
|
explicit |
- Parameters
-
parent the QObject this applet is parented to metadata the plugin information object for this Applet appletId a unique id used to differentiate between multiple instances of the same Applet type
- Since
- 5.27
- Deprecated:
- Since 5.86, use Applet(QObject *, KPluginMetaData, QVariantList) instead
Definition at line 59 of file applet.cpp.
◆ Applet() [5/5]
|
protected |
This constructor is to be used with the plugin loading systems found in KPluginInfo and KService.
The argument list is expected to have two elements: the KService service ID for the desktop entry and an applet ID which must be a base 10 number.
- Parameters
-
parent a QObject parent; you probably want to pass in 0 args a list of strings containing two entries: the service id and the applet id
- Deprecated:
- Since 5.86, use Applet(QObject *, KPluginMetaData, QVariantList) instead
Definition at line 87 of file applet.cpp.
Member Function Documentation
◆ actions()
KActionCollection * Plasma::Applet::actions | ( | ) | const |
Returns the collection of actions for this Applet.
Definition at line 705 of file applet.cpp.
◆ activated
|
signal |
Emitted when activation is requested due to, for example, a global keyboard shortcut.
By default the widget is given focus.
◆ appletDeleted
|
signal |
Emitted when the applet is deleted.
◆ associatedApplication()
QString Plasma::Applet::associatedApplication | ( | ) | const |
- Returns
- the application associated to this applet
- Since
- 4.4
Definition at line 855 of file applet.cpp.
◆ associatedApplicationUrls()
◆ backgroundHints()
Plasma::Types::BackgroundHints Plasma::Applet::backgroundHints | ( | ) | const |
How the applet wants its background to be drawn.
The containment may chose to ignore this hint.
- Since
- 5.65
◆ backgroundHintsChanged
|
signal |
Emitted when the background hints have changed.
- Since
- 5.65
◆ busyChanged
|
signal |
Emitted when the busy status has changed.
- Since
- 5.21
◆ config()
KConfigGroup Plasma::Applet::config | ( | ) | const |
Returns the KConfigGroup to access the applets configuration.
This config object will write to an instance specific config file named <appletname><instanceid>rc in the Plasma appdata directory.
Definition at line 270 of file applet.cpp.
◆ configChanged
|
virtualslot |
Called when applet configuration values have changed.
Definition at line 821 of file applet.cpp.
◆ configNeedsSaving
|
signal |
Emitted when an applet has changed values in its configuration and wishes for them to be saved at the next save point.
As this implies disk activity, this signal should be used with care.
- Note
- This does not need to be emitted from saveState by individual applets.
◆ configScheme()
KConfigLoader * Plasma::Applet::configScheme | ( | ) | const |
Returns the config skeleton object from this applet's package, if any.
- Returns
- config skeleton object, or 0 if none
Definition at line 319 of file applet.cpp.
◆ configurationRequired()
bool Plasma::Applet::configurationRequired | ( | ) | const |
- Returns
- true if the applet currently needs to be configured, otherwise, false
Definition at line 551 of file applet.cpp.
◆ configurationRequiredChanged
|
signal |
◆ configurationRequiredReason()
QString Plasma::Applet::configurationRequiredReason | ( | ) | const |
- Returns
- A translated message for the user explaining that the applet needs configuring; this should note what needs to be configured
- See also
- setConfigurationRequired
- Since
- 5.20
Definition at line 556 of file applet.cpp.
◆ containment()
Containment * Plasma::Applet::containment | ( | ) | const |
- Returns
- the Containment, if any, this applet belongs to
Definition at line 731 of file applet.cpp.
◆ containmentDisplayHints()
Types::ContainmentDisplayHints Plasma::Applet::containmentDisplayHints | ( | ) | const |
- Returns
- Display hints that come from the containment that suggest the applet how to look and behave.
- Since
- 5.77
◆ contextualActions()
Returns a list of context-related QAction instances.
This is used e.g. within the DesktopView to display a contextmenu.
- Returns
- A list of actions. The default implementation returns an empty list.
Definition at line 699 of file applet.cpp.
◆ contextualActionsAboutToShow
|
signal |
Emitted just before the contextual actions are about to show For instance just before the context menu containing the actions added with setAction() is shown.
◆ destroy
|
slot |
Destroys the applet; it will be removed nicely and deleted.
Its configuration will also be deleted. If you want to remove the Applet configuration, use this, don't just delete the Applet *
Definition at line 303 of file applet.cpp.
◆ destroyed()
bool Plasma::Applet::destroyed | ( | ) | const |
- Returns
- true if destroy() was called; useful for Applets which should avoid certain tasks if they are about to be deleted permanently
Definition at line 314 of file applet.cpp.
◆ destroyedChanged
|
signal |
Emitted when the applet has been scheduled for destruction or the destruction has been undone.
- Since
- 5.4
◆ effectiveBackgroundHints()
Plasma::Types::BackgroundHints Plasma::Applet::effectiveBackgroundHints | ( | ) | const |
The effective background hints the applet will have: it will follow userBackgroundHints only if backgroundHints has the Plasma::Types::ConfigurableBackground flag set.
- Since
- 5.65
◆ effectiveBackgroundHintsChanged
|
signal |
Emitted when the effective background hints have changed.
- Since
- 5.65
◆ failedToLaunch()
bool Plasma::Applet::failedToLaunch | ( | ) | const |
If for some reason, the applet fails to get up on its feet (the library couldn't be loaded, necessary hardware support wasn't found, etc..) this method returns true.
Definition at line 546 of file applet.cpp.
◆ flushPendingConstraintsEvents
|
slot |
Sends all pending constraints updates to the applet.
Will usually be called automatically, but can also be called manually if needed.
Definition at line 602 of file applet.cpp.
◆ formFactor()
Types::FormFactor Plasma::Applet::formFactor | ( | ) | const |
Returns the current form factor the applet is being displayed in.
- See also
- Plasma::FormFactor
◆ formFactorChanged
|
signal |
Emitted when the formfactor changes.
◆ globalConfig()
KConfigGroup Plasma::Applet::globalConfig | ( | ) | const |
Returns a KConfigGroup object to be shared by all applets of this type.
This config object will write to an applet-specific config object named plasma_<appletname>rc in the local config directory.
Definition at line 283 of file applet.cpp.
◆ globalShortcut()
QKeySequence Plasma::Applet::globalShortcut | ( | ) | const |
- Returns
- the global shortcut associated with this widget, or an empty shortcut if no global shortcut is associated.
Definition at line 779 of file applet.cpp.
◆ hasConfigurationInterface()
bool Plasma::Applet::hasConfigurationInterface | ( | ) | const |
- Returns
- true if this plasmoid provides a GUI configuration
Definition at line 797 of file applet.cpp.
◆ hasValidAssociatedApplication()
bool Plasma::Applet::hasValidAssociatedApplication | ( | ) | const |
- Returns
- true if the applet has a valid associated application or urls
- Since
- 4.4
Definition at line 870 of file applet.cpp.
◆ icon()
QString Plasma::Applet::icon | ( | ) | const |
- Returns
- The icon name related to this applet By default is the one in the plasmoid desktop file
◆ iconChanged
|
signal |
Emitted when the icon name for the applet has changed.
- Since
- 5.20
◆ id()
uint Plasma::Applet::id | ( | ) | const |
- Returns
- the id of this applet
Definition at line 173 of file applet.cpp.
◆ immutability()
Types::ImmutabilityType Plasma::Applet::immutability | ( | ) | const |
- Returns
- The type of immutability of this applet
◆ immutabilityChanged
|
signal |
Emitted when the immutability changes.
- Since
- 4.4
◆ init
|
virtualslot |
This method is called once the applet is loaded and added to a Corona.
If the applet requires a Scene or has an particularly intensive set of initialization routines to go through, consider implementing it in this method instead of the constructor.
Note: paintInterface may get called before init() depending on initialization order. Painting is managed by the canvas (QGraphisScene), and may schedule a paint event prior to init() being called.
Reimplemented in Plasma::Containment.
Definition at line 168 of file applet.cpp.
◆ isBusy()
bool Plasma::Applet::isBusy | ( | ) | const |
- Returns
- true if the applet should show a busy status, for instance doing some network operation
- Since
- 5.21
Definition at line 407 of file applet.cpp.
◆ isContainment()
bool Plasma::Applet::isContainment | ( | ) | const |
- Returns
- true if this Applet is currently being used as a Containment, false otherwise
Definition at line 929 of file applet.cpp.
◆ isUserConfiguring()
bool Plasma::Applet::isUserConfiguring | ( | ) | const |
- Returns
- true when the configuration interface is being shown
- Since
- 4.5
Definition at line 573 of file applet.cpp.
◆ kPackage()
KPackage::Package Plasma::Applet::kPackage | ( | ) | const |
Accessor for the associated Package object if any.
Generally, only Plasmoids come in a Package.
- Returns
- the Package object, or an invalid one if none
- Since
- 5.6
- Deprecated:
- Since 5.100, accessing an applets KPackage is deprecated. For using the metadata, use
pluginMetaData
instead.
Definition at line 345 of file applet.cpp.
◆ launchErrorMessage()
QString Plasma::Applet::launchErrorMessage | ( | ) | const |
If for some reason, the applet fails to get up on its feet (the library couldn't be loaded, necessary hardware support wasn't found, etc..) this method returns the reason why, in an user-readable way.
- Since
- 5.0
Definition at line 541 of file applet.cpp.
◆ loadPlasmoid()
Attempts to load an applet from a package.
Returns a pointer to the applet if successful. The caller takes responsibility for the applet, including deleting it when no longer needed. If you instance a plasmoid with this deprecated API, the automated default setup scripts won't be executed for that plasmoid
- Parameters
-
path the path to the package appletId unique ID to assign the applet, or zero to have one assigned automatically.
- Returns
- a pointer to the loaded applet, or 0 on load failure
- Since
- 4.3
- Deprecated:
- Since 5.19, use Containment::createApplet() instead, you are not supposed to have applets without containments
Definition at line 876 of file applet.cpp.
◆ location()
Types::Location Plasma::Applet::location | ( | ) | const |
Returns the location of the scene which is displaying applet.
- See also
- Plasma::Types::Location
◆ locationChanged
|
signal |
Emitted when the location changes.
◆ package()
Package Plasma::Applet::package | ( | ) | const |
Accessor for the associated Package object if any.
Generally, only Plasmoids come in a Package.
- Returns
- the Package object, or an invalid one if none
- Deprecated:
- Since 5.6, use kPackage() instead
Definition at line 337 of file applet.cpp.
◆ pluginInfo()
KPluginInfo Plasma::Applet::pluginInfo | ( | ) | const |
- Returns
- metadata information about this plugin
- See also
- KPluginInfo, pluginMetaData
- Since
- 5.0
- Deprecated:
- Since 5.28, use pluginMetaData instead
Definition at line 479 of file applet.cpp.
◆ pluginMetaData()
KPluginMetaData Plasma::Applet::pluginMetaData | ( | ) | const |
◆ restore()
|
virtual |
Restores state information about this applet saved previously in save(KConfigGroup&).
This method does not need to be reimplemented by Applet subclasses, but can be useful for Applet specializations (such as Containment) to do so.
Reimplemented in Plasma::Containment.
Definition at line 211 of file applet.cpp.
◆ runAssociatedApplication
|
slot |
Open the application associated to this applet, if it's not set but some urls are, open those urls with the proper application for their mimetype.
- Since
- 4.4
Definition at line 865 of file applet.cpp.
◆ save()
|
virtual |
Saves state information about this applet that will be accessed when next instantiated in the restore(KConfigGroup&) method.
This method does not need to be reimplemented by Applet subclasses, but can be useful for Applet specializations (such as Containment) to do so.
Applet subclasses may instead want to reimplement saveState().
Reimplemented in Plasma::Containment.
Definition at line 178 of file applet.cpp.
◆ saveState()
|
protectedvirtual |
When called, the Applet should write any information needed as part of the Applet's running state to the configuration object in config() and/or globalConfig().
Applets that always sync their settings/state with the config objects when these settings/states change do not need to reimplement this method.
Definition at line 256 of file applet.cpp.
◆ setAssociatedApplication()
void Plasma::Applet::setAssociatedApplication | ( | const QString & | string | ) |
Sets an application associated to this applet, that will be regarded as a full view of what is represented in the applet.
- Parameters
-
string the name of the application. it can be - a name understood by KService::serviceByDesktopName (e.g. "konqueror")
- a command in $PATH
- or an absolute path to an executable
- Since
- 4.4
Definition at line 831 of file applet.cpp.
◆ setAssociatedApplicationUrls()
Sets a list of urls associated to this application, they will be used as parameters for the associated application.
- See also
- setAssociatedApplication()
- Parameters
-
urls
Definition at line 843 of file applet.cpp.
◆ setBackgroundHints()
void Plasma::Applet::setBackgroundHints | ( | Plasma::Types::BackgroundHints | hint | ) |
Sets the applet background hints.
Only Applet implementations should write this property
- Since
- 5.65
Definition at line 427 of file applet.cpp.
◆ setBusy()
void Plasma::Applet::setBusy | ( | bool | busy | ) |
Sets the Applet to have a busy status hint, for instance the applet doing some network operation.
The graphical representation of the busy status depends completely from the visualization.
- Parameters
-
busy true if the applet is busy
- Since
- 5.21
Definition at line 412 of file applet.cpp.
◆ setConfigurationRequired()
|
protected |
When the applet needs to be configured before being usable, this method can be called to show a standard interface prompting the user to configure the applet.
- Parameters
-
needsConfiguring true if the applet needs to be configured, or false if it doesn't reason a translated message for the user explaining that the applet needs configuring; this should note what needs to be configured
Definition at line 561 of file applet.cpp.
◆ setGlobalShortcut()
void Plasma::Applet::setGlobalShortcut | ( | const QKeySequence & | shortcut | ) |
Sets the global shortcut to associate with this widget.
Definition at line 755 of file applet.cpp.
◆ setHasConfigurationInterface()
|
protected |
Sets whether or not this applet provides a user interface for configuring the applet.
It defaults to false, and if true is passed in you should also reimplement createConfigurationInterface()
- Parameters
-
hasInterface whether or not there is a user interface available
Definition at line 802 of file applet.cpp.
◆ setIcon()
void Plasma::Applet::setIcon | ( | const QString & | icon | ) |
Sets an icon name for this applet.
- Parameters
-
icon Freedesktop compatible icon name
Definition at line 397 of file applet.cpp.
◆ setImmutability
|
slot |
Sets the immutability type for this applet (not immutable, user immutable or system immutable)
- Parameters
-
immutable the new immutability type of this applet
Definition at line 527 of file applet.cpp.
◆ setLaunchErrorMessage
Call this method when the applet fails to launch properly.
An optional reason can be provided.
Not that all children items will be deleted when this method is called. If you have pointers to these items, you will need to reset them after calling this method.
- Parameters
-
failed true when the applet failed, false when it succeeded reason an optional reason to show the user why the applet failed to launch
- Since
- 5.0
Definition at line 246 of file applet.cpp.
◆ setStatus
|
slot |
◆ setTitle()
void Plasma::Applet::setTitle | ( | const QString & | title | ) |
Sets a custom title for this instance of the applet.
E.g. a clock might use the timezone as its name rather than the .desktop file
- Since
- 5.0
- Parameters
-
title the user-visible title for the applet.
Definition at line 382 of file applet.cpp.
◆ setUserBackgroundHints()
void Plasma::Applet::setUserBackgroundHints | ( | Plasma::Types::BackgroundHints | hint | ) |
Sets the hints the user wished the background style for the applet to be.
- Since
- 5.65
Definition at line 457 of file applet.cpp.
◆ setUserConfiguring()
void Plasma::Applet::setUserConfiguring | ( | bool | configuring | ) |
Tells the applet the user is configuring.
- Parameters
-
configuring true if the configuration ui is showing
Definition at line 578 of file applet.cpp.
◆ status()
Types::ItemStatus Plasma::Applet::status | ( | ) | const |
- Returns
- the status of the applet
- Since
- 4.4
◆ statusChanged
|
signal |
Emitted when the applet status changes.
- Since
- 4.4
◆ timerEvent()
|
overrideprotectedvirtual |
◆ title()
QString Plasma::Applet::title | ( | ) | const |
Returns the user-visible title for the applet, as specified in the Name field of the .desktop file.
Can be changed with
- See also
- setTitle
- Since
- 5.0
- Returns
- the user-visible title for the applet.
◆ titleChanged
|
signal |
Emitted when the title has changed.
- Since
- 5.20
◆ updateConstraints()
void Plasma::Applet::updateConstraints | ( | Plasma::Types::Constraints | constraints = Plasma::Types::AllConstraints | ) |
Called when any of the geometry constraints have been updated.
This method calls constraintsEvent, which may be reimplemented, once the Applet has been prepared for updating the constraints.
- Parameters
-
constraints the type of constraints that were updated
Definition at line 350 of file applet.cpp.
◆ userBackgroundHints()
Plasma::Types::BackgroundHints Plasma::Applet::userBackgroundHints | ( | ) | const |
The containment (and/or the user) may decide to use another kind of background instead if supported by the applet.
In order for an applet to support user configuration of the background, it needs to have the Plasma::Types::ConfigurableBackground flag set in its backgroundHints
- Since
- 5.65
◆ userBackgroundHintsChanged
|
signal |
Emitted when the user background hints have changed.
- Since
- 5.65
◆ userConfiguringChanged
|
signal |
emitted when the config ui appears or disappears
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Mar 21 2023 04:13:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.