Merge remote-tracking branch 'origin/KDE/4.7' into frameworks
Conflicts: CMakeLists.txt kio/kio/kfileitem.cpp plasma/datacontainer.cpp plasma/datacontainer.h plasma/private/wallpaper_p.h plasma/private/wallpaperrenderthread.cpp
This commit is contained in:
commit
2c7751ccef
@ -9,7 +9,7 @@
|
|||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details
|
* GNU Library General Public License for more details
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Library General Public
|
* You should have received a copy of the GNU Library General Public
|
||||||
* License along with this program; if not, write to the
|
* License along with this program; if not, write to the
|
||||||
|
@ -71,7 +71,7 @@ Comment[ta]=பிளாஸ்மா தரவு இயந்திரம்
|
|||||||
Comment[tg]=Системаи маълумотии Plasma
|
Comment[tg]=Системаи маълумотии Plasma
|
||||||
Comment[th]=กลไกข้อมูลของพลาสมา
|
Comment[th]=กลไกข้อมูลของพลาสมา
|
||||||
Comment[tr]=Plasma Veri Motoru
|
Comment[tr]=Plasma Veri Motoru
|
||||||
Comment[ug]=Plasma سانلىق مەلۇمات ماتورى
|
Comment[ug]=Plasma سانلىق-مەلۇمات ماتورى
|
||||||
Comment[uk]=Рушій даних Плазми
|
Comment[uk]=Рушій даних Плазми
|
||||||
Comment[wa]=Moteur di dnêyes di Plasma
|
Comment[wa]=Moteur di dnêyes di Plasma
|
||||||
Comment[x-test]=xxPlasma Data Enginexx
|
Comment[x-test]=xxPlasma Data Enginexx
|
||||||
|
@ -31,8 +31,6 @@ DataContainer::DataContainer(QObject *parent)
|
|||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new DataContainerPrivate(this))
|
d(new DataContainerPrivate(this))
|
||||||
{
|
{
|
||||||
d->storageTimer = new QTimer(this);
|
|
||||||
QObject::connect(d->storageTimer, SIGNAL(timeout()), this, SLOT(store()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataContainer::~DataContainer()
|
DataContainer::~DataContainer()
|
||||||
@ -61,7 +59,7 @@ void DataContainer::setData(const QString &key, const QVariant &value)
|
|||||||
//setData() since the last time it was stored. This
|
//setData() since the last time it was stored. This
|
||||||
//gives us only one singleShot timer.
|
//gives us only one singleShot timer.
|
||||||
if (isStorageEnabled() || !needsToBeStored()) {
|
if (isStorageEnabled() || !needsToBeStored()) {
|
||||||
d->storageTimer->start(180000);
|
d->storageTimer.start(180000, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNeedsToBeStored(true);
|
setNeedsToBeStored(true);
|
||||||
@ -336,10 +334,21 @@ bool DataContainer::isUsed() const
|
|||||||
|
|
||||||
void DataContainerPrivate::checkUsage()
|
void DataContainerPrivate::checkUsage()
|
||||||
{
|
{
|
||||||
if (!q->isUsed()) {
|
if (!d->checkUsageTimer.isActive()) {
|
||||||
|
d->checkUsageTimer.start(10, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataContainer::timerEvent(QTimerEvent * event)
|
||||||
|
{
|
||||||
|
if (event->timerId() == d->checkUsageTimer.timerId()) {
|
||||||
|
if (!isUsed()) {
|
||||||
// DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED!
|
// DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED!
|
||||||
//kDebug() << q->objectName() << "is unused";
|
//kDebug() << objectName() << "is unused";
|
||||||
emit q->becameUnused(q->objectName());
|
emit becameUnused(objectName());
|
||||||
|
}
|
||||||
|
} else if (event->timerId() == d->storageTimer.timerId()) {
|
||||||
|
d->store();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +239,12 @@ class PLASMA_EXPORT DataContainer : public QObject
|
|||||||
**/
|
**/
|
||||||
void setNeedsUpdate(bool update = true);
|
void setNeedsUpdate(bool update = true);
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
/**
|
||||||
|
* @reimp from QObject
|
||||||
|
*/
|
||||||
|
void timerEvent(QTimerEvent * event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SignalRelay;
|
friend class SignalRelay;
|
||||||
friend class DataContainerPrivate;
|
friend class DataContainerPrivate;
|
||||||
@ -247,7 +253,6 @@ class PLASMA_EXPORT DataContainer : public QObject
|
|||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void storeJobFinished(KJob *job))
|
Q_PRIVATE_SLOT(d, void storeJobFinished(KJob *job))
|
||||||
Q_PRIVATE_SLOT(d, void populateFromStoredData(KJob *job))
|
Q_PRIVATE_SLOT(d, void populateFromStoredData(KJob *job))
|
||||||
Q_PRIVATE_SLOT(d, void store())
|
|
||||||
Q_PRIVATE_SLOT(d, void retrieve())
|
Q_PRIVATE_SLOT(d, void retrieve())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
#ifndef PLASMA_DATACONTAINER_P_H
|
#ifndef PLASMA_DATACONTAINER_P_H
|
||||||
#define PLASMA_DATACONTAINER_P_H
|
#define PLASMA_DATACONTAINER_P_H
|
||||||
|
|
||||||
#include <QtCore/QTimerEvent>
|
|
||||||
#include <QtCore/QTime>
|
|
||||||
#include "servicejob.h"
|
#include "servicejob.h"
|
||||||
#include "storage_p.h"
|
#include "storage_p.h"
|
||||||
|
|
||||||
|
#include <QtCore/QTimerEvent>
|
||||||
|
#include <QtCore/QTime>
|
||||||
|
#include <QtCore/QBasicTimer>
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
@ -38,11 +40,11 @@ public:
|
|||||||
DataContainerPrivate(DataContainer *container)
|
DataContainerPrivate(DataContainer *container)
|
||||||
: q(container),
|
: q(container),
|
||||||
storage(NULL),
|
storage(NULL),
|
||||||
|
storageCount(0),
|
||||||
dirty(false),
|
dirty(false),
|
||||||
cached(false),
|
cached(false),
|
||||||
enableStorage(false),
|
enableStorage(false),
|
||||||
isStored(true),
|
isStored(true)
|
||||||
storageCount(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,14 +83,15 @@ public:
|
|||||||
DataEngine::Data data;
|
DataEngine::Data data;
|
||||||
QMap<QObject *, SignalRelay *> relayObjects;
|
QMap<QObject *, SignalRelay *> relayObjects;
|
||||||
QMap<uint, SignalRelay *> relays;
|
QMap<uint, SignalRelay *> relays;
|
||||||
QTimer *storageTimer;
|
|
||||||
QTime updateTs;
|
QTime updateTs;
|
||||||
Storage* storage;
|
Storage* storage;
|
||||||
|
QBasicTimer storageTimer;
|
||||||
|
QBasicTimer checkUsageTimer;
|
||||||
|
int storageCount;
|
||||||
bool dirty : 1;
|
bool dirty : 1;
|
||||||
bool cached : 1;
|
bool cached : 1;
|
||||||
bool enableStorage : 1;
|
bool enableStorage : 1;
|
||||||
bool isStored : 1;
|
bool isStored : 1;
|
||||||
int storageCount;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SignalRelay : public QObject
|
class SignalRelay : public QObject
|
||||||
|
@ -46,6 +46,8 @@ public:
|
|||||||
|
|
||||||
void newRenderCompleted(const WallpaperRenderRequest &render, const QImage &image);
|
void newRenderCompleted(const WallpaperRenderRequest &render, const QImage &image);
|
||||||
void setupScriptSupport();
|
void setupScriptSupport();
|
||||||
|
void renderWallpaper(const QString &sourceImagePath, const QImage &image, const QSize &size,
|
||||||
|
Wallpaper::ResizeMethod resizeMethod, const QColor &color);
|
||||||
|
|
||||||
Wallpaper *q;
|
Wallpaper *q;
|
||||||
KPluginInfo wallpaperDescription;
|
KPluginInfo wallpaperDescription;
|
||||||
@ -69,16 +71,15 @@ public:
|
|||||||
class LoadImageThread : public QObject, public QRunnable
|
class LoadImageThread : public QObject, public QRunnable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
public:
|
||||||
private:
|
|
||||||
QString m_filePath;
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void done(const QImage &pixmap);
|
|
||||||
|
|
||||||
public:
|
|
||||||
LoadImageThread(const QString &filePath);
|
LoadImageThread(const QString &filePath);
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void done(const QImage &pixmap);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
@ -121,13 +121,13 @@ void WallpaperRenderThread::run()
|
|||||||
QImage result(m_request.size, QImage::Format_ARGB32_Premultiplied);
|
QImage result(m_request.size, QImage::Format_ARGB32_Premultiplied);
|
||||||
result.fill(m_request.color.rgba());
|
result.fill(m_request.color.rgba());
|
||||||
|
|
||||||
if (m_request.file.isEmpty() || !QFile::exists(m_request.file)) {
|
if (m_request.file.isEmpty() && m_request.providedImage.isNull() && !QFile::exists(m_request.file)) {
|
||||||
if (!m_abort) {
|
if (!m_abort) {
|
||||||
emit done(m_request, result);
|
emit done(m_request, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
kDebug() << "oh, fuck it";
|
kDebug() << "wrong request or file does not exist";
|
||||||
#endif
|
#endif
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
@ -142,7 +142,11 @@ void WallpaperRenderThread::run()
|
|||||||
|
|
||||||
// set image size
|
// set image size
|
||||||
QSize imgSize(1, 1);
|
QSize imgSize(1, 1);
|
||||||
if (scalable) {
|
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
|
// scalable: image can be of any size
|
||||||
imgSize = imgSize.expandedTo(m_request.size);
|
imgSize = imgSize.expandedTo(m_request.size);
|
||||||
} else {
|
} else {
|
||||||
@ -231,9 +235,6 @@ void WallpaperRenderThread::run()
|
|||||||
QSvgRenderer svg(m_request.file);
|
QSvgRenderer svg(m_request.file);
|
||||||
if (m_abort) {
|
if (m_abort) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
#ifndef NDEBUG
|
|
||||||
kDebug() << "oh, fuck it 2";
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
svg.render(&p);
|
svg.render(&p);
|
||||||
@ -244,9 +245,6 @@ void WallpaperRenderThread::run()
|
|||||||
|
|
||||||
if (m_abort) {
|
if (m_abort) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
#ifndef NDEBUG
|
|
||||||
kDebug() << "oh, fuck it 3";
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,9 +253,6 @@ void WallpaperRenderThread::run()
|
|||||||
for (int y = pos.y(); y < m_request.size.height(); y += scaledSize.height()) {
|
for (int y = pos.y(); y < m_request.size.height(); y += scaledSize.height()) {
|
||||||
p.drawImage(QPoint(x, y), img);
|
p.drawImage(QPoint(x, y), img);
|
||||||
if (m_abort) {
|
if (m_abort) {
|
||||||
#ifndef NDEBUG
|
|
||||||
kDebug() << "oh, fuck it 4";
|
|
||||||
#endif
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -270,9 +265,6 @@ void WallpaperRenderThread::run()
|
|||||||
|
|
||||||
// signal we're done
|
// signal we're done
|
||||||
if (!m_abort) {
|
if (!m_abort) {
|
||||||
#ifndef NDEBUG
|
|
||||||
kDebug() << "*****************************************************";
|
|
||||||
#endif
|
|
||||||
emit done(m_request, result);
|
emit done(m_request, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
QWeakPointer<QObject> requester;
|
QWeakPointer<QObject> requester;
|
||||||
|
QImage providedImage;
|
||||||
QString file;
|
QString file;
|
||||||
QSize size;
|
QSize size;
|
||||||
Wallpaper::ResizeMethod resizeMethod;
|
Wallpaper::ResizeMethod resizeMethod;
|
||||||
|
@ -64,7 +64,7 @@ Name[ta]=பொதியின் மூலத்தரவு சோதனைக
|
|||||||
Name[tg]=Файли санҷишии стсетмаи metadata
|
Name[tg]=Файли санҷишии стсетмаи metadata
|
||||||
Name[th]=แฟ้มทดสอบข้อมูลกำกับแพกเกจ
|
Name[th]=แฟ้มทดสอบข้อมูลกำกับแพกเกจ
|
||||||
Name[tr]=Paket metadata test dosyası
|
Name[tr]=Paket metadata test dosyası
|
||||||
Name[ug]=بوغچا مېتا سانلىق مەلۇمات سىناق ھۆججەت
|
Name[ug]=بوغچا مېتا سانلىق-مەلۇمات سىناق ھۆججەت
|
||||||
Name[uk]=Файл перевірки метаданих пакунка
|
Name[uk]=Файл перевірки метаданих пакунка
|
||||||
Name[wa]=Fitchî d' asprouvaedje des meta-dnêyes do pacaedje
|
Name[wa]=Fitchî d' asprouvaedje des meta-dnêyes do pacaedje
|
||||||
Name[x-test]=xxPackage metadata test filexx
|
Name[x-test]=xxPackage metadata test filexx
|
||||||
|
@ -11,7 +11,7 @@ Name[ca]=Motor de dades de prova
|
|||||||
Name[ca@valencia]=Motor de dades de prova
|
Name[ca@valencia]=Motor de dades de prova
|
||||||
Name[cs]=Testovací datový nástroj
|
Name[cs]=Testovací datový nástroj
|
||||||
Name[da]=Test datamotor
|
Name[da]=Test datamotor
|
||||||
Name[de]=Test-Datentreiber
|
Name[de]=Test-Datenmodul
|
||||||
Name[el]=Μηχανή δεδομένων ελέγχου
|
Name[el]=Μηχανή δεδομένων ελέγχου
|
||||||
Name[en_GB]=Test Data Engine
|
Name[en_GB]=Test Data Engine
|
||||||
Name[eo]=Testa Datuma motoro
|
Name[eo]=Testa Datuma motoro
|
||||||
|
@ -415,6 +415,16 @@ QSizeF Wallpaper::targetSizeHint() const
|
|||||||
return d->targetSize;
|
return d->targetSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wallpaper::render(const QImage &image, const QSize &size,
|
||||||
|
Wallpaper::ResizeMethod resizeMethod, const QColor &color)
|
||||||
|
{
|
||||||
|
if (image.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->renderWallpaper(QString(), image, size, resizeMethod, color);
|
||||||
|
}
|
||||||
|
|
||||||
void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
|
void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
|
||||||
Wallpaper::ResizeMethod resizeMethod, const QColor &color)
|
Wallpaper::ResizeMethod resizeMethod, const QColor &color)
|
||||||
{
|
{
|
||||||
@ -423,23 +433,30 @@ void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeMethod = qBound(ScaledResize, resizeMethod, LastResizeMethod);
|
d->renderWallpaper(sourceImagePath, QImage(), size, resizeMethod, color);
|
||||||
if (d->lastResizeMethod != resizeMethod) {
|
}
|
||||||
d->lastResizeMethod = resizeMethod;
|
|
||||||
emit renderHintsChanged();
|
void WallpaperPrivate::renderWallpaper(const QString &sourceImagePath, const QImage &image, const QSize &size,
|
||||||
|
Wallpaper::ResizeMethod resizeMethod, const QColor &color)
|
||||||
|
{
|
||||||
|
resizeMethod = qBound(Wallpaper::ScaledResize, resizeMethod, Wallpaper::LastResizeMethod);
|
||||||
|
if (lastResizeMethod != resizeMethod) {
|
||||||
|
lastResizeMethod = resizeMethod;
|
||||||
|
emit q->renderHintsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->cacheRendering) {
|
if (cacheRendering) {
|
||||||
QFileInfo info(sourceImagePath);
|
QFileInfo info(sourceImagePath);
|
||||||
QString cache = d->cacheKey(sourceImagePath, size, resizeMethod, color);
|
QString cache = cacheKey(sourceImagePath, size, resizeMethod, color);
|
||||||
if (d->findInCache(cache, info.lastModified().toTime_t())) {
|
if (findInCache(cache, info.lastModified().toTime_t())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WallpaperRenderRequest request;
|
WallpaperRenderRequest request;
|
||||||
d->renderToken = request.token;
|
renderToken = request.token;
|
||||||
request.requester = this;
|
request.requester = q;
|
||||||
|
request.providedImage = image;
|
||||||
request.file = sourceImagePath;
|
request.file = sourceImagePath;
|
||||||
request.size = size;
|
request.size = size;
|
||||||
request.resizeMethod = resizeMethod;
|
request.resizeMethod = resizeMethod;
|
||||||
|
16
wallpaper.h
16
wallpaper.h
@ -455,6 +455,22 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
|||||||
Wallpaper::ResizeMethod resizeMethod = ScaledResize,
|
Wallpaper::ResizeMethod resizeMethod = ScaledResize,
|
||||||
const QColor &color = QColor(0, 0, 0));
|
const QColor &color = QColor(0, 0, 0));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the wallpaper asyncronously with the given parameters. When the rendering is
|
||||||
|
* complete, the renderCompleted signal is emitted.
|
||||||
|
*
|
||||||
|
* @param image the raw QImage
|
||||||
|
* @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.7.4
|
||||||
|
*/
|
||||||
|
void render(const QImage &image, 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
|
* 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.
|
* changes often or is innexpensive to render, then it's probably best not to cache them.
|
||||||
|
Loading…
Reference in New Issue
Block a user