remove wallpaper files

This commit is contained in:
Marco Martin 2012-11-21 15:30:33 +01:00
parent e15217f645
commit 9ad97e680a
12 changed files with 0 additions and 1692 deletions

View File

@ -60,7 +60,6 @@
#include "private/applet_p.h"
#include "private/containmentactionspluginsconfig_p.h"
#include "private/wallpaper_p.h"
#include "plasma/plasma.h"

View File

@ -1,85 +0,0 @@
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=Plasma/Wallpaper
Comment=Plasma wallpaper
Comment[ar]=خلفية شاشة بلازما
Comment[as]=Plasma wallpaper
Comment[ast]=Fondu d'escritoriu de Plasma
Comment[be@latin]=Špalery Plasma
Comment[bg]=Тапет за Plasma
Comment[bn]=
Comment[bn_IN]=Plasma -
Comment[bs]=Plazma tapet
Comment[ca]=Fons d'escriptori del Plasma
Comment[ca@valencia]=Fons d'escriptori del Plasma
Comment[cs]=Tapeta Plasma
Comment[da]=Plasma-baggrundsbillede
Comment[de]=Plasma-Hintergrundbild
Comment[el]=Ταπετσαρία plasma
Comment[en_GB]=Plasma wallpaper
Comment[es]=Fondo de escritorio para Plasma
Comment[et]=Plasma taustapilt
Comment[eu]=Plasma horma papera
Comment[fi]=Plasma-taustakuva
Comment[fr]=Fond d'écran Plasma
Comment[fy]=Plasma eftergrûnôfbylding
Comment[ga]=Cúlbhrat Plasma
Comment[gl]=Fondo de escritorio do Plasma
Comment[gu]=
Comment[he]=תמונת רקע של Plasma
Comment[hi]=
Comment[hne]=
Comment[hr]=Plasmina pozadinska slika
Comment[hsb]=Tapeta za Plasma
Comment[hu]=Plasma háttérkép
Comment[ia]=Tapete de papiro de Plasma
Comment[id]=Gambar belakang Plasma
Comment[is]=Plasma veggfóður
Comment[it]=Sfondo Plasma
Comment[ja]=Plasma
Comment[kk]=Plasma тұсқағазы
Comment[km]=
Comment[kn]= ಿ ಿ ( )
Comment[ko]=Plasma
Comment[ku]=Wêne-rûerdê Plasma
Comment[lt]=Plasma apmušalas
Comment[lv]=Plasma ekrāntapete
Comment[mai]=
Comment[ml]= ി
Comment[nb]=Plasma tapet
Comment[nds]=Plasma-Achtergrundbild
Comment[nl]=Plasma-bureaubladachtergrond
Comment[nn]=Plasmabakgrunn
Comment[pa]=
Comment[pl]=Tapeta Plazmy
Comment[pt]=Papel de parede do Plasma
Comment[pt_BR]=Papel de parede do Plasma
Comment[ro]=Fundal Plasma
Comment[ru]=Обои Plasma
Comment[se]=Plasma-duogášgovva
Comment[si]=Plasma
Comment[sk]=Tapeta Plasma
Comment[sl]=Tapeta za Plasmo
Comment[sq]=Tapetat plazma
Comment[sr]=Плазма тапет
Comment[sr@ijekavian]=Плазма тапет
Comment[sr@ijekavianlatin]=Plasma tapet
Comment[sr@latin]=Plasma tapet
Comment[sv]=Plasma skrivbordsunderlägg
Comment[ta]=ி ிிி
Comment[tg]=Тасвири заминаи Plasma
Comment[th]=
Comment[tr]=Plasma duvar kağıdı
Comment[tt]=Плазма обое
Comment[ug]=Plasma تام قەغىزى
Comment[uk]=Тло стільниці Плазми
Comment[vi]=Hình nn Plasma
Comment[wa]=Tapisreye di Plasma
Comment[x-test]=xxPlasma wallpaperxx
Comment[zh_CN]=Plasma
Comment[zh_TW]=Plasma
[PropertyDef::X-Plasma-FormFactors]
Type=QStringList

View File

@ -48,14 +48,12 @@
#include "corona.h"
#include "pluginloader.h"
#include "svg.h"
#include "wallpaper.h"
#include "remote/accessappletjob.h"
#include "remote/accessmanager.h"
#include "private/applet_p.h"
#include "private/containmentactionspluginsconfig_p.h"
#include "private/wallpaper_p.h"
namespace Plasma

View File

@ -54,7 +54,6 @@
#include "private/applet_p.h"
#include "private/containmentactionspluginsconfig_p.h"
#include "private/wallpaper_p.h"
namespace Plasma

View File

@ -31,7 +31,6 @@
#include <kmessagebox.h>
#include "kdeclarative.h"
#include "private/wallpaper_p.h"
#include "package.h"
#include "config-plasma.h"

View File

@ -1,70 +0,0 @@
/*
* 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_WALLPAPERPRIVATE_H
#define PLASMA_WALLPAPERPRIVATE_H
#include <QtCore/QQueue>
#include <QtCore/QRunnable>
#include <QtCore/QWeakPointer>
#include "plasma/dataengineconsumer.h"
#include "plasma/scripting/wallpaperscript.h"
#include "plasma/private/wallpaperrenderthread_p.h"
namespace Plasma
{
class WallpaperPrivate : public DataEngineConsumer
{
public:
WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper);
QString cachePath(const QString &key) const;
QString cacheKey(const QString &sourceImagePath, const QSize &size,
int resizeMethod, const QColor &color) const;
void initScript();
void setupScriptSupport();
Wallpaper *q;
KPluginInfo wallpaperDescription;
Package *package;
QRectF boundingRect;
KServiceAction mode;
int renderToken;
Wallpaper::ResizeMethod lastResizeMethod;
QSizeF targetSize;
WallpaperScript *script;
QList<QAction*> contextActions;
QString wallpaperPath;
bool cacheRendering : 1;
bool initialized : 1;
bool needsConfig : 1;
bool scriptInitialized : 1;
bool previewing : 1;
bool needsPreviewDuringConfiguration : 1;
};
} // namespace Plasma
#endif

View File

@ -1,277 +0,0 @@
/*
* Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
* Copyright (c) 2009 Aaron Seigo <aseigo@kde.org>
*
* 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.
*/
#include "plasma/private/wallpaperrenderthread_p.h"
#include <QCoreApplication>
#include <QPainter>
#include <QFile>
#include <QSvgRenderer>
#include "config-plasma.h"
#if !PLASMA_NO_SOLID
#include <solid/device.h>
#include <solid/deviceinterface.h>
#endif
#include <kdebug.h>
namespace Plasma
{
int WallpaperRenderRequest::s_token = 0;
int WallpaperRenderThread::s_rendererCount = 0;
QQueue<WallpaperRenderRequest> WallpaperRenderThread::s_renderQueue;
WallpaperRenderThread::WallpaperRenderThread(const WallpaperRenderRequest &request, QObject *parent)
: QThread(parent),
m_request(request),
m_abort(false)
{
qRegisterMetaType<WallpaperRenderRequest>("WallpaperRenderRequest");
if (!request.requester) {
deleteLater();
return;
}
++s_rendererCount;
connect(this, SIGNAL(done(WallpaperRenderRequest,QImage)),
request.requester.data(), SLOT(newRenderCompleted(WallpaperRenderRequest,QImage)));
}
WallpaperRenderThread::~WallpaperRenderThread()
{
#ifndef NDEBUG
kDebug() << "rendering done";
#endif
m_abort = true;
wait();
--s_rendererCount;
checkQueue();
}
void WallpaperRenderThread::render(const WallpaperRenderRequest &request)
{
QObject *requester = request.requester.data();
if (!requester) {
return;
}
// remove all dead requests and requests previously made for the same parent
QMutableListIterator<WallpaperRenderRequest> it(s_renderQueue);
while (it.hasNext()) {
const WallpaperRenderRequest &request = it.next();
if (!request.requester || request.requester.data() == requester) {
it.remove();
}
}
s_renderQueue.append(request);
checkQueue();
}
void WallpaperRenderThread::checkQueue()
{
if (s_renderQueue.isEmpty()) {
return;
}
if (QCoreApplication::closingDown()) {
s_renderQueue.clear();
return;
}
#if !PLASMA_NO_SOLID
const int numProcs = qMax(1, Solid::Device::listFromType(Solid::DeviceInterface::Processor).count());
#else
const int numProcs = 1;
#endif
#ifndef NDEBUG
kDebug() << "checking rendering against" << s_rendererCount << numProcs;
#endif
if (s_rendererCount < numProcs) {
WallpaperRenderThread *renderThread = new WallpaperRenderThread(s_renderQueue.dequeue());
renderThread->start();
}
}
void WallpaperRenderThread::run()
{
#ifndef NDEBUG
kDebug() << "rendering wallpaper" << m_request.file;
#endif
QImage result(m_request.size, QImage::Format_ARGB32_Premultiplied);
result.fill(m_request.color.rgba());
if (m_request.file.isEmpty() && m_request.providedImage.isNull() && !QFile::exists(m_request.file)) {
if (!m_abort) {
emit done(m_request, result);
}
#ifndef NDEBUG
kDebug() << "wrong request or file does not exist";
#endif
deleteLater();
return;
}
QPoint pos(0, 0);
//const float ratio = qMax(float(1), m_request.size.width() / float(m_request.size.height()));
const bool scalable = m_request.file.endsWith(QLatin1String("svg")) || m_request.file.endsWith(QLatin1String("svgz"));
bool tiled = false;
QSize scaledSize;
QImage img;
// set image size
QSize imgSize(1, 1);
if (!m_request.providedImage.isNull()) {
img = m_request.providedImage;
kDebug() << "going to resize the img" << img.size();
imgSize = imgSize.expandedTo(img.size());
} else if (scalable) {
// scalable: image can be of any size
imgSize = imgSize.expandedTo(m_request.size);
} else {
// otherwise, use the natural size of the loaded image
img = QImage(m_request.file);
imgSize = imgSize.expandedTo(img.size());
//kDebug() << "loaded with" << imgSize << ratio;
}
// set render parameters according to resize mode
switch (m_request.resizeMethod)
{
case Wallpaper::ScaledResize:
scaledSize = m_request.size;
break;
case Wallpaper::CenteredResize:
scaledSize = imgSize;
pos = QPoint((m_request.size.width() - scaledSize.width()) / 2,
(m_request.size.height() - scaledSize.height()) / 2);
//If the picture is bigger than the screen, shrink it
if (m_request.size.width() < imgSize.width() && imgSize.width() > imgSize.height()) {
int width = m_request.size.width();
int height = width * scaledSize.height() / imgSize.width();
scaledSize = QSize(width, height);
pos = QPoint((m_request.size.width() - scaledSize.width()) / 2,
(m_request.size.height() - scaledSize.height()) / 2);
} else if (m_request.size.height() < imgSize.height()) {
int height = m_request.size.height();
int width = height * imgSize.width() / imgSize.height();
scaledSize = QSize(width, height);
pos = QPoint((m_request.size.width() - scaledSize.width()) / 2,
(m_request.size.height() - scaledSize.height()) / 2);
}
break;
case Wallpaper::MaxpectResize: {
float xratio = (float) m_request.size.width() / imgSize.width();
float yratio = (float) m_request.size.height() / imgSize.height();
if (xratio > yratio) {
int height = m_request.size.height();
int width = height * imgSize.width() / imgSize.height();
scaledSize = QSize(width, height);
} else {
int width = m_request.size.width();
int height = width * imgSize.height() / imgSize.width();
scaledSize = QSize(width, height);
}
pos = QPoint((m_request.size.width() - scaledSize.width()) / 2,
(m_request.size.height() - scaledSize.height()) / 2);
break;
}
case Wallpaper::ScaledAndCroppedResize: {
float xratio = (float) m_request.size.width() / imgSize.width();
float yratio = (float) m_request.size.height() / imgSize.height();
if (xratio > yratio) {
int width = m_request.size.width();
int height = width * imgSize.height() / imgSize.width();
scaledSize = QSize(width, height);
} else {
int height = m_request.size.height();
int width = height * imgSize.width() / imgSize.height();
scaledSize = QSize(width, height);
}
pos = QPoint((m_request.size.width() - scaledSize.width()) / 2,
(m_request.size.height() - scaledSize.height()) / 2);
break;
}
case Wallpaper::TiledResize:
scaledSize = imgSize;
tiled = true;
break;
case Wallpaper::CenterTiledResize:
scaledSize = imgSize;
pos = QPoint(-scaledSize.width() + ((m_request.size.width() - scaledSize.width()) / 2) % scaledSize.width(),
-scaledSize.height() + ((m_request.size.height() - scaledSize.height()) / 2) % scaledSize.height());
tiled = true;
break;
}
QPainter p(&result);
//kDebug() << token << scalable << scaledSize << imgSize;
if (scalable) {
// tiling is ignored for scalable wallpapers
QSvgRenderer svg(m_request.file);
if (m_abort) {
deleteLater();
return;
}
svg.render(&p);
} else {
if (scaledSize != imgSize) {
img = img.scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
if (m_abort) {
deleteLater();
return;
}
if (tiled) {
for (int x = pos.x(); x < m_request.size.width(); x += scaledSize.width()) {
for (int y = pos.y(); y < m_request.size.height(); y += scaledSize.height()) {
p.drawImage(QPoint(x, y), img);
if (m_abort) {
deleteLater();
return;
}
}
}
} else {
p.drawImage(pos, img);
}
}
// signal we're done
if (!m_abort) {
emit done(m_request, result);
}
deleteLater();
}
} // namespace Plasma
#include "moc_wallpaperrenderthread_p.cpp"

View File

@ -1,83 +0,0 @@
/*
* Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
* Copyright (c) 2009 Aaron Seigo <aseigo@kde.org>
*
* 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_WALLPAPERRENDERTHREAD_P_H
#define PLASMA_WALLPAPERRENDERTHREAD_P_H
#include <QColor>
#include <QImage>
#include <QMutex>
#include <QQueue>
#include <QThread>
#include <QWaitCondition>
#include "plasma/wallpaper.h"
namespace Plasma
{
class WallpaperRenderRequest
{
public:
WallpaperRenderRequest()
: token(++s_token)
{
}
QWeakPointer<QObject> requester;
QImage providedImage;
QString file;
QSize size;
Wallpaper::ResizeMethod resizeMethod;
QColor color;
int token;
static int s_token;
};
class WallpaperRenderThread : public QThread
{
Q_OBJECT
public:
WallpaperRenderThread(const WallpaperRenderRequest &request, QObject *parent = 0);
virtual ~WallpaperRenderThread();
static void render(const WallpaperRenderRequest &request);
Q_SIGNALS:
void done(const WallpaperRenderRequest &request, const QImage &image);
protected:
virtual void run();
private:
static void checkQueue();
WallpaperRenderRequest m_request;
bool m_abort;
static int s_rendererCount;
static QQueue<WallpaperRenderRequest> s_renderQueue;
};
} // namespace Plasma
Q_DECLARE_METATYPE(Plasma::WallpaperRenderRequest)
#endif // PLASMA_WALLPAPERRENDERTHREAD_P_H

View File

@ -1,169 +0,0 @@
/*
* Copyright 2009 by Aaron Seigo <aseigo@kde.org>
* Copyright 2009 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.
*/
#include "wallpaperscript.h"
#include "private/wallpaper_p.h"
#include "package.h"
namespace Plasma
{
class WallpaperScriptPrivate
{
public:
Wallpaper *wallpaper;
};
WallpaperScript::WallpaperScript(QObject *parent)
: ScriptEngine(parent),
d(new WallpaperScriptPrivate)
{
}
WallpaperScript::~WallpaperScript()
{
delete d;
}
void WallpaperScript::setWallpaper(Wallpaper *wallpaper)
{
d->wallpaper = wallpaper;
connect(wallpaper, SIGNAL(renderCompleted(QImage)),
this, SLOT(renderCompleted(QImage)));
}
Wallpaper *WallpaperScript::wallpaper() const
{
return d->wallpaper;
}
QString WallpaperScript::mainScript() const
{
Q_ASSERT(d->wallpaper);
return d->wallpaper->package().filePath("mainscript");
}
Package WallpaperScript::package() const
{
Q_ASSERT(d->wallpaper);
return d->wallpaper->package();
}
KPluginInfo WallpaperScript::description() const
{
Q_ASSERT(d->wallpaper);
return d->wallpaper->d->wallpaperDescription;
}
void WallpaperScript::initWallpaper(const KConfigGroup &config)
{
Q_UNUSED(config)
}
void WallpaperScript::paint(QPainter *painter, const QRectF &exposedRect)
{
Q_UNUSED(painter)
Q_UNUSED(exposedRect)
}
void WallpaperScript::save(KConfigGroup &config)
{
Q_UNUSED(config)
}
QWidget *WallpaperScript::createConfigurationInterface(QWidget *parent)
{
Q_UNUSED(parent)
return 0;
}
void WallpaperScript::addUrls(const QList<QUrl> & urls)
{
Q_UNUSED(urls)
}
bool WallpaperScript::isInitialized() const
{
if (d->wallpaper) {
return d->wallpaper->isInitialized();
}
return false;
}
QRectF WallpaperScript::boundingRect() const
{
if (d->wallpaper) {
return d->wallpaper->boundingRect();
}
return QRectF();
}
void WallpaperScript::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod)
{
if (d->wallpaper) {
d->wallpaper->setResizeMethodHint(resizeMethod);
}
}
void WallpaperScript::setTargetSizeHint(const QSizeF &targetSize)
{
if (d->wallpaper) {
d->wallpaper->setTargetSizeHint(targetSize);
}
}
void WallpaperScript::setConfigurationRequired(bool needsConfiguring, const QString &reason)
{
if (d->wallpaper) {
d->wallpaper->setConfigurationRequired(needsConfiguring, reason);
}
}
void WallpaperScript::setContextualActions(const QList<QAction*> &actions)
{
if (d->wallpaper) {
d->wallpaper->setContextualActions(actions);
}
}
void WallpaperScript::update(const QRectF &exposedArea)
{
if (d->wallpaper) {
d->wallpaper->update(exposedArea);
}
}
void WallpaperScript::configNeedsSaving()
{
if (d->wallpaper) {
d->wallpaper->configNeedsSaving();
}
}
void WallpaperScript::renderCompleted(const QImage &image)
{
Q_UNUSED(image)
}
} // Plasma namespace
#include "moc_wallpaperscript.cpp"

View File

@ -1,152 +0,0 @@
/*
* Copyright 2009 by Aaron Seigo <aseigo@kde.org>
* Copyright 2009 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_WALLPAPERSCRIPT_H
#define PLASMA_WALLPAPERSCRIPT_H
#include <kplugininfo.h>
#include <plasma/plasma_export.h>
#include <plasma/scripting/scriptengine.h>
#include <plasma/wallpaper.h>
namespace Plasma
{
class WallpaperScriptPrivate;
class Service;
/**
* @class WallpaperScript plasma/scripting/wallpaperscript.h <Plasma/Scripting/WallpaperScript>
*
* @short Provides a restricted interface for scripting a Wallpaper
*/
class PLASMA_EXPORT WallpaperScript : public ScriptEngine
{
Q_OBJECT
public:
/**
* Default constructor for a WallpaperScript.
* Subclasses should not attempt to access the Plasma::Wallpaper
* associated with this WallpaperScript in the constructor. All
* such set up that requires the Wallpaper itself should be done
* in the init() method.
*/
explicit WallpaperScript(QObject *parent = 0);
~WallpaperScript();
/**
* Sets the Plasma::Wallpaper associated with this WallpaperScript
*/
void setWallpaper(Wallpaper *wallpaper);
/**
* Returns the Plasma::Wallpaper associated with this script component
*/
Wallpaper *wallpaper() const;
/**
* This method is called once the wallpaper is loaded or mode is changed.
*
* The mode can be retrieved using the renderingMode() method.
*
* @param config Config group to load settings
**/
virtual void initWallpaper(const KConfigGroup &config);
/**
* 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);
/**
* This method is called when settings need to be saved.
* @param config Config group to save settings
**/
virtual void save(KConfigGroup &config);
/**
* 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.
*
* To signal that settings have changed connect to
* settingsChanged(bool modified) in @p parent.
*
* @code connect(this, SIGNAL(settingsChanged(bool), parent, SLOT(settingsChanged(bool)))
* @endcode
*
* Emit settingsChanged(true) when the settings are changed and false when the original state is restored.
*
* Implementation detail note: for best visual results, use a QGridLayout with two columns,
* with the option labels in column 0
*/
virtual QWidget *createConfigurationInterface(QWidget *parent);
/**
* Adds urls (e.g. from a drop)
*/
virtual void addUrls(const QList<QUrl>& urls);
protected:
/**
* @return absolute path to the main script file for this wallpaper
*/
QString mainScript() const;
/**
* @return the Package associated with this wallpaper which can
* be used to request resources, such as images and
* interface files.
*/
Package package() const;
/**
* @return the KPluginInfo associated with this wallpaper
*/
KPluginInfo description() const;
bool isInitialized() const;
QRectF boundingRect() const;
void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod);
void setTargetSizeHint(const QSizeF &targetSize);
void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
void setContextualActions(const QList<QAction*> &actions);
void update(const QRectF &exposedArea);
void configNeedsSaving();
protected Q_SLOTS:
virtual void renderCompleted(const QImage &image);
private:
WallpaperScriptPrivate *const d;
};
#define K_EXPORT_PLASMA_WALLPAPERSCRIPTENGINE(libname, classname) \
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
K_EXPORT_PLUGIN(factory("plasma_wallpaperscriptengine_" #libname))
} //Plasma namespace
#endif

View File

@ -1,456 +0,0 @@
/*
* 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.
*/
#include "wallpaper.h"
#include "config-plasma.h"
#include <QColor>
#include <QFile>
#include <QFileInfo>
#include <QImage>
#include <QAction>
#include <QQueue>
#include <QTimer>
#include <QRunnable>
#include <QThreadPool>
#include <kdebug.h>
#include <kglobal.h>
#include <kservicetypetrader.h>
#include <kstandarddirs.h>
#include <klocalizedstring.h>
#if !PLASMA_NO_KIO
#include <kio/job.h>
#endif
#include <version.h>
#include <qstandardpaths.h>
#include "package.h"
#include "pluginloader.h"
#include "private/packages_p.h"
#include "private/wallpaper_p.h"
namespace Plasma
{
Wallpaper::Wallpaper(QObject * parentObject)
: d(new WallpaperPrivate(KService::serviceByStorageId(QString()), this))
{
setParent(parentObject);
}
Wallpaper::Wallpaper(QObject *parentObject, const QVariantList &args)
: d(new WallpaperPrivate(KService::serviceByStorageId(args.count() > 0 ?
args[0].toString() : QString()), this))
{
// now remove first item since those are managed by Wallpaper and subclasses shouldn't
// need to worry about them. yes, it violates the constness of this var, but it lets us add
// or remove items later while applets can just pretend that their args always start at 0
QVariantList &mutableArgs = const_cast<QVariantList &>(args);
if (!mutableArgs.isEmpty()) {
mutableArgs.removeFirst();
}
setParent(parentObject);
}
Wallpaper::~Wallpaper()
{
delete d;
}
void Wallpaper::addUrls(const QList<QUrl> &urls)
{
if (d->script) {
d->script->addUrls(urls);
}
}
KPluginInfo::List Wallpaper::listWallpaperInfo(const QString &formFactor)
{
QString constraint;
if (!formFactor.isEmpty()) {
constraint.append("[X-Plasma-FormFactors] ~~ '").append(formFactor).append("'");
}
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Wallpaper", constraint);
return KPluginInfo::fromServices(offers);
}
KPluginInfo::List Wallpaper::listWallpaperInfoForMimeType(const QString &mimeType, const QString &formFactor)
{
QString constraint = QString("'%1' in [X-Plasma-DropMimeTypes]").arg(mimeType);
if (!formFactor.isEmpty()) {
constraint.append("[X-Plasma-FormFactors] ~~ '").append(formFactor).append("'");
}
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Wallpaper", constraint);
#ifndef NDEBUG
kDebug() << offers.count() << constraint;
#endif
return KPluginInfo::fromServices(offers);
}
bool Wallpaper::supportsMimetype(const QString &mimetype) const
{
return d->wallpaperDescription.isValid() &&
d->wallpaperDescription.service()->hasMimeType(mimetype);
}
Wallpaper *Wallpaper::load(const QString &wallpaperName, const QVariantList &args)
{
if (wallpaperName.isEmpty()) {
return 0;
}
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(wallpaperName);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Wallpaper", constraint);
if (offers.isEmpty()) {
#ifndef NDEBUG
kDebug() << "offers is empty for " << wallpaperName;
#endif
return 0;
}
KService::Ptr offer = offers.first();
QVariantList allArgs;
allArgs << offer->storageId() << args;
if (!offer->property("X-Plasma-API").toString().isEmpty()) {
#ifndef NDEBUG
kDebug() << "we have a script using the"
<< offer->property("X-Plasma-API").toString() << "API";
#endif
return new Wallpaper(0, allArgs);
}
KPluginLoader plugin(*offer);
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
return 0;
}
QString error;
Wallpaper *wallpaper = offer->createInstance<Plasma::Wallpaper>(0, allArgs, &error);
if (!wallpaper) {
#ifndef NDEBUG
kDebug() << "Couldn't load wallpaper \"" << wallpaperName << "\"! reason given: " << error;
#endif
}
return wallpaper;
}
Wallpaper *Wallpaper::load(const KPluginInfo &info, const QVariantList &args)
{
if (!info.isValid()) {
return 0;
}
return load(info.pluginName(), args);
}
QString Wallpaper::name() const
{
if (!d->wallpaperDescription.isValid()) {
return i18n("Unknown Wallpaper");
}
return d->wallpaperDescription.name();
}
QString Wallpaper::icon() const
{
if (!d->wallpaperDescription.isValid()) {
return QString();
}
return d->wallpaperDescription.icon();
}
QString Wallpaper::pluginName() const
{
if (!d->wallpaperDescription.isValid()) {
return QString();
}
return d->wallpaperDescription.pluginName();
}
KServiceAction Wallpaper::renderingMode() const
{
return d->mode;
}
QList<KServiceAction> Wallpaper::listRenderingModes() const
{
if (!d->wallpaperDescription.isValid()) {
return QList<KServiceAction>();
}
return d->wallpaperDescription.service()->actions();
}
QRectF Wallpaper::boundingRect() const
{
return d->boundingRect;
}
bool Wallpaper::isInitialized() const
{
return d->initialized;
}
QString Wallpaper::wallpaperPath() const
{
return d->wallpaperPath;
}
void Wallpaper::setWallpaperPath(const QString& path)
{
if (path.isEmpty() || !QFile::exists(path)) {
kWarning() << "failed on:" << path;
return;
}
d->wallpaperPath = path;
}
void Wallpaper::setBoundingRect(const QRectF &boundingRect)
{
d->boundingRect = boundingRect;
if (d->targetSize != boundingRect.size()) {
d->targetSize = boundingRect.size();
emit renderHintsChanged();
}
}
void Wallpaper::setRenderingMode(const QString &mode)
{
if (d->mode.name() == mode) {
return;
}
d->mode = KServiceAction();
if (!mode.isEmpty()) {
QList<KServiceAction> modes = listRenderingModes();
foreach (const KServiceAction &action, modes) {
if (action.name() == mode) {
d->mode = action;
break;
}
}
}
}
void Wallpaper::restore(const KConfigGroup &config)
{
init(config);
d->initialized = true;
}
void Wallpaper::init(const KConfigGroup &config)
{
if (d->script) {
d->initScript();
d->script->initWallpaper(config);
}
}
void Wallpaper::save(KConfigGroup &config)
{
if (d->script) {
d->script->save(config);
}
}
bool Wallpaper::configurationRequired() const
{
return d->needsConfig;
}
void Wallpaper::setConfigurationRequired(bool needsConfig, const QString &reason)
{
//TODO: implement something for reason. first, we need to decide where/how
// to communicate it to the user
Q_UNUSED(reason)
if (d->needsConfig == needsConfig) {
return;
}
d->needsConfig = needsConfig;
emit configurationRequired(needsConfig);
}
void Wallpaper::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod)
{
const ResizeMethod method = qBound(ScaledResize, resizeMethod, LastResizeMethod);
if (method != d->lastResizeMethod) {
d->lastResizeMethod = method;
emit renderHintsChanged();
}
}
Wallpaper::ResizeMethod Wallpaper::resizeMethodHint() const
{
return d->lastResizeMethod;
}
void Wallpaper::setTargetSizeHint(const QSizeF &targetSize)
{
if (targetSize != d->targetSize) {
d->targetSize = targetSize;
emit renderHintsChanged();
}
}
QSizeF Wallpaper::targetSizeHint() const
{
return d->targetSize;
}
WallpaperPrivate::WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper) :
q(wallpaper),
wallpaperDescription(service),
package(0),
renderToken(-1),
lastResizeMethod(Wallpaper::ScaledResize),
script(0),
cacheRendering(false),
initialized(false),
needsConfig(false),
scriptInitialized(false),
previewing(false),
needsPreviewDuringConfiguration(false)
{
if (wallpaperDescription.isValid()) {
QString api = wallpaperDescription.property("X-Plasma-API").toString();
if (!api.isEmpty()) {
const QString path = KStandardDirs::locate("data",
"plasma/wallpapers/" + wallpaperDescription.pluginName() + '/');
package = new Package(PluginLoader::self()->loadPackage("Plasma/Wallpaper", api));
package->setPath(path);
if (package->isValid()) {
script = Plasma::loadScriptEngine(api, q);
}
if (!script) {
#ifndef NDEBUG
kDebug() << "Could not create a" << api << "ScriptEngine for the"
<< wallpaperDescription.name() << "Wallpaper.";
#endif
delete package;
package = 0;
}
}
}
}
QString WallpaperPrivate::cacheKey(const QString &sourceImagePath, const QSize &size,
int resizeMethod, const QColor &color) const
{
const QString id = QString("%5_%3_%4_%1x%2")
.arg(size.width()).arg(size.height()).arg(color.name())
.arg(resizeMethod).arg(sourceImagePath);
return id;
}
QString WallpaperPrivate::cachePath(const QString &key) const
{
return QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + "plasma-wallpapers/" + key + ".png";
}
// put all setup routines for script here. at this point we can assume that
// package exists and that we have a script engine
void WallpaperPrivate::setupScriptSupport()
{
Q_ASSERT(package);
#ifndef NDEBUG
kDebug() << "setting up script support, package is in" << package->path()
<< ", main script is" << package->filePath("mainscript");
#endif
const QString translationsPath = package->filePath("translations");
if (!translationsPath.isEmpty()) {
KGlobal::dirs()->addResourceDir("locale", translationsPath);
KLocalizedString::insertCatalog(wallpaperDescription.pluginName());
}
}
void WallpaperPrivate::initScript()
{
if (script && !scriptInitialized) {
setupScriptSupport();
script->init();
scriptInitialized = true;
}
}
QList<QAction*> Wallpaper::contextualActions() const
{
return d->contextActions;
}
void Wallpaper::setContextualActions(const QList<QAction*> &actions)
{
d->contextActions = actions;
}
bool Wallpaper::isPreviewing() const
{
return d->previewing;
}
void Wallpaper::setPreviewing(bool previewing)
{
d->previewing = previewing;
}
bool Wallpaper::needsPreviewDuringConfiguration() const
{
return d->needsPreviewDuringConfiguration;
}
void Wallpaper::setPreviewDuringConfiguration(const bool preview)
{
d->needsPreviewDuringConfiguration = preview;
}
Package Wallpaper::package() const
{
return d->package ? *d->package : Package();
}
} // Plasma namespace
#include "moc_wallpaper.cpp"
#include "private/moc_wallpaper_p.cpp"

View File

@ -1,395 +0,0 @@
/*
* 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
#include <QColor>
#include <kplugininfo.h>
#include <plasma/package.h>
#include <plasma/plasma.h>
#include <plasma/version.h>
namespace Plasma
{
class DataEngine;
class WallpaperPrivate;
/**
* @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:
*
* plasma-wallpaper-\<pluginname\>.desktop
*
* 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(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)
Q_PROPERTY(bool previewing READ isPreviewing WRITE setPreviewing)
Q_PROPERTY(ResizeMethod resizeMethod READ resizeMethodHint WRITE setResizeMethodHint)
Q_PROPERTY(QSizeF targetSize READ targetSizeHint WRITE setTargetSizeHint)
public:
/**
* 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 */,
LastResizeMethod = MaxpectResize
};
Q_ENUMS(ResizeMethod)
/**
* Default constructor for an empty or null wallpaper
*/
explicit Wallpaper(QObject * parent = 0);
~Wallpaper();
/**
* Returns a list of all known wallpapers.
*
* @param formFactor the format of the wallpaper being search for (e.g. desktop)
* @return list of wallpapers
**/
static KPluginInfo::List listWallpaperInfo(const QString &formFactor = QString());
/**
* Returns a list of all known wallpapers that can accept the given MimeType
* @arg mimeType the mimeType to search for
* @arg formFactor the format of the wallpaper being search for (e.g. desktop)
* @return list of wallpapers
*/
static KPluginInfo::List listWallpaperInfoForMimeType(const QString &mimeType,
const QString &formFactor = QString());
/**
* Attempts to load a wallpaper
*
* 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());
/**
* Attempts to load a wallpaper
*
* 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());
/**
* 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;
/**
* Accessor for the associated Package object if any.
*
* @return the Package object, or 0 if none
**/
Package package() const;
/**
* 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;
/**
* @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;
/**
* 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;
/**
* @return true if initialized (usually by calling restore), false otherwise
*/
bool isInitialized() const;
/**
* Returns bounding rectangle
*/
QRectF boundingRect() const;
/**
* Sets bounding rectangle
*/
void setBoundingRect(const QRectF &boundingRect);
/**
* Can be Overridden by plugins which support setting Image URLs.
* This is triggered by events in the user interface such as
* drag and drop of files.
*/
virtual void addUrls(const QList<QUrl> &urls);
/**
* 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);
/**
* @return true if the wallpaper currently needs to be configured,
* otherwise, false
* @since 4.3
*/
bool configurationRequired() const;
virtual void setWallpaperPath(const QString& path);
/**
* Allows one to set rendering hints that may differ from the actualities of the
* Wallpaper's current state, allowing for better selection of papers from packages,
* for instance.
*
* @param 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);
/**
* @return the current resize method hint
* @since 4.7.2
*/
Wallpaper::ResizeMethod resizeMethodHint() const;
/**
* Allows one to set rendering hints that may differ from the actualities of the
* Wallpaper's current state, allowing for better selection of papers from packages,
* for instance.
*
* @param targetSize The size to assume will be used for future wallpaper scaling
*
* @since 4.3
*/
void setTargetSizeHint(const QSizeF &targetSize);
/**
* @return the current target size method hint
* @since 4.7.2
*/
QSizeF targetSizeHint() const;
/**
* Returns a list of wallpaper contextual actions (nothing by default)
*/
QList<QAction*> contextualActions() const;
/**
* @return true if in preview mode, such as in a configuation dialog
* @since 4.5
*/
bool isPreviewing() const;
QString wallpaperPath() const;
/**
* Puts the wallpaper into preview mode
* @since 4.5
*/
void setPreviewing(bool previewing);
/**
* @return true if the wallpaper needs a live preview in the configuration UI
* @since 4.6
*/
bool needsPreviewDuringConfiguration() const;
Q_SIGNALS:
/**
* This signal indicates that wallpaper needs to be repainted.
*/
void update(const QRectF &exposedArea);
/**
* Emitted when the user wants to configure/change the wallpaper.
* @since 4.3
*/
void configureRequested();
/**
* Emitted when the state of the wallpaper requiring configuration
* changes.
* @since 4.3
*/
void configurationRequired(bool needsConfig);
/**
* Emitted when the configuration of the wallpaper needs to be saved
* to disk.
* @since 4.3
*/
void configNeedsSaving();
/**
* @internal
*/
void renderHintsChanged();
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.
*
* The mode can be retrieved using the renderingMode() method.
*
* @param config Config group to load settings
**/
virtual void init(const KConfigGroup &config);
/**
* 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
* @since 4.3
*/
void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
/**
* Sets the contextual actions for this wallpaper.
*
* @param actions A list of contextual actions for this wallpaper
*
* @since 4.4
**/
void setContextualActions(const QList<QAction*> &actions);
/**
* 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);
private:
Q_PRIVATE_SLOT(d, void initScript())
friend class WallpaperPackage;
friend class WallpaperPrivate;
friend class WallpaperScript;
friend class WallpaperWithPaint;
friend class ContainmentPrivate;
WallpaperPrivate *const d;
};
} // Plasma namespace
/**
* Register a wallpaper when it is contained in a loadable module
*/
#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