2005-12-29 22:55:22 +01:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2006-2007 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
|
2008-04-14 12:48:32 +02:00
|
|
|
* Copyright 2008 by Ménard Alexis <darktears31@gmail.com>
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
2005-12-29 22:55:22 +01:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
2006-01-23 12:37:31 +01:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-12-29 22:55:22 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_APPLET_H
|
|
|
|
#define PLASMA_APPLET_H
|
|
|
|
|
2007-06-20 08:45:08 +02:00
|
|
|
#include <QtGui/QGraphicsItem>
|
2007-04-22 11:35:04 +02:00
|
|
|
#include <QtGui/QWidget>
|
2008-04-14 18:02:23 +02:00
|
|
|
#include <QtGui/QGraphicsWidget>
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2008-05-22 17:53:48 +02:00
|
|
|
#include <KDE/KConfigGroup>
|
2008-03-02 03:18:10 +01:00
|
|
|
#include <KDE/KGenericFactory>
|
2008-05-22 17:53:48 +02:00
|
|
|
#include <KDE/KPluginInfo>
|
2008-06-01 04:53:50 +02:00
|
|
|
#include <KDE/KShortcut>
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2007-07-30 18:19:07 +02:00
|
|
|
#include <plasma/configxml.h>
|
2008-02-15 11:35:00 +01:00
|
|
|
#include <plasma/packagestructure.h>
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma.h>
|
2008-05-09 06:43:21 +02:00
|
|
|
#include <plasma/animator.h>
|
2008-07-17 03:11:25 +02:00
|
|
|
#include <plasma/version.h>
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2008-04-02 17:37:17 +02:00
|
|
|
class KConfigDialog;
|
2008-04-14 18:02:23 +02:00
|
|
|
class QGraphicsView;
|
2008-05-17 05:39:24 +02:00
|
|
|
class KActionCollection;
|
2008-04-02 17:37:17 +02:00
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
2007-06-02 19:29:39 +02:00
|
|
|
|
2008-08-02 19:46:32 +02:00
|
|
|
class AppletPrivate;
|
2007-09-18 23:22:45 +02:00
|
|
|
class Containment;
|
2008-09-05 02:22:42 +02:00
|
|
|
class Context;
|
2007-06-02 19:29:39 +02:00
|
|
|
class DataEngine;
|
2008-08-02 13:48:56 +02:00
|
|
|
class Extender;
|
2008-08-02 19:46:32 +02:00
|
|
|
class ExtenderItem;
|
|
|
|
class Package;
|
2007-06-02 19:29:39 +02:00
|
|
|
|
2007-05-22 20:29:12 +02:00
|
|
|
/**
|
2008-08-25 19:47:48 +02:00
|
|
|
* @class Applet plasma/applet.h <Plasma/Applet>
|
|
|
|
*
|
2007-07-28 21:59:22 +02:00
|
|
|
* @short The base Applet class
|
2007-05-22 20:29:12 +02:00
|
|
|
*
|
2007-07-28 21:59:22 +02:00
|
|
|
* Applet provides several important roles for add-ons widgets in Plasma.
|
2007-05-23 17:47:27 +02:00
|
|
|
*
|
2007-07-28 21:59:22 +02:00
|
|
|
* 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
|
2007-12-05 23:31:23 +01:00
|
|
|
* Applet::dataEngine(const QString&) are properly deref'd on Applet
|
2007-07-28 21:59:22 +02:00
|
|
|
* 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 tutorial on writing Applets using this class.
|
2007-05-22 20:29:12 +02:00
|
|
|
*/
|
2008-04-14 18:02:23 +02:00
|
|
|
class PLASMA_EXPORT Applet : public QGraphicsWidget
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2008-04-16 23:15:38 +02:00
|
|
|
Q_PROPERTY(bool hasConfigurationInterface READ hasConfigurationInterface)
|
2008-01-10 20:02:05 +01:00
|
|
|
Q_PROPERTY(QString name READ name)
|
|
|
|
Q_PROPERTY(QString category READ category)
|
2008-04-24 20:24:11 +02:00
|
|
|
Q_PROPERTY(ImmutabilityType immutability READ immutability WRITE setImmutability)
|
2008-04-16 23:15:38 +02:00
|
|
|
Q_PROPERTY(bool hasFailedToLaunch READ hasFailedToLaunch WRITE setFailedToLaunch)
|
2008-04-29 04:34:21 +02:00
|
|
|
Q_PROPERTY(bool configurationRequired READ configurationRequired WRITE setConfigurationRequired)
|
2008-01-10 20:02:05 +01:00
|
|
|
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
|
|
|
|
Q_PROPERTY(bool shouldConserveResources READ shouldConserveResources)
|
2005-12-29 22:55:22 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef QList<Applet*> List;
|
2007-05-24 22:01:12 +02:00
|
|
|
typedef QHash<QString, Applet*> Dict;
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2008-04-26 11:13:57 +02:00
|
|
|
/**
|
|
|
|
* Description on how draw a background for the applet
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
enum BackgroundHint {
|
|
|
|
NoBackground = 0, /** Not drawing a background under the
|
|
|
|
applet, the applet has its own implementation */
|
|
|
|
StandardBackground = 1, /** The standard background from the theme is drawn */
|
|
|
|
TranslucentBackground = 2,/** An alternate version of the background is drawn,
|
|
|
|
usually more translucent */
|
|
|
|
ShadowedBackground = 4, /** The applet has a drop shadow */
|
|
|
|
DefaultBackground = StandardBackground | ShadowedBackground
|
|
|
|
/** Default settings:
|
|
|
|
both standard background
|
|
|
|
and shadow */
|
|
|
|
};
|
2008-04-26 11:13:57 +02:00
|
|
|
Q_DECLARE_FLAGS(BackgroundHints, BackgroundHint)
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
~Applet();
|
|
|
|
|
2008-02-15 11:35:00 +01:00
|
|
|
/**
|
|
|
|
* @return a package structure representing a Theme
|
|
|
|
*/
|
2008-02-26 05:08:51 +01:00
|
|
|
static PackageStructure::Ptr packageStructure();
|
2008-02-15 11:35:00 +01:00
|
|
|
|
2007-08-05 15:01:09 +02:00
|
|
|
/**
|
|
|
|
* @return the id of this applet
|
|
|
|
*/
|
|
|
|
uint id() const;
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
/**
|
2007-05-25 04:36:22 +02:00
|
|
|
* Returns the KConfigGroup to access the applets configuration.
|
2005-12-29 22:55:22 +01:00
|
|
|
*
|
2007-05-25 04:36:22 +02:00
|
|
|
* This config object will write to an instance
|
2006-04-13 02:11:16 +02:00
|
|
|
* specific config file named \<appletname\>\<instanceid\>rc
|
2007-05-25 04:36:22 +02:00
|
|
|
* in the Plasma appdata directory.
|
2005-12-29 22:55:22 +01:00
|
|
|
**/
|
2007-07-12 21:14:23 +02:00
|
|
|
KConfigGroup config() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a config group with the name provided. This ensures
|
|
|
|
* that the group name is properly namespaced to avoid collision
|
|
|
|
* with other applets that may be sharing this config file
|
|
|
|
*
|
|
|
|
* @param group the name of the group to access
|
|
|
|
**/
|
2007-11-25 00:38:37 +01:00
|
|
|
KConfigGroup config(const QString &group) const;
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2007-09-18 23:22:45 +02:00
|
|
|
/**
|
2008-06-15 23:47:25 +02:00
|
|
|
* 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 reimplmented by Applet
|
|
|
|
* subclasses, but can be useful for Applet specializations
|
|
|
|
* (such as Containment) to do so.
|
|
|
|
*
|
|
|
|
* Applet subclasses may instead want to reimplement saveState().
|
2007-09-18 23:22:45 +02:00
|
|
|
**/
|
2008-05-22 17:53:48 +02:00
|
|
|
virtual void save(KConfigGroup &group) const;
|
2007-09-18 23:22:45 +02:00
|
|
|
|
2008-02-13 02:52:02 +01:00
|
|
|
/**
|
2008-06-15 23:47:25 +02:00
|
|
|
* Restores state information about this applet saved previously
|
|
|
|
* in save(KConfigGroup&).
|
|
|
|
*
|
|
|
|
* This method does not need to be reimplmented by Applet
|
|
|
|
* subclasses, but can be useful for Applet specializations
|
|
|
|
* (such as Containment) to do so.
|
2008-02-13 02:52:02 +01:00
|
|
|
**/
|
2008-05-22 17:53:48 +02:00
|
|
|
virtual void restore(KConfigGroup &group);
|
2008-02-13 02:52:02 +01:00
|
|
|
|
2006-04-13 02:11:16 +02:00
|
|
|
/**
|
2007-05-25 04:36:22 +02:00
|
|
|
* 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.
|
2006-04-13 02:11:16 +02:00
|
|
|
*/
|
2007-07-12 21:14:23 +02:00
|
|
|
KConfigGroup globalConfig() const;
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2007-07-30 18:19:07 +02:00
|
|
|
/**
|
|
|
|
* Returns the config skeleton object from this applet's package,
|
|
|
|
* if any.
|
|
|
|
*
|
|
|
|
* @return config skeleton object, or 0 if none
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
ConfigXml *configScheme() const;
|
2007-07-30 18:19:07 +02:00
|
|
|
|
2006-04-13 02:11:16 +02:00
|
|
|
/**
|
2007-07-11 03:24:43 +02:00
|
|
|
* Loads the given DataEngine
|
2006-04-13 02:11:16 +02:00
|
|
|
*
|
2007-07-11 03:24:43 +02:00
|
|
|
* Tries to load the data engine given by @p name. Each engine is
|
|
|
|
* only loaded once, and that instance is re-used on all subsequent
|
|
|
|
* requests.
|
|
|
|
*
|
|
|
|
* If the data engine was not found, an invalid data engine is returned
|
|
|
|
* (see DataEngine::isValid()).
|
|
|
|
*
|
|
|
|
* Note that you should <em>not</em> delete the returned engine.
|
|
|
|
*
|
|
|
|
* @param name Name of the data engine to load
|
|
|
|
* @return pointer to the data engine if it was loaded,
|
|
|
|
* or an invalid data engine if the requested engine
|
|
|
|
* could not be loaded
|
2006-04-13 02:11:16 +02:00
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
|
2007-07-20 05:34:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessor for the associated Package object if any.
|
|
|
|
* Generally, only Plasmoids come in a Package.
|
|
|
|
*
|
|
|
|
* @return the Package object, or 0 if none
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
const Package *package() const;
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2008-04-14 23:07:25 +02:00
|
|
|
/**
|
2008-10-16 23:40:21 +02:00
|
|
|
* Returns the view this widget is visible on, or 0 if none can be found.
|
|
|
|
* @warning do NOT assume this will always return a view!
|
|
|
|
* a null view probably means that either plasma isn't finished loading, or your applet is
|
|
|
|
* on an activity that's not being shown anywhere.
|
2008-04-14 23:07:25 +02:00
|
|
|
*/
|
|
|
|
QGraphicsView *view() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps a QRect from a view's coordinates to local coordinates.
|
|
|
|
* @param view the view from which rect should be mapped
|
|
|
|
* @param rect the rect to be mapped
|
|
|
|
*/
|
|
|
|
QRectF mapFromView(const QGraphicsView *view, const QRect &rect) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps a QRectF from local coordinates to a view's coordinates.
|
|
|
|
* @param view the view to which rect should be mapped
|
|
|
|
* @param rect the rect to be mapped
|
|
|
|
*/
|
|
|
|
QRect mapToView(const QGraphicsView *view, const QRectF &rect) const;
|
|
|
|
|
|
|
|
/**
|
2008-05-09 07:32:15 +02:00
|
|
|
* Reccomended position for a popup window like a menu or a tooltip
|
2008-04-14 23:07:25 +02:00
|
|
|
* given its size
|
|
|
|
* @param s size of the popup
|
2008-05-09 07:32:15 +02:00
|
|
|
* @returns reccomended position
|
2008-04-14 23:07:25 +02:00
|
|
|
*/
|
|
|
|
QPoint popupPosition(const QSize &s) const;
|
|
|
|
|
2007-08-05 10:41:55 +02:00
|
|
|
/**
|
|
|
|
* Called when any of the geometry constraints have been updated.
|
2008-04-27 13:04:43 +02:00
|
|
|
* This method calls constraintsEvent, which may be reimplemented,
|
2007-08-05 10:41:55 +02:00
|
|
|
* once the Applet has been prepared for updating the constraints.
|
2007-10-02 01:24:38 +02:00
|
|
|
*
|
|
|
|
* @param constraints the type of constraints that were updated
|
2007-08-05 10:41:55 +02:00
|
|
|
*/
|
2007-10-02 01:30:47 +02:00
|
|
|
void updateConstraints(Plasma::Constraints constraints = Plasma::AllConstraints);
|
2007-08-05 10:41:55 +02:00
|
|
|
|
2007-06-01 00:40:38 +02:00
|
|
|
/**
|
|
|
|
* Returns the current form factor the applet is being displayed in.
|
2007-07-07 00:20:57 +02:00
|
|
|
*
|
2007-06-01 00:40:38 +02:00
|
|
|
* @see Plasma::FormFactor
|
|
|
|
*/
|
2007-09-18 23:22:45 +02:00
|
|
|
virtual FormFactor formFactor() const;
|
2007-06-01 00:40:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the location of the scene which is displaying applet.
|
2007-07-07 00:20:57 +02:00
|
|
|
*
|
2007-06-01 00:40:38 +02:00
|
|
|
* @see Plasma::Location
|
|
|
|
*/
|
2007-09-18 23:22:45 +02:00
|
|
|
virtual Location location() const;
|
2008-05-01 00:13:27 +02:00
|
|
|
|
2008-08-18 16:04:30 +02:00
|
|
|
/**
|
|
|
|
* Returns the workspace context which the applet is operating in
|
|
|
|
*/
|
2008-09-05 02:22:42 +02:00
|
|
|
Context *context() const;
|
2008-08-18 16:04:30 +02:00
|
|
|
|
2008-05-01 00:13:27 +02:00
|
|
|
/**
|
2008-05-09 07:32:15 +02:00
|
|
|
* @return the preferred aspect ratio mode for placement and resizing
|
2008-01-10 20:02:05 +01:00
|
|
|
*/
|
2008-05-01 00:13:27 +02:00
|
|
|
Plasma::AspectRatioMode aspectRatioMode() const;
|
2008-01-10 20:02:05 +01:00
|
|
|
|
|
|
|
/**
|
2008-05-09 07:32:15 +02:00
|
|
|
* Sets the preferred aspect ratio mode for placement and resizing
|
2008-01-10 20:02:05 +01:00
|
|
|
*/
|
2008-05-01 00:13:27 +02:00
|
|
|
void setAspectRatioMode(Plasma::AspectRatioMode);
|
2008-01-25 01:08:25 +01:00
|
|
|
|
2007-05-24 22:01:12 +02:00
|
|
|
/**
|
2007-09-18 23:22:45 +02:00
|
|
|
* Returns a list of all known applets.
|
2007-05-24 22:01:12 +02:00
|
|
|
*
|
2007-07-17 23:30:27 +02:00
|
|
|
* @param category Only applets matchin this category will be returned.
|
|
|
|
* Useful in conjunction with knownCategories.
|
2007-09-28 07:46:37 +02:00
|
|
|
* If "Misc" is passed in, then applets without a
|
2007-07-18 00:26:18 +02:00
|
|
|
* Categories= entry are also returned.
|
2007-07-17 23:30:27 +02:00
|
|
|
* If an empty string is passed in, all applets are
|
|
|
|
* returned.
|
2007-09-28 07:46:37 +02:00
|
|
|
* @param parentApp the application to filter applets on. Uses the
|
2007-07-17 23:30:27 +02:00
|
|
|
* X-KDE-ParentApp entry (if any) in the plugin info.
|
|
|
|
* The default value of QString() will result in a
|
|
|
|
* list containing only applets not specifically
|
|
|
|
* registered to an application.
|
2007-05-24 22:01:12 +02:00
|
|
|
* @return list of applets
|
|
|
|
**/
|
2008-04-16 23:15:38 +02:00
|
|
|
static KPluginInfo::List listAppletInfo(const QString &category = QString(),
|
2007-07-17 23:30:27 +02:00
|
|
|
const QString &parentApp = QString());
|
2007-06-01 00:40:38 +02:00
|
|
|
|
2007-07-31 12:52:05 +02:00
|
|
|
/**
|
2007-09-18 23:22:45 +02:00
|
|
|
* Returns a list of all known applets associated with a certain mimetype.
|
2007-07-31 12:52:05 +02:00
|
|
|
*
|
|
|
|
* @return list of applets
|
|
|
|
**/
|
2008-04-16 23:15:38 +02:00
|
|
|
static KPluginInfo::List listAppletInfoForMimetype(const QString &mimetype);
|
2007-07-31 12:52:05 +02:00
|
|
|
|
2007-07-12 15:24:35 +02:00
|
|
|
/**
|
|
|
|
* Returns a list of all the categories used by
|
|
|
|
* installed applets.
|
2007-07-17 23:30:27 +02:00
|
|
|
*
|
2007-09-28 07:46:37 +02:00
|
|
|
* @param parentApp the application to filter applets on. Uses the
|
2007-07-17 23:30:27 +02:00
|
|
|
* X-KDE-ParentApp entry (if any) in the plugin info.
|
|
|
|
* The default value of QString() will result in a
|
|
|
|
* list containing only applets not specifically
|
|
|
|
* registered to an application.
|
|
|
|
* @return list of categories
|
2007-11-19 10:46:52 +01:00
|
|
|
* @param visibleOnly true if it should only return applets that are marked as visible
|
2007-07-12 15:24:35 +02:00
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
static QStringList listCategories(const QString &parentApp = QString(),
|
|
|
|
bool visibleOnly = true);
|
2007-07-12 15:24:35 +02:00
|
|
|
|
2007-05-24 22:01:12 +02:00
|
|
|
/**
|
2007-07-07 00:20:57 +02:00
|
|
|
* Attempts to load an applet
|
|
|
|
*
|
|
|
|
* Returns a pointer to the applet if successful.
|
|
|
|
* The caller takes responsibility for the applet, including
|
2007-05-24 22:01:12 +02:00
|
|
|
* deleting it when no longer needed.
|
|
|
|
*
|
|
|
|
* @param name the plugin name, as returned by KPluginInfo::pluginName()
|
2008-03-28 08:42:25 +01:00
|
|
|
* @param appletId unique ID to assign the applet, or zero to have one
|
2007-05-24 22:01:12 +02:00
|
|
|
* assigned automatically.
|
2007-06-20 10:11:59 +02:00
|
|
|
* @param args to send the applet extra arguments
|
2007-05-24 22:01:12 +02:00
|
|
|
* @return a pointer to the loaded applet, or 0 on load failure
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
static Applet *load(const QString &name, uint appletId = 0,
|
|
|
|
const QVariantList &args = QVariantList());
|
2007-05-23 17:47:27 +02:00
|
|
|
|
2007-05-24 22:51:59 +02:00
|
|
|
/**
|
2007-07-07 00:20:57 +02:00
|
|
|
* Attempts to load an applet
|
|
|
|
*
|
|
|
|
* Returns a pointer to the applet if successful.
|
|
|
|
* The caller takes responsibility for the applet, including
|
2007-05-24 22:51:59 +02:00
|
|
|
* deleting it when no longer needed.
|
|
|
|
*
|
|
|
|
* @param info KPluginInfo object for the desired applet
|
2008-03-28 08:42:25 +01:00
|
|
|
* @param appletId unique ID to assign the applet, or zero to have one
|
2007-05-24 22:51:59 +02:00
|
|
|
* assigned automatically.
|
2008-03-28 08:42:25 +01:00
|
|
|
* @param args to send the applet extra arguments
|
2007-05-24 22:51:59 +02:00
|
|
|
* @return a pointer to the loaded applet, or 0 on load failure
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
static Applet *load(const KPluginInfo &info, uint appletId = 0,
|
|
|
|
const QVariantList &args = QVariantList());
|
2007-05-24 22:51:59 +02:00
|
|
|
|
2008-01-12 07:02:29 +01:00
|
|
|
/**
|
|
|
|
* Get the category of the given applet
|
|
|
|
*
|
2008-03-28 08:42:25 +01:00
|
|
|
* @param applet a KPluginInfo object for the applet
|
2008-01-12 07:02:29 +01:00
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
static QString category(const KPluginInfo &applet);
|
2008-01-12 07:02:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the category of the given applet
|
|
|
|
*
|
2008-03-28 08:42:25 +01:00
|
|
|
* @param appletName the name of the applet
|
2008-01-12 07:02:29 +01:00
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
static QString category(const QString &appletName);
|
2008-01-12 07:02:29 +01:00
|
|
|
|
2007-06-22 22:28:42 +02:00
|
|
|
/**
|
|
|
|
* This method is called when the interface should be painted.
|
2007-07-07 00:20:57 +02:00
|
|
|
*
|
2007-07-24 23:04:31 +02:00
|
|
|
* @param painter the QPainter to use to do the paintiner
|
|
|
|
* @param option the style options object
|
|
|
|
* @param contentsRect the rect to paint within; automatically adjusted for
|
|
|
|
* the background, if any
|
2007-06-22 22:28:42 +02:00
|
|
|
**/
|
|
|
|
virtual void paintInterface(QPainter *painter,
|
|
|
|
const QStyleOptionGraphicsItem *option,
|
2008-10-11 18:19:04 +02:00
|
|
|
const QRect &contentsRect);
|
2007-06-22 22:28:42 +02:00
|
|
|
|
2007-06-05 21:31:48 +02:00
|
|
|
/**
|
|
|
|
* Returns the user-visible name for the applet, as specified in the
|
|
|
|
* .desktop file.
|
2007-07-07 00:20:57 +02:00
|
|
|
*
|
2007-06-05 21:31:48 +02:00
|
|
|
* @return the user-visible name for the applet.
|
|
|
|
**/
|
2007-06-21 20:24:05 +02:00
|
|
|
QString name() const;
|
|
|
|
|
2008-04-14 23:50:41 +02:00
|
|
|
/**
|
|
|
|
* @return the font currently set for this widget
|
|
|
|
**/
|
|
|
|
QFont font() const;
|
2008-04-14 17:15:26 +02:00
|
|
|
|
2007-08-05 15:01:09 +02:00
|
|
|
/**
|
|
|
|
* Returns the plugin name for the applet
|
|
|
|
*/
|
|
|
|
QString pluginName() const;
|
|
|
|
|
2007-12-21 13:27:29 +01:00
|
|
|
/**
|
|
|
|
* Whether the applet should conserve resources. If true, try to avoid doing stuff which
|
|
|
|
* is computationally heavy. Try to conserve power and resources.
|
|
|
|
*
|
|
|
|
* @return true if it should conserve resources, false if it does not.
|
|
|
|
*/
|
2007-12-21 13:34:40 +01:00
|
|
|
bool shouldConserveResources() const;
|
2007-12-21 13:27:29 +01:00
|
|
|
|
2007-07-23 08:12:38 +02:00
|
|
|
/**
|
|
|
|
* Returns the icon related to this applet
|
|
|
|
**/
|
|
|
|
QString icon() const;
|
|
|
|
|
2007-07-12 15:24:35 +02:00
|
|
|
/**
|
|
|
|
* Returns the category the applet is in, as specified in the
|
|
|
|
* .desktop file.
|
|
|
|
*/
|
|
|
|
QString category() const;
|
2007-07-29 01:41:40 +02:00
|
|
|
|
2007-06-21 20:24:05 +02:00
|
|
|
/**
|
2008-04-24 20:24:11 +02:00
|
|
|
* @return The type of immutability of this applet
|
|
|
|
*/
|
|
|
|
ImmutabilityType immutability() const;
|
2007-06-21 20:24:05 +02:00
|
|
|
|
2008-10-11 18:19:04 +02:00
|
|
|
void paintWindowFrame(QPainter *painter,
|
|
|
|
const QStyleOptionGraphicsItem *option, QWidget *widget);
|
2008-04-13 15:23:39 +02:00
|
|
|
|
2007-07-12 20:34:53 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
**/
|
2008-04-16 23:15:38 +02:00
|
|
|
bool hasFailedToLaunch() const;
|
2007-07-12 20:34:53 +02:00
|
|
|
|
2007-08-03 17:23:56 +02:00
|
|
|
/**
|
2007-09-28 07:46:37 +02:00
|
|
|
* @return true if the applet currently needs to be configured,
|
2007-08-03 17:23:56 +02:00
|
|
|
* otherwise, false
|
|
|
|
*/
|
2008-04-29 04:34:21 +02:00
|
|
|
bool configurationRequired() const;
|
2007-08-03 17:23:56 +02:00
|
|
|
|
2007-07-20 10:12:20 +02:00
|
|
|
/**
|
2008-01-12 07:02:29 +01:00
|
|
|
* @return true if this plasmoid provides a GUI configuration
|
2007-07-20 10:12:20 +02:00
|
|
|
**/
|
2008-04-16 23:15:38 +02:00
|
|
|
bool hasConfigurationInterface() const;
|
2007-06-21 20:07:39 +02:00
|
|
|
|
2007-07-31 02:20:19 +02:00
|
|
|
/**
|
|
|
|
* Returns a list of context-related QAction instances.
|
|
|
|
*
|
|
|
|
* This is used e.g. within the \a DesktopView to display a
|
|
|
|
* contextmenu.
|
|
|
|
*
|
|
|
|
* @return A list of actions. The default implementation returns an
|
|
|
|
* empty list.
|
|
|
|
**/
|
2008-04-25 21:55:24 +02:00
|
|
|
virtual QList<QAction*> contextualActions();
|
2007-07-31 02:20:19 +02:00
|
|
|
|
2008-05-17 05:39:24 +02:00
|
|
|
/**
|
|
|
|
* Returns the QAction with the given name from our collection
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
QAction *action(QString name) const;
|
2008-05-17 05:39:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the action to our collection under the given name
|
|
|
|
*/
|
|
|
|
void addAction(QString name, QAction *action);
|
|
|
|
|
2008-06-28 18:02:08 +02:00
|
|
|
/**
|
|
|
|
* Sets the BackgroundHints for this applet @see BackgroundHint
|
|
|
|
*
|
|
|
|
* @param hints the BackgroundHint combination for this applet
|
|
|
|
*/
|
|
|
|
void setBackgroundHints(const BackgroundHints hints);
|
|
|
|
|
2007-08-05 10:41:55 +02:00
|
|
|
/**
|
2008-04-26 11:13:57 +02:00
|
|
|
* @return BackgroundHints flags combination telling if the standard background is shown
|
|
|
|
* and if it has a drop shadow
|
2007-08-05 10:41:55 +02:00
|
|
|
*/
|
2008-04-26 11:13:57 +02:00
|
|
|
BackgroundHints backgroundHints() const;
|
2007-08-05 10:41:55 +02:00
|
|
|
|
2007-09-28 07:46:37 +02:00
|
|
|
/**
|
2008-01-12 07:02:29 +01:00
|
|
|
* @return true if this Applet is currently being used as a Containment, false otherwise
|
|
|
|
*/
|
2008-04-27 21:05:06 +02:00
|
|
|
bool isContainment() const;
|
2008-01-12 07:02:29 +01:00
|
|
|
|
2008-05-11 19:21:55 +02:00
|
|
|
/**
|
2008-10-02 08:08:31 +02:00
|
|
|
* This method returns screen coordinates for the widget; this method can be somewhat
|
|
|
|
* expensive and should ONLY be called when screen coordinates are required. For
|
|
|
|
* example when positioning top level widgets on top of the view to create the
|
|
|
|
* appearance of unit. This should NOT be used for popups (@see popupPosition) or
|
|
|
|
* for normal widget use (use Plasma:: widgets or QGraphicsProxyWidget instead).
|
|
|
|
*
|
2008-05-11 19:21:55 +02:00
|
|
|
* @return a rect of the applet in screen coordinates.
|
|
|
|
*/
|
|
|
|
QRect screenRect() const;
|
|
|
|
|
2007-11-15 10:39:46 +01:00
|
|
|
/**
|
2008-01-12 07:02:29 +01:00
|
|
|
* Reimplemented from QGraphicsItem
|
|
|
|
**/
|
|
|
|
int type() const;
|
2008-10-11 18:19:04 +02:00
|
|
|
enum {
|
|
|
|
Type = Plasma::AppletType
|
|
|
|
};
|
2008-01-12 07:02:29 +01:00
|
|
|
|
2008-01-18 01:09:33 +01:00
|
|
|
/**
|
|
|
|
* @return the Containment, if any, this applet belongs to
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
Containment *containment() const;
|
2008-01-18 01:09:33 +01:00
|
|
|
|
2008-06-01 04:53:50 +02:00
|
|
|
/**
|
|
|
|
* Sets the global shorcut to associate with this widget.
|
|
|
|
*/
|
|
|
|
void setGlobalShortcut(const KShortcut &shortcut);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the global shortcut associated with this wiget, or
|
|
|
|
* an empty shortcut if no global shortcut is associated.
|
|
|
|
*/
|
|
|
|
KShortcut globalShortcut() const;
|
|
|
|
|
2008-05-17 05:39:24 +02:00
|
|
|
/**
|
|
|
|
* associate actions with this widget, including ones added after this call.
|
|
|
|
* needed to make keyboard shortcuts work.
|
|
|
|
*/
|
|
|
|
virtual void addAssociatedWidget(QWidget *widget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* un-associate actions from this widget, including ones added after this call.
|
|
|
|
* needed to make keyboard shortcuts work.
|
|
|
|
*/
|
|
|
|
virtual void removeAssociatedWidget(QWidget *widget);
|
|
|
|
|
2008-05-12 07:17:45 +02:00
|
|
|
/**
|
|
|
|
* @param parent the QGraphicsItem this applet is parented to
|
|
|
|
* @param serviceId the name of the .desktop file containing the
|
|
|
|
* information about the widget
|
|
|
|
* @param appletId a unique id used to differentiate between multiple
|
|
|
|
* instances of the same Applet type
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
explicit Applet(QGraphicsItem *parent = 0,
|
|
|
|
const QString &serviceId = QString(),
|
2008-05-12 07:17:45 +02:00
|
|
|
uint appletId = 0);
|
|
|
|
|
2006-01-20 12:09:06 +01:00
|
|
|
Q_SIGNALS:
|
2008-04-25 19:21:24 +02:00
|
|
|
/**
|
|
|
|
* This signal indicates that an application launch, window
|
|
|
|
* creation or window focus event was triggered. This is used, for instance,
|
|
|
|
* to ensure that the Dashboard view in Plasma hides when such an event is
|
|
|
|
* triggered by an item it is displaying.
|
|
|
|
*/
|
2008-04-29 04:28:35 +02:00
|
|
|
void releaseVisualFocus();
|
2008-04-25 19:21:24 +02:00
|
|
|
|
2007-11-09 01:42:18 +01:00
|
|
|
/**
|
|
|
|
* Emitted whenever the applet makes a geometry change, so that views
|
|
|
|
* can coordinate themselves with these changes if they desire.
|
|
|
|
*/
|
|
|
|
void geometryChanged();
|
2008-08-02 13:48:56 +02:00
|
|
|
|
2008-07-27 18:20:56 +02:00
|
|
|
/**
|
|
|
|
* Emitted by Applet subclasses when they change a sizeHint and wants to announce the change
|
|
|
|
*/
|
|
|
|
void sizeHintChanged(Qt::SizeHint which);
|
2007-11-09 01:42:18 +01:00
|
|
|
|
2008-01-01 23:44:56 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-01-01 23:54:33 +01:00
|
|
|
void configNeedsSaving();
|
2008-01-01 23:44:56 +01:00
|
|
|
|
2008-06-01 04:13:53 +02:00
|
|
|
/**
|
|
|
|
* Emitted when activation is requested due to, for example, a global
|
|
|
|
* keyboard shortcut. By default the wiget is given focus.
|
|
|
|
*/
|
|
|
|
void activate();
|
|
|
|
|
2007-08-05 11:39:32 +02:00
|
|
|
public Q_SLOTS:
|
2007-12-04 03:17:21 +01:00
|
|
|
/**
|
2008-10-11 18:19:04 +02:00
|
|
|
* Sets the immutability type for this applet (not immutable,
|
|
|
|
* user immutable or system immutable)
|
2008-04-24 20:24:11 +02:00
|
|
|
* @arg immutable the new immutability type of this applet
|
|
|
|
*/
|
|
|
|
void setImmutability(const ImmutabilityType immutable);
|
2007-12-04 03:17:21 +01:00
|
|
|
|
2007-08-05 11:39:32 +02:00
|
|
|
/**
|
2008-05-09 06:43:21 +02:00
|
|
|
* Destroys the applet; it will be removed nicely and deleted.
|
|
|
|
* Its configuration will also be deleted.
|
2007-08-05 11:39:32 +02:00
|
|
|
*/
|
2008-05-20 06:02:36 +02:00
|
|
|
virtual void destroy();
|
2007-08-05 11:39:32 +02:00
|
|
|
|
2007-10-19 23:43:27 +02:00
|
|
|
/**
|
2008-04-02 17:37:17 +02:00
|
|
|
* Lets the user interact with the plasmoid options.
|
2007-10-19 23:43:27 +02:00
|
|
|
* Called when the user selects the configure entry
|
|
|
|
* from the context menu.
|
2008-06-23 06:26:13 +02:00
|
|
|
*
|
|
|
|
* Unless there is good reason for overriding this method,
|
|
|
|
* Applet subclasses should actually override createConfigurationInterface
|
|
|
|
* instead. A good example of when this isn't plausible is
|
|
|
|
* when using a dialog prepared by another library, such
|
|
|
|
* as KPropertiesDialog from libkfile.
|
2007-10-19 23:43:27 +02:00
|
|
|
*/
|
2008-06-23 06:26:13 +02:00
|
|
|
virtual void showConfigurationInterface();
|
2007-10-19 23:43:27 +02:00
|
|
|
|
2008-04-23 22:27:44 +02:00
|
|
|
/**
|
|
|
|
* Causes this applet to raise above all other applets.
|
|
|
|
*/
|
|
|
|
void raise();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Causes this applet to lower below all the other applets.
|
|
|
|
*/
|
|
|
|
void lower();
|
2008-04-25 19:21:24 +02:00
|
|
|
|
2007-10-26 03:04:56 +02:00
|
|
|
/**
|
|
|
|
* Sends all pending contraints updates to the applet. Will usually
|
|
|
|
* be called automatically, but can also be called manually if needed.
|
|
|
|
*/
|
2008-04-26 19:13:59 +02:00
|
|
|
void flushPendingConstraintsEvents();
|
2007-10-26 03:04:56 +02:00
|
|
|
|
2008-05-23 00:59:35 +02:00
|
|
|
/**
|
|
|
|
* This method is called once the applet is loaded and added to a Corona.
|
|
|
|
* If the applet requires a QGraphicsScene or has an particularly intensive
|
|
|
|
* set of initialization routines to go through, consider implementing it
|
|
|
|
* in this method instead of the constructor.
|
|
|
|
**/
|
|
|
|
virtual void init();
|
|
|
|
|
2008-09-12 17:21:58 +02:00
|
|
|
/**
|
|
|
|
* Called when applet configuration values has changed.
|
|
|
|
*/
|
|
|
|
virtual void configChanged();
|
|
|
|
|
2008-08-02 13:48:56 +02:00
|
|
|
/**
|
|
|
|
* Get's called when and extender item has to be initialized after a plasma restart. If you
|
|
|
|
* create ExtenderItems in your applet, you should implement this function to again create
|
|
|
|
* the widget that should be shown in this extender item. This function might look something
|
|
|
|
* like this:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* SuperCoolWidget *widget = new SuperCoolWidget();
|
|
|
|
* dataEngine("engine")->connectSource(item->config("dataSourceName"), widget);
|
|
|
|
* item->setWidget(widget);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* You can also add one or more custom qactions to this extender item in this function.
|
2008-09-11 21:26:05 +02:00
|
|
|
*
|
|
|
|
* Note that by default, not all ExtenderItems are persistent. Only items that are detached,
|
|
|
|
* will have there configuration stored when plasma exists.
|
2008-08-02 13:48:56 +02:00
|
|
|
*/
|
|
|
|
virtual void initExtenderItem(ExtenderItem *item);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the extender this applet has.
|
|
|
|
*/
|
|
|
|
Extender *extender() const;
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
protected:
|
2008-04-26 14:06:18 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param parent a QObject parent; you probably want to pass in 0
|
|
|
|
* @param args a list of strings containing two entries: the service id
|
|
|
|
* and the applet id
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
Applet(QObject *parent, const QVariantList &args);
|
2008-04-26 14:06:18 +02:00
|
|
|
|
2008-04-18 18:05:20 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param failed true when the applet failed, false when it succeeded
|
|
|
|
* @param reason an optional reason to show the user why the applet
|
|
|
|
* failed to launch
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
void setFailedToLaunch(bool failed, const QString &reason = QString());
|
2008-04-18 18:05:20 +02:00
|
|
|
|
2007-09-18 23:22:45 +02:00
|
|
|
/**
|
2008-06-15 23:47:25 +02:00
|
|
|
* 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.
|
2007-09-18 23:22:45 +02:00
|
|
|
**/
|
2008-05-22 17:53:48 +02:00
|
|
|
virtual void saveState(KConfigGroup &config) const;
|
2007-09-18 23:22:45 +02:00
|
|
|
|
2008-04-16 23:15:38 +02:00
|
|
|
/**
|
|
|
|
* 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
|
2008-05-04 01:37:55 +02:00
|
|
|
* also reimplement createConfigurationInterface()
|
2008-04-16 23:15:38 +02:00
|
|
|
*
|
|
|
|
* @param hasInterface whether or not there is a user interface available
|
|
|
|
**/
|
|
|
|
void setHasConfigurationInterface(bool hasInterface);
|
|
|
|
|
2008-04-29 04:35:56 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param needsConfiguring true if the applet needs to be configured,
|
|
|
|
* or false if it doesn't
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
|
2008-04-29 04:35:56 +02:00
|
|
|
|
2008-04-28 20:32:34 +02:00
|
|
|
/**
|
|
|
|
* Reimplement this method so provide a configuration interface,
|
|
|
|
* parented to the supplied widget. Ownership of the widgets is passed
|
|
|
|
* to the parent widget.
|
|
|
|
*
|
|
|
|
* @param parent the dialog which is the parent of the configuration
|
|
|
|
* widgets
|
|
|
|
*/
|
|
|
|
virtual void createConfigurationInterface(KConfigDialog *parent);
|
|
|
|
|
2008-04-27 13:04:43 +02:00
|
|
|
/**
|
|
|
|
* Called when any of the geometry constraints have been updated.
|
|
|
|
*
|
|
|
|
* This is always called prior to painting and should be used as an
|
|
|
|
* opportunity to layout the widget, calculate sizings, etc.
|
|
|
|
*
|
|
|
|
* Do not call update() from this method; an update() will be triggered
|
|
|
|
* at the appropriate time for the applet.
|
|
|
|
*
|
|
|
|
* @param constraints the type of constraints that were updated
|
|
|
|
* @property constraint
|
|
|
|
*/
|
|
|
|
virtual void constraintsEvent(Plasma::Constraints constraints);
|
|
|
|
|
2008-02-21 11:26:40 +01:00
|
|
|
/**
|
2008-04-30 17:04:49 +02:00
|
|
|
* Register the widgets that manage mouse clicks but you still want
|
2008-02-21 11:26:40 +01:00
|
|
|
* to be able to drag the applet around when holding the mouse pointer
|
2008-04-30 17:04:49 +02:00
|
|
|
* on that widget.
|
2008-02-21 11:26:40 +01:00
|
|
|
*
|
|
|
|
* Calling this results in an eventFilter being places on the widget.
|
|
|
|
*
|
2008-04-30 17:04:49 +02:00
|
|
|
* @param item the item to watch for mouse move
|
2008-02-21 11:26:40 +01:00
|
|
|
*/
|
2008-05-02 17:12:52 +02:00
|
|
|
void registerAsDragHandle(QGraphicsItem *item);
|
2008-04-30 17:04:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister a widget registered with registerAsDragHandle.
|
|
|
|
*
|
|
|
|
* @param item the item to unregister
|
|
|
|
*/
|
2008-05-02 17:12:52 +02:00
|
|
|
void unregisterAsDragHandle(QGraphicsItem *item);
|
2008-04-30 17:04:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param item the item to look for if it is registered or not
|
|
|
|
* @return true if it is registered, false otherwise
|
|
|
|
*/
|
2008-05-02 17:12:52 +02:00
|
|
|
bool isRegisteredAsDragHandle(QGraphicsItem *item);
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2007-05-27 10:01:31 +02:00
|
|
|
/**
|
|
|
|
* @internal event filter; used for focus watching
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
bool eventFilter(QObject *o, QEvent *e);
|
2007-09-27 01:01:57 +02:00
|
|
|
|
2008-02-21 11:26:40 +01:00
|
|
|
/**
|
|
|
|
* @internal scene event filter; used to manage applet dragging
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
bool sceneEventFilter (QGraphicsItem *watched, QEvent *event);
|
2008-02-21 11:26:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal manage the mouse movement to drag the applet around
|
|
|
|
*/
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
2008-04-14 23:50:41 +02:00
|
|
|
/**
|
|
|
|
* @internal manage the mouse movement to drag the applet around
|
|
|
|
*/
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
2008-04-14 23:07:25 +02:00
|
|
|
/**
|
|
|
|
* Reimplemented from QGraphicsItem
|
|
|
|
*/
|
2008-06-01 04:13:53 +02:00
|
|
|
void focusInEvent(QFocusEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplemented from QGraphicsItem
|
|
|
|
*/
|
|
|
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
2008-04-14 23:07:25 +02:00
|
|
|
|
2007-08-05 10:41:55 +02:00
|
|
|
/**
|
2007-11-27 07:01:06 +01:00
|
|
|
* Reimplemented from QGraphicsItem
|
2007-08-05 10:41:55 +02:00
|
|
|
*/
|
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
|
|
|
|
2008-06-25 02:33:46 +02:00
|
|
|
/**
|
|
|
|
* Reimplemented from QGraphicsItem
|
|
|
|
*/
|
|
|
|
QPainterPath shape() const;
|
|
|
|
|
2008-04-29 22:31:18 +02:00
|
|
|
/**
|
|
|
|
* Reimplemented from QGraphicsLayoutItem
|
|
|
|
*/
|
2008-10-05 19:48:44 +02:00
|
|
|
QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
|
2008-04-29 22:31:18 +02:00
|
|
|
|
2008-10-05 19:48:44 +02:00
|
|
|
/**
|
|
|
|
* Reimplemented from QGraphicsLayoutItem
|
|
|
|
*/
|
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplemented from QGraphicsLayoutItem
|
|
|
|
*/
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplemented from QObject
|
|
|
|
*/
|
2008-05-09 01:30:56 +02:00
|
|
|
void timerEvent (QTimerEvent *event);
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
private:
|
2008-06-01 04:13:53 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void setFocus())
|
2008-04-28 17:41:18 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void checkImmutability())
|
2008-04-28 17:55:13 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void themeChanged())
|
2008-10-11 18:19:04 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void appletAnimationComplete(QGraphicsItem *item,
|
|
|
|
Plasma::Animator::Animation anim))
|
2008-07-07 00:43:53 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void selectItemToDestroy())
|
2008-08-05 17:27:48 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect))
|
2007-07-20 05:34:20 +02:00
|
|
|
|
2007-07-20 10:12:20 +02:00
|
|
|
/**
|
|
|
|
* Reimplemented from QGraphicsItem
|
|
|
|
**/
|
2008-04-14 16:50:02 +02:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2007-06-22 22:28:42 +02:00
|
|
|
|
2008-10-11 18:19:04 +02:00
|
|
|
AppletPrivate *const d;
|
2008-04-18 18:05:20 +02:00
|
|
|
|
|
|
|
//Corona needs to access setFailedToLaunch and init
|
|
|
|
friend class Corona;
|
2008-07-01 20:56:43 +02:00
|
|
|
friend class CoronaPrivate;
|
2008-04-18 18:05:20 +02:00
|
|
|
friend class Containment;
|
2008-07-01 20:56:43 +02:00
|
|
|
friend class ContainmentPrivate;
|
2008-04-29 05:05:31 +02:00
|
|
|
friend class AppletScript;
|
2008-05-24 20:33:40 +02:00
|
|
|
friend class AppletHandle;
|
2008-07-01 20:56:43 +02:00
|
|
|
friend class AppletPrivate;
|
2008-09-18 04:47:25 +02:00
|
|
|
friend class PopupApplet;
|
2008-09-12 19:16:58 +02:00
|
|
|
friend class PopupAppletPrivate;
|
2008-08-02 13:48:56 +02:00
|
|
|
|
|
|
|
//FIXME: this shouldn't be necesarry.
|
|
|
|
friend class Extender;
|
|
|
|
friend class ExtenderItem;
|
2005-12-29 22:55:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
2008-04-26 11:13:57 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Applet::BackgroundHints)
|
|
|
|
|
2007-07-07 00:20:57 +02:00
|
|
|
/**
|
|
|
|
* Register an applet when it is contained in a loadable module
|
|
|
|
*/
|
2007-05-24 22:01:12 +02:00
|
|
|
#define K_EXPORT_PLASMA_APPLET(libname, classname) \
|
2007-08-29 04:33:22 +02:00
|
|
|
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
2008-07-17 03:11:25 +02:00
|
|
|
K_EXPORT_PLUGIN(factory("plasma_applet_" #libname)) \
|
|
|
|
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
2007-05-24 22:01:12 +02:00
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
#endif // multiple inclusion guard
|