2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2008 by Petri Damsten <damu@iki.fi>
|
|
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_WALLPAPER_H
|
|
|
|
#define PLASMA_WALLPAPER_H
|
|
|
|
|
2011-01-26 21:08:35 +01:00
|
|
|
#include <kmimetype.h>
|
2008-11-04 03:04:34 +01:00
|
|
|
#include <kplugininfo.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
#include <plasma/plasma.h>
|
2009-04-02 08:31:37 +02:00
|
|
|
#include <plasma/packagestructure.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
#include <plasma/version.h>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
2009-04-01 01:51:52 +02:00
|
|
|
|
|
|
|
class DataEngine;
|
2008-11-04 00:08:39 +01:00
|
|
|
class WallpaperPrivate;
|
2009-10-29 06:54:11 +01:00
|
|
|
class Package;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Wallpaper plasma/wallpaper.h <Plasma/Wallpaper>
|
|
|
|
*
|
|
|
|
* @short The base Wallpaper class
|
|
|
|
*
|
|
|
|
* "Wallpapers" are components that paint the background for Containments that
|
|
|
|
* do not provide their own background rendering.
|
|
|
|
*
|
|
|
|
* Wallpaper plugins are registered using .desktop files. These files should be
|
|
|
|
* named using the following naming scheme:
|
|
|
|
*
|
2009-01-10 01:08:31 +01:00
|
|
|
* plasma-wallpaper-\<pluginname\>.desktop
|
2008-11-04 00:08:39 +01:00
|
|
|
*
|
|
|
|
* If a wallpaper plugin provides more than on mode (e.g. Single Image, Wallpaper)
|
|
|
|
* it should include a Actions= entry in the .desktop file, listing the possible
|
|
|
|
* actions. An actions group should be included to provide for translatable names.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PLASMA_EXPORT Wallpaper : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect)
|
|
|
|
Q_PROPERTY(QString name READ name)
|
|
|
|
Q_PROPERTY(QString pluginName READ pluginName)
|
|
|
|
Q_PROPERTY(QString icon READ icon)
|
|
|
|
Q_PROPERTY(KServiceAction renderingMode READ renderingMode)
|
|
|
|
Q_PROPERTY(QList<KServiceAction> listRenderingModes READ listRenderingModes)
|
2009-05-13 18:13:56 +02:00
|
|
|
Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache)
|
2010-03-05 01:54:30 +01:00
|
|
|
Q_PROPERTY(bool previewing READ isPreviewing WRITE setPreviewing)
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
public:
|
2009-04-02 08:31:37 +02:00
|
|
|
/**
|
|
|
|
* Various resize modes supported by the built in image renderer
|
|
|
|
*/
|
|
|
|
enum ResizeMethod {
|
|
|
|
ScaledResize /**< Scales the image to fit the full area*/,
|
|
|
|
CenteredResize /**< Centers the image within the area */,
|
|
|
|
ScaledAndCroppedResize /**< Scales and crops the image, preserving the aspect ratio */,
|
|
|
|
TiledResize /**< Tiles the image to fill the area */,
|
|
|
|
CenterTiledResize /**< Tiles the image to fill the area, starting with a centered tile */,
|
|
|
|
MaxpectResize /**< Best fit resize */
|
|
|
|
};
|
|
|
|
Q_ENUMS(ResizeMethod)
|
|
|
|
|
2009-04-07 07:45:20 +02:00
|
|
|
/**
|
|
|
|
* Default constructor for an empty or null wallpaper
|
|
|
|
*/
|
|
|
|
explicit Wallpaper(QObject * parent = 0);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
~Wallpaper();
|
|
|
|
|
2011-01-20 20:50:11 +01:00
|
|
|
/**
|
|
|
|
* Sets the urls for the wallpaper
|
|
|
|
* @param urls Urls of the selected images
|
|
|
|
* @since 4.7
|
|
|
|
*/
|
|
|
|
void setUrls(const KUrl::List &urls);
|
|
|
|
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
|
|
|
* Returns a list of all known wallpapers.
|
|
|
|
*
|
2009-09-03 22:40:22 +02:00
|
|
|
* @arg formFactor the format of the wallpaper being search for (e.g. desktop)
|
2008-11-04 00:08:39 +01:00
|
|
|
* @return list of wallpapers
|
|
|
|
**/
|
|
|
|
static KPluginInfo::List listWallpaperInfo(const QString &formFactor = QString());
|
|
|
|
|
2009-09-03 22:40:22 +02:00
|
|
|
/**
|
2011-05-06 12:23:42 +02:00
|
|
|
* Returns a list of all known wallpapers that can accept the given MimeType
|
|
|
|
* @arg mimeType the mimeType to search for
|
2009-09-03 22:40:22 +02:00
|
|
|
* @arg formFactor the format of the wallpaper being search for (e.g. desktop)
|
|
|
|
* @return list of wallpapers
|
|
|
|
*/
|
2011-05-06 12:23:42 +02:00
|
|
|
static KPluginInfo::List listWallpaperInfoForMimetype(const QString &mimeType,
|
2009-09-03 22:40:22 +02:00
|
|
|
const QString &formFactor = QString());
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
2009-05-27 02:14:48 +02:00
|
|
|
* Attempts to load a wallpaper
|
2008-11-04 00:08:39 +01:00
|
|
|
*
|
|
|
|
* Returns a pointer to the wallpaper if successful.
|
|
|
|
* The caller takes responsibility for the wallpaper, including
|
|
|
|
* deleting it when no longer needed.
|
|
|
|
*
|
|
|
|
* @param name the plugin name, as returned by KPluginInfo::pluginName()
|
|
|
|
* @param args to send the wallpaper extra arguments
|
|
|
|
* @return a pointer to the loaded wallpaper, or 0 on load failure
|
|
|
|
**/
|
|
|
|
static Wallpaper *load(const QString &name, const QVariantList &args = QVariantList());
|
|
|
|
|
|
|
|
/**
|
2009-05-27 02:14:48 +02:00
|
|
|
* Attempts to load a wallpaper
|
2008-11-04 00:08:39 +01:00
|
|
|
*
|
|
|
|
* Returns a pointer to the wallpaper if successful.
|
|
|
|
* The caller takes responsibility for the wallpaper, including
|
|
|
|
* deleting it when no longer needed.
|
|
|
|
*
|
|
|
|
* @param info KPluginInfo object for the desired wallpaper
|
|
|
|
* @param args to send the wallpaper extra arguments
|
|
|
|
* @return a pointer to the loaded wallpaper, or 0 on load failure
|
|
|
|
**/
|
|
|
|
static Wallpaper *load(const KPluginInfo &info, const QVariantList &args = QVariantList());
|
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
/**
|
2009-04-07 07:45:20 +02:00
|
|
|
* Returns the Package specialization for wallpapers. May be queried for 'preferred'
|
|
|
|
* which will return the preferred wallpaper image path given the associated Wallpaper
|
|
|
|
* object, if any.
|
|
|
|
*
|
|
|
|
* @param paper the Wallpaper object to associated the PackageStructure with,
|
|
|
|
* which will then use the Wallpaper object to define things such as
|
|
|
|
* default size and resize methods.
|
2009-04-02 08:31:37 +02:00
|
|
|
*/
|
2009-04-07 07:45:20 +02:00
|
|
|
static PackageStructure::Ptr packageStructure(Wallpaper *paper = 0);
|
2009-04-02 08:31:37 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
|
|
|
* Returns the user-visible name for the wallpaper, as specified in the
|
|
|
|
* .desktop file.
|
|
|
|
*
|
|
|
|
* @return the user-visible name for the wallpaper.
|
|
|
|
**/
|
|
|
|
QString name() const;
|
|
|
|
|
2009-10-29 06:54:11 +01:00
|
|
|
/**
|
|
|
|
* Accessor for the associated Package object if any.
|
|
|
|
*
|
|
|
|
* @return the Package object, or 0 if none
|
|
|
|
**/
|
|
|
|
const Package *package() const;
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
/**
|
|
|
|
* Returns the plugin name for the wallpaper
|
|
|
|
*/
|
|
|
|
QString pluginName() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the icon related to this wallpaper
|
|
|
|
**/
|
|
|
|
QString icon() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the currently active rendering mode
|
|
|
|
*/
|
|
|
|
KServiceAction renderingMode() const;
|
|
|
|
|
2011-01-26 21:08:35 +01:00
|
|
|
/**
|
|
|
|
* @return true if the mimetype is supported by this wallpaper and
|
|
|
|
* can be used in renderering. Uses the MimeType= entry from
|
|
|
|
* the .desktop file, and can include mimetypes that may not be
|
|
|
|
* suitable for drag-and-drop purposes.
|
|
|
|
* @since 4.7
|
|
|
|
*/
|
|
|
|
bool supportsMimetype(const QString &mimetype) const;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the rendering mode for this wallpaper.
|
|
|
|
* @param mode One of the modes supported by the plugin,
|
|
|
|
* or an empty string for the default mode.
|
|
|
|
*/
|
|
|
|
void setRenderingMode(const QString &mode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns modes the wallpaper has, as specified in the
|
|
|
|
* .desktop file.
|
|
|
|
*/
|
|
|
|
QList<KServiceAction> listRenderingModes() const;
|
|
|
|
|
|
|
|
/**
|
2009-04-13 19:33:23 +02:00
|
|
|
* @return true if initialized (usually by calling restore), false otherwise
|
2008-11-04 00:08:39 +01:00
|
|
|
*/
|
|
|
|
bool isInitialized() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns bounding rectangle
|
|
|
|
*/
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets bounding rectangle
|
|
|
|
*/
|
|
|
|
void setBoundingRect(const QRectF &boundingRect);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called when the wallpaper should be painted.
|
|
|
|
*
|
|
|
|
* @param painter the QPainter to use to do the painting
|
|
|
|
* @param exposedRect the rect to paint within
|
|
|
|
**/
|
|
|
|
virtual void paint(QPainter *painter, const QRectF &exposedRect) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method should be called once the wallpaper is loaded or mode is changed.
|
|
|
|
* @param config Config group to load settings
|
|
|
|
* @see init
|
|
|
|
**/
|
|
|
|
void restore(const KConfigGroup &config);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called when settings need to be saved.
|
|
|
|
* @param config Config group to save settings
|
|
|
|
**/
|
|
|
|
virtual void save(KConfigGroup &config);
|
|
|
|
|
|
|
|
/**
|
2009-06-13 23:49:15 +02:00
|
|
|
* Returns a widget that can be used to configure the options (if any)
|
|
|
|
* associated with this wallpaper. It will be deleted by the caller
|
|
|
|
* when it complete. The default implementation returns a null pointer.
|
|
|
|
*
|
2009-04-16 00:30:15 +02:00
|
|
|
* To signal that settings have changed connect to
|
|
|
|
* settingsChanged(bool modified) in @p parent.
|
2009-06-13 23:49:15 +02:00
|
|
|
*
|
2009-04-16 00:30:15 +02:00
|
|
|
* @code connect(this, SIGNAL(settingsChanged(bool), parent, SLOT(settingsChanged(bool)))
|
|
|
|
* @endcode
|
2009-06-13 23:49:15 +02:00
|
|
|
*
|
2009-04-16 00:30:15 +02:00
|
|
|
* Emit settingsChanged(true) when the settings are changed and false when the original state is restored.
|
2009-06-13 23:49:15 +02:00
|
|
|
*
|
|
|
|
* Implementation detail note: for best visual results, use a QGridLayout with two columns,
|
|
|
|
* with the option labels in column 0
|
2008-11-04 00:08:39 +01:00
|
|
|
*/
|
|
|
|
virtual QWidget *createConfigurationInterface(QWidget *parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mouse move event. To prevent further propagation of the event,
|
|
|
|
* the event must be accepted.
|
|
|
|
*
|
|
|
|
* @param event the mouse event object
|
|
|
|
*/
|
|
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mouse press event. To prevent further propagation of the even,
|
|
|
|
* and to receive mouseMoveEvents, the event must be accepted.
|
|
|
|
*
|
|
|
|
* @param event the mouse event object
|
|
|
|
*/
|
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mouse release event. To prevent further propagation of the event,
|
|
|
|
* the event must be accepted.
|
|
|
|
*
|
|
|
|
* @param event the mouse event object
|
|
|
|
*/
|
|
|
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mouse wheel event. To prevent further propagation of the event,
|
|
|
|
* the event must be accepted.
|
|
|
|
*
|
|
|
|
* @param event the wheel event object
|
|
|
|
*/
|
|
|
|
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
|
|
|
|
|
2009-04-01 01:51:52 +02:00
|
|
|
/**
|
|
|
|
* Loads the given DataEngine
|
|
|
|
*
|
|
|
|
* 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
|
2009-04-01 02:04:57 +02:00
|
|
|
*
|
|
|
|
* @since 4.3
|
2009-04-01 01:51:52 +02:00
|
|
|
*/
|
|
|
|
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
|
|
|
|
|
2009-04-02 06:15:50 +02:00
|
|
|
/**
|
|
|
|
* @return true if the wallpaper currently needs to be configured,
|
|
|
|
* otherwise, false
|
2009-04-02 08:31:37 +02:00
|
|
|
* @since 4.3
|
2009-04-02 06:15:50 +02:00
|
|
|
*/
|
|
|
|
bool configurationRequired() const;
|
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
/**
|
|
|
|
* @return true if disk caching is turned on.
|
|
|
|
* @since 4.3
|
|
|
|
*/
|
2009-05-13 18:13:56 +02:00
|
|
|
bool isUsingRenderingCache() const;
|
2009-04-02 08:31:37 +02:00
|
|
|
|
2009-04-07 09:18:58 +02:00
|
|
|
/**
|
|
|
|
* Allows one to set rendering hints that may differ from the actualities of the
|
2009-10-29 06:54:11 +01:00
|
|
|
* Wallpaper's current state, allowing for better selection of papers from packages,
|
2009-04-07 09:18:58 +02:00
|
|
|
* for instance.
|
|
|
|
*
|
|
|
|
* @arg resizeMethod The resize method to assume will be used for future wallpaper
|
|
|
|
* scaling; may later be changed by calls to render()
|
|
|
|
*
|
|
|
|
* @since 4.3
|
|
|
|
*/
|
|
|
|
void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod);
|
|
|
|
|
2009-10-29 06:54:11 +01:00
|
|
|
/**
|
2009-04-07 09:18:58 +02:00
|
|
|
* Allows one to set rendering hints that may differ from the actualities of the
|
2009-10-29 06:54:11 +01:00
|
|
|
* Wallpaper's current state, allowing for better selection of papers from packages,
|
2009-04-07 09:18:58 +02:00
|
|
|
* for instance.
|
|
|
|
*
|
|
|
|
* @arg targetSize The size to assume will be used for future wallpaper scaling
|
|
|
|
*
|
|
|
|
* @since 4.3
|
|
|
|
*/
|
|
|
|
void setTargetSizeHint(const QSizeF &targetSize);
|
|
|
|
|
2009-10-12 15:01:51 +02:00
|
|
|
/**
|
|
|
|
* Returns a list of wallpaper contextual actions (nothing by default)
|
|
|
|
*/
|
|
|
|
QList<QAction*> contextualActions() const;
|
|
|
|
|
2010-03-05 01:54:30 +01:00
|
|
|
/**
|
|
|
|
* @return true if in preview mode, such as in a configuation dialog
|
|
|
|
* @since 4.5
|
|
|
|
*/
|
|
|
|
bool isPreviewing() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Puts the wallpaper into preview mode
|
2010-03-05 02:25:58 +01:00
|
|
|
* @since 4.5
|
2010-03-05 01:54:30 +01:00
|
|
|
*/
|
|
|
|
void setPreviewing(bool previewing);
|
|
|
|
|
2010-08-12 21:51:39 +02:00
|
|
|
/**
|
|
|
|
* @return true if the wallpaper needs a live preview in the configuration UI
|
|
|
|
* @since 4.6
|
|
|
|
*/
|
|
|
|
bool needsPreviewDuringConfiguration() const;
|
|
|
|
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* This signal indicates that wallpaper needs to be repainted.
|
|
|
|
*/
|
|
|
|
void update(const QRectF &exposedArea);
|
|
|
|
|
2009-04-02 06:15:50 +02:00
|
|
|
/**
|
|
|
|
* Emitted when the user wants to configure/change the wallpaper.
|
2009-04-02 08:31:37 +02:00
|
|
|
* @since 4.3
|
2009-04-02 06:15:50 +02:00
|
|
|
*/
|
|
|
|
void configureRequested();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Emitted when the state of the wallpaper requiring configuration
|
|
|
|
* changes.
|
2009-04-02 08:31:37 +02:00
|
|
|
* @since 4.3
|
2009-04-02 06:15:50 +02:00
|
|
|
*/
|
|
|
|
void configurationRequired(bool needsConfig);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Emitted when the configuration of the wallpaper needs to be saved
|
|
|
|
* to disk.
|
2009-04-02 08:31:37 +02:00
|
|
|
* @since 4.3
|
2009-04-02 06:15:50 +02:00
|
|
|
*/
|
|
|
|
void configNeedsSaving();
|
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
/**
|
|
|
|
* Emitted when a wallpaper image render is completed.
|
|
|
|
* @since 4.3
|
|
|
|
*/
|
2009-04-02 08:48:30 +02:00
|
|
|
void renderCompleted(const QImage &image);
|
2009-04-02 08:31:37 +02:00
|
|
|
|
2009-09-04 01:22:48 +02:00
|
|
|
/**
|
|
|
|
* Emitted when a URL matching X-Plasma-DropMimeTypes is dropped on the wallpaper
|
|
|
|
*
|
|
|
|
* @arg url the URL of the dropped file
|
|
|
|
* @since 4.4
|
|
|
|
*/
|
2011-01-30 21:04:43 +01:00
|
|
|
KDE_DEPRECATED void urlDropped(const KUrl &url);
|
2009-09-04 01:22:48 +02:00
|
|
|
|
2009-04-07 09:18:58 +02:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
void renderHintsChanged();
|
|
|
|
|
2011-01-20 20:50:11 +01:00
|
|
|
protected Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* This method is invoked by setUrls(KUrl::List)
|
|
|
|
* Can be Overriden by Plugins which want to support setting Image URLs
|
|
|
|
* Will be changed to virtual method in libplasma2/KDE5
|
|
|
|
* @since 4.7
|
|
|
|
*/
|
|
|
|
void addUrls(const KUrl::List &urls);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* This constructor is to be used with the plugin loading systems
|
|
|
|
* found in KPluginInfo and KService. The argument list is expected
|
|
|
|
* to have one element: the KService service ID for the desktop entry.
|
|
|
|
*
|
|
|
|
* @param parent a QObject parent; you probably want to pass in 0
|
|
|
|
* @param args a list of strings containing one entry: the service id
|
|
|
|
*/
|
|
|
|
Wallpaper(QObject *parent, const QVariantList &args);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called once the wallpaper is loaded or mode is changed.
|
2009-01-10 01:08:31 +01:00
|
|
|
*
|
2009-04-08 17:06:47 +02:00
|
|
|
* The mode can be retrieved using the renderingMode() method.
|
2009-01-10 01:08:31 +01:00
|
|
|
*
|
2008-11-04 00:08:39 +01:00
|
|
|
* @param config Config group to load settings
|
|
|
|
**/
|
|
|
|
virtual void init(const KConfigGroup &config);
|
|
|
|
|
2009-04-02 06:15:50 +02:00
|
|
|
/**
|
|
|
|
* When the wallpaper needs to be configured before being usable, this
|
|
|
|
* method can be called to denote that action is required
|
|
|
|
*
|
|
|
|
* @param needsConfiguring true if the applet needs to be configured,
|
|
|
|
* or false if it doesn't
|
|
|
|
* @param reason a translated message for the user explaining that the
|
|
|
|
* applet needs configuring; this should note what needs
|
|
|
|
* to be configured
|
2009-04-02 08:31:37 +02:00
|
|
|
* @since 4.3
|
2009-04-02 06:15:50 +02:00
|
|
|
*/
|
|
|
|
void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
|
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
/**
|
|
|
|
* Renders the wallpaper asyncronously with the given parameters. When the rendering is
|
2009-04-02 08:48:30 +02:00
|
|
|
* complete, the renderCompleted signal is emitted.
|
2009-04-02 08:31:37 +02:00
|
|
|
*
|
|
|
|
* @param sourceImagePath the path to the image file on disk. Common image formats such as
|
|
|
|
* PNG, JPEG and SVG are supported
|
|
|
|
* @param size the size to render the image as
|
|
|
|
* @param resizeMethod the method to use when resizing the image to fit size, @see
|
|
|
|
* ResizeMethod
|
|
|
|
* @param color the color to use to pad the rendered image if it doesn't take up the
|
|
|
|
* entire size with the given ResizeMethod
|
|
|
|
* @since 4.3
|
|
|
|
*/
|
|
|
|
void render(const QString &sourceImagePath, const QSize &size,
|
|
|
|
Wallpaper::ResizeMethod resizeMethod = ScaledResize,
|
|
|
|
const QColor &color = QColor(0, 0, 0));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether or not to cache on disk the results of calls to render. If the wallpaper
|
|
|
|
* changes often or is innexpensive to render, then it's probably best not to cache them.
|
2009-10-29 06:54:11 +01:00
|
|
|
*
|
2009-04-02 08:31:37 +02:00
|
|
|
* The default is not to cache.
|
|
|
|
*
|
|
|
|
* @see render
|
|
|
|
* @param useCache true to cache rendered papers on disk, false not to cache
|
|
|
|
* @since 4.3
|
|
|
|
*/
|
2009-05-13 18:13:56 +02:00
|
|
|
void setUsingRenderingCache(bool useCache);
|
2009-05-13 18:03:59 +02:00
|
|
|
|
2009-04-10 21:49:33 +02:00
|
|
|
/**
|
|
|
|
* Tries to load pixmap with the specified key from cache.
|
|
|
|
*
|
|
|
|
* @param key the name to use in the cache for this image
|
|
|
|
* @param image the image object to populate with the resulting data if found
|
|
|
|
* @param lastModified if non-zero, the time stamp is also checked on the file,
|
|
|
|
* and must be newer than the timestamp to be loaded
|
|
|
|
*
|
|
|
|
* @return true when pixmap was found and loaded from cache, false otherwise
|
|
|
|
* @since 4.3
|
|
|
|
**/
|
|
|
|
bool findInCache(const QString &key, QImage &image, unsigned int lastModified = 0);
|
|
|
|
|
|
|
|
/**
|
2009-05-13 18:13:56 +02:00
|
|
|
* Insert specified pixmap into the cache if usingRenderingCache.
|
2009-04-10 21:49:33 +02:00
|
|
|
* If the cache already contains pixmap with the specified key then it is
|
|
|
|
* overwritten.
|
|
|
|
*
|
|
|
|
* @param key the name use in the cache for this image; if the image is specific
|
|
|
|
* to this wallpaper plugin, consider including the name() as part of
|
|
|
|
* the cache key to avoid collisions with other plugins.
|
2009-04-10 21:52:16 +02:00
|
|
|
* @param image the image to store in the cache; passing in a null image will cause
|
|
|
|
* the cached image to be removed from the cache
|
2009-04-10 21:49:33 +02:00
|
|
|
*
|
|
|
|
* @since 4.3
|
|
|
|
**/
|
|
|
|
void insertIntoCache(const QString& key, const QImage &image);
|
|
|
|
|
2009-10-12 15:01:51 +02:00
|
|
|
/**
|
|
|
|
* Sets the contextual actions for this wallpaper.
|
|
|
|
*
|
|
|
|
* @param actions A list of contextual actions for this wallpaper
|
2009-12-08 16:52:54 +01:00
|
|
|
*
|
|
|
|
* @since 4.4
|
2009-10-12 15:01:51 +02:00
|
|
|
**/
|
|
|
|
void setContextualActions(const QList<QAction*> &actions);
|
|
|
|
|
2010-08-12 21:51:39 +02:00
|
|
|
/**
|
|
|
|
* Sets whether the configuration user interface of the wallpaper should have
|
|
|
|
* a live preview rendered by a Wallpaper instance. note: this is just an
|
|
|
|
* hint, the configuration user interface can choose to ignore it
|
|
|
|
*
|
|
|
|
* @param preview true if a preview should be shown
|
|
|
|
* @since 4.6
|
|
|
|
*/
|
|
|
|
void setPreviewDuringConfiguration(const bool preview);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
private:
|
2011-04-30 13:29:38 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void newRenderCompleted(const WallpaperRenderRequest &request,
|
|
|
|
const QImage &image))
|
2009-10-29 06:54:11 +01:00
|
|
|
Q_PRIVATE_SLOT(d, void initScript())
|
2009-04-02 08:31:37 +02:00
|
|
|
|
2009-04-07 07:45:20 +02:00
|
|
|
friend class WallpaperPackage;
|
2009-04-02 08:31:37 +02:00
|
|
|
friend class WallpaperPrivate;
|
2009-10-29 06:54:11 +01:00
|
|
|
friend class WallpaperScript;
|
|
|
|
friend class WallpaperWithPaint;
|
2009-09-04 01:22:48 +02:00
|
|
|
friend class ContainmentPrivate;
|
2008-11-04 00:08:39 +01:00
|
|
|
WallpaperPrivate *const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
/**
|
2009-05-27 02:14:48 +02:00
|
|
|
* Register a wallpaper when it is contained in a loadable module
|
2008-11-04 00:08:39 +01:00
|
|
|
*/
|
|
|
|
#define K_EXPORT_PLASMA_WALLPAPER(libname, classname) \
|
|
|
|
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
|
|
|
K_EXPORT_PLUGIN(factory("plasma_wallpaper_" #libname)) \
|
|
|
|
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|