qmlfrontend/preview_image_provider.cpp
author Wuzzy <Wuzzy@disroot.org>
Thu, 07 Apr 2022 08:15:08 +0200
changeset 15839 dd891c8e30c7
parent 14154 8354b390f1a2
permissions -rw-r--r--
Update Wuzzy's e-mail address in credits

#include "preview_image_provider.h"

PreviewImageProvider::PreviewImageProvider()
    : QQuickImageProvider(QQuickImageProvider::Pixmap) {}

QPixmap PreviewImageProvider::requestPixmap(const QString &id, QSize *size,
                                            const QSize &requestedSize) {
  Q_UNUSED(id);
  Q_UNUSED(requestedSize);

  if (size) *size = m_px.size();

  return m_px;
}

void PreviewImageProvider::setImage(const QImage &preview) {
  m_px = QPixmap::fromImage(preview, Qt::ColorOnly);
  // QPixmap pxres(px.size());
  // QPainter p(&pxres);

  // p.fillRect(pxres.rect(), linearGrad);
  // p.drawPixmap(0, 0, px);
}