void PrettyImage::ImageFetched(RedirectFollower* follower) {
  follower->deleteLater();
  QNetworkReply* reply = follower->reply();
  reply->deleteLater();

  QImage image = QImage::fromData(reply->readAll());
  if (image.isNull()) {
    qLog(Debug) << "Image failed to load" << reply->request().url();
    deleteLater();
  } else {
    state_ = State_CreatingThumbnail;
    image_ = image;

    QFuture<QImage> future =
        QtConcurrent::run(image_, &QImage::scaled, image_size(),
                          Qt::KeepAspectRatio, Qt::SmoothTransformation);
    NewClosure(future, this, SLOT(ImageScaled(QFuture<QImage>)), future);
  }
}
Exemple #2
0
void PrettyImage::ImageFetched() {
  QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
  reply->deleteLater();

  QImage image = QImage::fromData(reply->readAll());
  if (image.isNull()) {
    deleteLater();
  } else {
    state_ = State_CreatingThumbnail;
    image_ = image;

    QFuture<QImage> future =
        QtConcurrent::run(image_, &QImage::scaled, image_size(),
                          Qt::KeepAspectRatio, Qt::SmoothTransformation);

    QFutureWatcher<QImage>* watcher = new QFutureWatcher<QImage>(this);
    watcher->setFuture(future);
    connect(watcher, SIGNAL(finished()), SLOT(ImageScaled()));
  }
}