void ArtLoader::TempArtLoaded(quint64 id, const QImage& image) {
  if (id != id_)
    return;
  id_ = 0;

  QString uri;
  QString thumbnail_uri;
  QImage thumbnail;

  if (!image.isNull()) {
    temp_art_.reset(new QTemporaryFile(temp_file_pattern_));
    temp_art_->open();
    image.save(temp_art_->fileName(), "JPEG");

    // Scale the image down to make a thumbnail.  It's a bit crap doing it here
    // since it's the GUI thread, but the alternative is hard.
    temp_art_thumbnail_.reset(new QTemporaryFile(temp_file_pattern_));
    temp_art_thumbnail_->open();
    thumbnail = image.scaledToHeight(120, Qt::SmoothTransformation);
    thumbnail.save(temp_art_thumbnail_->fileName(), "JPEG");

    uri = "file://" + temp_art_->fileName();
    thumbnail_uri = "file://" + temp_art_thumbnail_->fileName();
  }

  emit ArtLoaded(last_song_, uri, image);
  emit ThumbnailLoaded(last_song_, thumbnail_uri, thumbnail);
}
Example #2
0
OSD::OSD(SystemTrayIcon* tray_icon, Application* app, QObject* parent)
  : QObject(parent),
    tray_icon_(tray_icon),
    app_(app),
    timeout_msec_(5000),
    behaviour_(Native),
    show_on_volume_change_(false),
    show_art_(true),
    show_on_play_mode_change_(true),
    use_custom_text_(false),
    custom_text1_(QString()),
    custom_text2_(QString()),
    preview_mode_(false),
    force_show_next_(false),
    ignore_next_stopped_(false),
    pretty_popup_(new OSDPretty(OSDPretty::Mode_Popup))
{
  connect(app_->current_art_loader(), SIGNAL(ThumbnailLoaded(Song,QString,QImage)),
          SLOT(AlbumArtLoaded(Song,QString,QImage)));

  ReloadSettings();
  Init();
}