Use a smaller cover in the tray icon tooltip again. Fixes issue #1135

This commit is contained in:
David Sansome 2010-12-19 15:04:22 +00:00
parent 8bc23a4d66
commit 2d8028d89a
3 changed files with 17 additions and 2 deletions

View File

@ -25,6 +25,7 @@ namespace mpris {
ArtLoader::ArtLoader(QObject* parent)
: QObject(parent),
temp_file_pattern_(QDir::tempPath() + "/clementine-art-XXXXXX.jpg"),
cover_loader_(new BackgroundThreadImplementation<AlbumCoverLoader, AlbumCoverLoader>(this)),
id_(0)
{
@ -54,16 +55,26 @@ void ArtLoader::TempArtLoaded(quint64 id, const QImage& image) {
id_ = 0;
QString uri;
QString thumbnail_uri;
if (!image.isNull()) {
temp_art_.reset(new QTemporaryFile(QDir::tempPath() + "/clementine-art-XXXXXX.jpg"));
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();
image.scaledToHeight(120, Qt::SmoothTransformation)
.save(temp_art_thumbnail_->fileName(), "JPEG");
uri = "file://" + temp_art_->fileName();
thumbnail_uri = "file://" + temp_art_thumbnail_->fileName();
}
emit ArtLoaded(last_song_, uri);
emit ThumbnailLoaded(last_song_, thumbnail_uri);
}

View File

@ -47,13 +47,17 @@ public slots:
signals:
void ArtLoaded(const Song& song, const QString& uri);
void ThumbnailLoaded(const Song& song, const QString& uri);
private slots:
void Initialised();
void TempArtLoaded(quint64 id, const QImage& image);
private:
QString temp_file_pattern_;
boost::scoped_ptr<QTemporaryFile> temp_art_;
boost::scoped_ptr<QTemporaryFile> temp_art_thumbnail_;
BackgroundThread<AlbumCoverLoader>* cover_loader_;
quint64 id_;

View File

@ -391,7 +391,7 @@ MainWindow::MainWindow(Engine::Type engine, QWidget *parent)
connect(playlists_, SIGNAL(SummaryTextChanged(QString)), ui_->playlist_summary, SLOT(setText(QString)));
connect(playlists_, SIGNAL(PlayRequested(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
connect(player_->ArtLoader(), SIGNAL(ArtLoaded(Song,QString)), osd_, SLOT(CoverArtPathReady(Song,QString)));
connect(player_->ArtLoader(), SIGNAL(ThumbnailLoaded(Song,QString)), osd_, SLOT(CoverArtPathReady(Song,QString)));
connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
connect(ui_->playlist->view(), SIGNAL(PlayPauseItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));