Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-08-22 16:30:38 +03:00
parent 18df74394a
commit 5681751ab4
4 changed files with 17 additions and 17 deletions

View File

@ -1,14 +1,15 @@
#include "IconImageProvider.h"
IconImageProvider::IconImageProvider(std::shared_ptr<IconList> iconList, int iconSize) : QQuickImageProvider(QQuickImageProvider::Pixmap), m_iconList(iconList), m_iconSize(iconSize)
{
}
IconImageProvider::IconImageProvider(std::shared_ptr<IconList> iconList, int iconSize)
: QQuickImageProvider(QQuickImageProvider::Pixmap), m_iconList(iconList), m_iconSize(iconSize)
{}
QPixmap IconImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
QPixmap IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize)
{
if (size)
*size = QSize(m_iconSize, m_iconSize);
QIcon i = m_iconList->getIcon(id);
return i.pixmap(requestedSize.width() > 0 ? requestedSize.width() : m_iconSize, requestedSize.height() > 0 ? requestedSize.height() : m_iconSize);
return i.pixmap(requestedSize.width() > 0 ? requestedSize.width() : m_iconSize,
requestedSize.height() > 0 ? requestedSize.height() : m_iconSize);
}

View File

@ -3,14 +3,13 @@
#include <QQuickImageProvider>
class IconImageProvider : public QQuickImageProvider
{
public:
class IconImageProvider : public QQuickImageProvider {
public:
IconImageProvider(std::shared_ptr<IconList> iconList, int iconSize = 48);
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override;
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override;
private:
private:
std::shared_ptr<IconList> m_iconList;
int m_iconSize;
};