File indexing completed on 2024-12-08 09:28:59

0001 /*
0002     SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 #ifndef IMAGEPROVIDER_H_
0006 #define IMAGEPROVIDER_H_
0007 
0008 #include <QQuickImageProvider>
0009 
0010 /**
0011  * @class ImageProvider
0012  * This class makes it possible to use QImages from C++ in QML
0013  *
0014  * @author Artem Fedoskin
0015  * @version 1.0
0016  */
0017 class ImageProvider : public QQuickImageProvider
0018 {
0019     public:
0020         ImageProvider();
0021         /** @short Get image by id
0022              *  @return image of size requestedSize
0023              **/
0024         virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
0025         /**
0026              * @short Add image to the list of images with the given id
0027              */
0028         void addImage(const QString &id, QImage image);
0029 
0030     private:
0031         QHash<QString, QImage> images;
0032 };
0033 #endif