mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-02 10:36:45 +01:00
Use static QPixmapCache everywhere
This commit is contained in:
parent
b8b21d53e1
commit
f21be30004
@ -43,6 +43,7 @@
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
#include <QColor>
|
||||
@ -794,7 +795,7 @@ QString InternetSearchView::PixmapCacheKey(const InternetSearchView::Result &res
|
||||
}
|
||||
|
||||
bool InternetSearchView::FindCachedPixmap(const InternetSearchView::Result &result, QPixmap *pixmap) const {
|
||||
return pixmap_cache_.find(result.pixmap_cache_key_, pixmap);
|
||||
return QPixmapCache::find(result.pixmap_cache_key_, pixmap);
|
||||
}
|
||||
|
||||
void InternetSearchView::LazyLoadAlbumCover(const QModelIndex &proxy_index) {
|
||||
@ -840,7 +841,7 @@ void InternetSearchView::LazyLoadAlbumCover(const QModelIndex &proxy_index) {
|
||||
const InternetSearchView::Result result = item_song->data(InternetSearchModel::Role_Result).value<InternetSearchView::Result>();
|
||||
|
||||
QPixmap cached_pixmap;
|
||||
if (pixmap_cache_.find(result.pixmap_cache_key_, &cached_pixmap)) {
|
||||
if (QPixmapCache::find(result.pixmap_cache_key_, &cached_pixmap)) {
|
||||
item_album->setData(cached_pixmap, Qt::DecorationRole);
|
||||
}
|
||||
else {
|
||||
@ -861,7 +862,7 @@ void InternetSearchView::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoad
|
||||
if (albumcover_result.success && !albumcover_result.image_scaled.isNull()) {
|
||||
QPixmap pixmap = QPixmap::fromImage(albumcover_result.image_scaled);
|
||||
if (!pixmap.isNull()) {
|
||||
pixmap_cache_.insert(key, pixmap);
|
||||
QPixmapCache::insert(key, pixmap);
|
||||
}
|
||||
if (idx.isValid()) {
|
||||
QStandardItem *item = front_model_->itemFromIndex(idx);
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "core/song.h"
|
||||
@ -216,7 +215,6 @@ class InternetSearchView : public QWidget {
|
||||
|
||||
AlbumCoverLoaderOptions cover_loader_options_;
|
||||
QMap<quint64, QPair<QModelIndex, QString>> cover_loader_tasks_;
|
||||
QPixmapCache pixmap_cache_;
|
||||
|
||||
};
|
||||
Q_DECLARE_METATYPE(InternetSearchView::Result)
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <QUrl>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPainter>
|
||||
#include <QColor>
|
||||
#include <QPen>
|
||||
@ -469,13 +470,13 @@ QPixmap SongSourceDelegate::LookupPixmap(const Song::Source source, const QSize
|
||||
|
||||
QPixmap pixmap;
|
||||
QString cache_key = QString("%1-%2x%3").arg(Song::TextForSource(source)).arg(size.width()).arg(size.height());
|
||||
if (pixmap_cache_.find(cache_key, &pixmap)) {
|
||||
if (QPixmapCache::find(cache_key, &pixmap)) {
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QIcon icon(Song::IconForSource(source));
|
||||
pixmap = icon.pixmap(size.height());
|
||||
pixmap_cache_.insert(cache_key, pixmap);
|
||||
QPixmapCache::insert(cache_key, pixmap);
|
||||
|
||||
return pixmap;
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include <QVariant>
|
||||
#include <QUrl>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QColor>
|
||||
@ -203,8 +202,6 @@ class SongSourceDelegate : public PlaylistDelegateBase {
|
||||
|
||||
private:
|
||||
QPixmap LookupPixmap(const Song::Source source, const QSize size) const;
|
||||
|
||||
mutable QPixmapCache pixmap_cache_;
|
||||
};
|
||||
|
||||
class RatingItemDelegate : public PlaylistDelegateBase {
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "core/simpletreemodel.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user