blob: b3530f3edbf267284b9ff22d3ece923c5bfbea4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <synchronousimagecache.h>
#include <QQuickImageProvider>
#include "asset.h"
namespace QmlDesigner {
struct Thumbnail
{
QPixmap pixmap;
QSize originalSize;
Asset::Type assetType;
qint64 fileSize;
};
class AssetsLibraryIconProvider : public QQuickImageProvider
{
public:
AssetsLibraryIconProvider(SynchronousImageCache &fontImageCache);
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override;
void clearCache();
void invalidateThumbnail(const QString &id);
QSize imageSize(const QString &id);
qint64 fileSize(const QString &id);
private:
QPixmap generateFontIcons(const QString &filePath, const QSize &requestedSize) const;
QPair<QPixmap, qint64> fetchPixmap(const QString &id, const QSize &requestedSize) const;
Thumbnail createThumbnail(const QString &id, const QSize &requestedSize);
SynchronousImageCache &m_fontImageCache;
// Generated icon sizes should contain all ItemLibraryResourceView needed icon sizes, and their
// x2 versions for HDPI sceens
std::vector<QSize> iconSizes = {{128, 128}, // Drag
{96, 96}, // list @2x
{48, 48}}; // list
QHash<QString, Thumbnail> m_thumbnails;
};
} // namespace QmlDesigner
|