From 9156f8f389a8b0bf17a20c5a3e4a24b59111073c Mon Sep 17 00:00:00 2001 From: Mark Furneaux Date: Thu, 1 May 2014 12:26:48 -0400 Subject: [PATCH] Fix oversized album cover art When viewing the "Full Size" album covers, if the cover was higher in resolution than that of the monitor, it would get cut off. Also, the window was resizable however the image was not. This patch makes the dialog a fixed size and resizes the cover only if it is too large to fit on the screen. It also now displays the dimentions of the original artwork in the title bar. --- src/ui/albumcoverchoicecontroller.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ui/albumcoverchoicecontroller.cpp b/src/ui/albumcoverchoicecontroller.cpp index d25918120..b4b94d955 100644 --- a/src/ui/albumcoverchoicecontroller.cpp +++ b/src/ui/albumcoverchoicecontroller.cpp @@ -30,6 +30,7 @@ #include "ui/iconloader.h" #include +#include #include #include #include @@ -205,13 +206,26 @@ void AlbumCoverChoiceController::ShowCover(const Song& song) { if (!song.album().isEmpty()) title_text += " - " + song.album(); - dialog->setWindowTitle(title_text); - QLabel* label = new QLabel(dialog); label->setPixmap(AlbumCoverLoader::TryLoadPixmap( song.art_automatic(), song.art_manual(), song.url().toLocalFile())); - dialog->resize(label->pixmap()->size()); + // add (WxHpx) to the title before possibly resizing + title_text += " (" + QString::number(label->pixmap()->width()) + + "x" + QString::number(label->pixmap()->height()) + "px)"; + + // if the cover is larger than the screen, resize the window + // 85% seems to be enough to account for title bar and taskbar etc. + QDesktopWidget desktop; + int desktop_height = desktop.geometry().height(); + const int new_height = (double)desktop_height * 0.85; + if (new_height < label->pixmap()->height()) { + label->setPixmap(label->pixmap()->scaledToHeight(new_height, + Qt::SmoothTransformation)); + } + + dialog->setWindowTitle(title_text); + dialog->setFixedSize(label->pixmap()->size()); dialog->show(); }