From 2d8028d89a58cb2059a434b775b1ea36f1b591f9 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 19 Dec 2010 15:04:22 +0000 Subject: [PATCH] Use a smaller cover in the tray icon tooltip again. Fixes issue #1135 --- src/core/mpris_common.cpp | 13 ++++++++++++- src/core/mpris_common.h | 4 ++++ src/ui/mainwindow.cpp | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/core/mpris_common.cpp b/src/core/mpris_common.cpp index 797e35709..1e04159df 100644 --- a/src/core/mpris_common.cpp +++ b/src/core/mpris_common.cpp @@ -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(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); } diff --git a/src/core/mpris_common.h b/src/core/mpris_common.h index 9702aab99..bfdfe3b2d 100644 --- a/src/core/mpris_common.h +++ b/src/core/mpris_common.h @@ -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 temp_art_; + boost::scoped_ptr temp_art_thumbnail_; BackgroundThread* cover_loader_; quint64 id_; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 5008a8711..fc3c8787d 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -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)));