From 4e12ac1c09acbb2b4032d34da34e0749a5ffca51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Fri, 21 Oct 2011 13:06:30 +0200 Subject: [PATCH 1/6] Fix small license glitch --- abstractrunner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abstractrunner.h b/abstractrunner.h index 62f8cacd5..9e30d46e0 100644 --- a/abstractrunner.h +++ b/abstractrunner.h @@ -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 From 4cc0c2fbd6804a6ed03babf28b4fdb0b9438eb3e Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sat, 22 Oct 2011 14:56:58 +0200 Subject: [PATCH 2/6] SVN_SILENT made messages (.desktop file) --- data/servicetypes/plasma-dataengine.desktop | 2 +- tests/packagemetadatatest.desktop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/servicetypes/plasma-dataengine.desktop b/data/servicetypes/plasma-dataengine.desktop index b4da43ed3..ab82e66a3 100644 --- a/data/servicetypes/plasma-dataengine.desktop +++ b/data/servicetypes/plasma-dataengine.desktop @@ -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 diff --git a/tests/packagemetadatatest.desktop b/tests/packagemetadatatest.desktop index a0f785460..069943718 100644 --- a/tests/packagemetadatatest.desktop +++ b/tests/packagemetadatatest.desktop @@ -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 From 4371c365fa2d18a08f47fc9ce64b1734e106bf14 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Fri, 28 Oct 2011 14:12:20 +0200 Subject: [PATCH 3/6] SVN_SILENT made messages (.desktop file) --- tests/testengine/plasma-dataengine-testengine.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testengine/plasma-dataengine-testengine.desktop b/tests/testengine/plasma-dataengine-testengine.desktop index 7b64ee255..734aadfe6 100644 --- a/tests/testengine/plasma-dataengine-testengine.desktop +++ b/tests/testengine/plasma-dataengine-testengine.desktop @@ -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 From 23784d26bbca8d8b6ffaddeea6b5cb1244155e24 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 30 Oct 2011 01:57:49 +0200 Subject: [PATCH 4/6] less profanity --- private/wallpaperrenderthread.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/private/wallpaperrenderthread.cpp b/private/wallpaperrenderthread.cpp index 316b89b60..a5f3fdcbf 100644 --- a/private/wallpaperrenderthread.cpp +++ b/private/wallpaperrenderthread.cpp @@ -223,7 +223,6 @@ void WallpaperRenderThread::run() QSvgRenderer svg(m_request.file); if (m_abort) { deleteLater(); - kDebug() << "oh, fuck it 2"; return; } svg.render(&p); @@ -234,7 +233,6 @@ void WallpaperRenderThread::run() if (m_abort) { deleteLater(); - kDebug() << "oh, fuck it 3"; return; } @@ -243,7 +241,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) { - kDebug() << "oh, fuck it 4"; deleteLater(); return; } @@ -256,7 +253,6 @@ void WallpaperRenderThread::run() // signal we're done if (!m_abort) { - kDebug() << "*****************************************************"; emit done(m_request, result); } From 97743420a0ebbc2d6073062718f7ee3a08a26390 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 30 Oct 2011 10:24:57 +0100 Subject: [PATCH 5/6] add a wallpaper render that takes a pre-loaded QImage. FAR FAR faster than re-loading from disk if already in memory. new API (new overload, really), but required to fix iperformance issues elsewhere, so considered a bug fix --- private/wallpaper_p.h | 18 +++++++++------- private/wallpaperrenderthread.cpp | 10 ++++++--- private/wallpaperrenderthread_p.h | 1 + wallpaper.cpp | 35 +++++++++++++++++++++++-------- wallpaper.h | 16 ++++++++++++++ 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/private/wallpaper_p.h b/private/wallpaper_p.h index 32a0fdcd4..7df8e14a5 100644 --- a/private/wallpaper_p.h +++ b/private/wallpaper_p.h @@ -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); static PackageStructure::Ptr s_packageStructure; @@ -70,16 +72,16 @@ public: class LoadImageThread : public QObject, public QRunnable { Q_OBJECT - - private: - QString m_filePath; - Q_SIGNALS: - void done(const QImage &pixmap); +public: + LoadImageThread(const QString &filePath); + void run(); - public: - LoadImageThread(const QString &filePath); - void run(); +Q_SIGNALS: + void done(const QImage &pixmap); + +private: + QString m_filePath; }; } // namespace Plasma diff --git a/private/wallpaperrenderthread.cpp b/private/wallpaperrenderthread.cpp index a5f3fdcbf..0a4e21575 100644 --- a/private/wallpaperrenderthread.cpp +++ b/private/wallpaperrenderthread.cpp @@ -115,12 +115,12 @@ 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); } - kDebug() << "oh, fuck it"; + kDebug() << "wrong request or file does not exist"; deleteLater(); return; } @@ -134,7 +134,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 { diff --git a/private/wallpaperrenderthread_p.h b/private/wallpaperrenderthread_p.h index 7a31d591d..677c0273b 100644 --- a/private/wallpaperrenderthread_p.h +++ b/private/wallpaperrenderthread_p.h @@ -42,6 +42,7 @@ public: } QWeakPointer requester; + QImage providedImage; QString file; QSize size; Wallpaper::ResizeMethod resizeMethod; diff --git a/wallpaper.cpp b/wallpaper.cpp index 8cae0d4bf..35d744f7d 100644 --- a/wallpaper.cpp +++ b/wallpaper.cpp @@ -442,6 +442,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) { @@ -450,23 +460,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; diff --git a/wallpaper.h b/wallpaper.h index 3bfa2b3ed..ecc08be61 100644 --- a/wallpaper.h +++ b/wallpaper.h @@ -486,6 +486,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. From 176d4b896b6afa7a41c19b4b083dea71791801b8 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 30 Oct 2011 10:35:29 +0100 Subject: [PATCH 6/6] delay usage checks so quite disconnect/reconnects don't result in unecessary loss of data (only to reload it again immediately thereafter...) --- datacontainer.cpp | 25 +++++++++++++++++-------- datacontainer.h | 6 +++++- private/datacontainer_p.h | 15 +++++++++------ 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/datacontainer.cpp b/datacontainer.cpp index 663c7ca97..84b345c74 100644 --- a/datacontainer.cpp +++ b/datacontainer.cpp @@ -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); @@ -330,11 +328,22 @@ void DataContainer::setNeedsUpdate(bool update) void DataContainer::checkUsage() { - if (d->relays.count() < 1 && - receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))) < 1) { - // DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED! - kDebug() << objectName() << "is unused"; - emit becameUnused(objectName()); + if (!d->checkUsageTimer.isActive()) { + d->checkUsageTimer.start(10, this); + } +} + +void DataContainer::timerEvent(QTimerEvent * event) +{ + if (event->timerId() == d->checkUsageTimer.timerId()) { + if (d->relays.count() < 1 && + receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))) < 1) { + // 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(); } } diff --git a/datacontainer.h b/datacontainer.h index 746be5e40..3c196c10e 100644 --- a/datacontainer.h +++ b/datacontainer.h @@ -245,6 +245,11 @@ class PLASMA_EXPORT DataContainer : public QObject **/ void checkUsage(); + /** + * @reimp from QObject + */ + void timerEvent(QTimerEvent * event); + private: friend class SignalRelay; friend class DataContainerPrivate; @@ -253,7 +258,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()) }; diff --git a/private/datacontainer_p.h b/private/datacontainer_p.h index 59054d624..a3e1f00a8 100644 --- a/private/datacontainer_p.h +++ b/private/datacontainer_p.h @@ -20,11 +20,13 @@ #ifndef PLASMA_DATACONTAINER_P_H #define PLASMA_DATACONTAINER_P_H -#include -#include #include "servicejob.h" #include "storage_p.h" +#include +#include +#include + 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) { } @@ -71,14 +73,15 @@ public: DataEngine::Data data; QMap relayObjects; QMap 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