Changeset View
Changeset View
Standalone View
Standalone View
src/covermanager/CoverCache.cpp
Show All 19 Lines | |||||
20 | #include "core/support/Amarok.h" | 20 | #include "core/support/Amarok.h" | ||
21 | 21 | | |||
22 | #include <QDir> | 22 | #include <QDir> | ||
23 | #include <QImage> | 23 | #include <QImage> | ||
24 | #include <QMutexLocker> | 24 | #include <QMutexLocker> | ||
25 | #include <QPixmapCache> | 25 | #include <QPixmapCache> | ||
26 | #include <QReadWriteLock> | 26 | #include <QReadWriteLock> | ||
27 | #include <QReadLocker> | 27 | #include <QReadLocker> | ||
28 | #include <QStandardPaths> | ||||
28 | #include <QWriteLocker> | 29 | #include <QWriteLocker> | ||
29 | 30 | | |||
30 | #include <QStandardPaths> | | |||
31 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
32 | 32 | | |||
33 | #include <thread> | ||||
34 | | ||||
33 | CoverCache* CoverCache::s_instance = 0; | 35 | CoverCache* CoverCache::s_instance = 0; | ||
34 | 36 | | |||
35 | CoverCache* | 37 | CoverCache* | ||
36 | CoverCache::instance() | 38 | CoverCache::instance() | ||
37 | { | 39 | { | ||
38 | return s_instance ? s_instance : (s_instance = new CoverCache()); | 40 | return s_instance ? s_instance : (s_instance = new CoverCache()); | ||
39 | } | 41 | } | ||
40 | 42 | | |||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 101 | { | |||
110 | if( cacheCoverDir.exists( noCoverKey ) ) | 112 | if( cacheCoverDir.exists( noCoverKey ) ) | ||
111 | { | 113 | { | ||
112 | pixmap.load( cacheCoverDir.filePath( noCoverKey ) ); | 114 | pixmap.load( cacheCoverDir.filePath( noCoverKey ) ); | ||
113 | } | 115 | } | ||
114 | else | 116 | else | ||
115 | { | 117 | { | ||
116 | const QPixmap orgPixmap( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/nocover.png" ) ); | 118 | const QPixmap orgPixmap( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/nocover.png" ) ); | ||
117 | pixmap = orgPixmap.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); | 119 | pixmap = orgPixmap.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); | ||
118 | pixmap.save( cacheCoverDir.filePath( noCoverKey ), "PNG" ); | 120 | std::thread thread( QOverload<const QString&, const char*, int>::of( &QPixmap::save ), pixmap, cacheCoverDir.filePath( noCoverKey ), "PNG", -1 ); | ||
121 | thread.detach(); | ||||
119 | } | 122 | } | ||
120 | QPixmapCache::insert( noCoverKey, pixmap ); | 123 | QPixmapCache::insert( noCoverKey, pixmap ); | ||
121 | return pixmap; | 124 | return pixmap; | ||
122 | } | 125 | } | ||
123 | 126 | | |||
124 | pixmap = QPixmap::fromImage( image ); | 127 | pixmap = QPixmap::fromImage( image ); | ||
125 | 128 | | |||
126 | // -- add the cover to the cache if not full-scale or too big | 129 | // -- add the cover to the cache if not full-scale or too big | ||
Show All 17 Lines |