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