summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/designercore/imagecache/explicitimagecacheimageprovider.h
blob: bef22d68a7e01eacd867ec52646278ae50c13381 (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QQuickAsyncImageProvider>
#include <QQuickImageResponse>

namespace QmlDesigner {

class AsynchronousExplicitImageCache;

class ExplicitImageCacheImageProvider : public QQuickAsyncImageProvider
{
public:
    ExplicitImageCacheImageProvider(AsynchronousExplicitImageCache &imageCache,
                                    const QImage &defaultImage,
                                    const QImage &failedImage)
        : m_cache(imageCache)
        , m_defaultImage(defaultImage)
        , m_failedImage(failedImage)
    {}

    QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;

private:
    AsynchronousExplicitImageCache &m_cache;
    QImage m_defaultImage;
    QImage m_failedImage;
};

} // namespace QmlDesigner