From 2ea6cc66ba1ab1c15f7bb02ffdf6c6a443894294 Mon Sep 17 00:00:00 2001 From: spycrab Date: Sun, 19 Aug 2018 17:13:29 +0200 Subject: [PATCH] Qt/GridProxyModel: Ensure uniform sizes in cover mode --- .../DolphinQt/GameList/GridProxyModel.cpp | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp index 36df8306c0..d32d424c58 100644 --- a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp +++ b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp @@ -5,6 +5,7 @@ #include "DolphinQt/GameList/GridProxyModel.h" #include +#include #include #include @@ -36,17 +37,26 @@ QVariant GridProxyModel::data(const QModelIndex& i, int role) const const auto& buffer = model->GetGameFile(source_index.row())->GetCoverImage().buffer; - QPixmap pixmap; + QSize size = Config::Get(Config::MAIN_USE_GAME_COVERS) ? QSize(160, 224) : LARGE_BANNER_SIZE; + QPixmap pixmap(size * model->GetScale() * QPixmap().devicePixelRatio()); if (buffer.empty() || !Config::Get(Config::MAIN_USE_GAME_COVERS)) { - pixmap = model - ->data(model->index(source_index.row(), GameListModel::COL_BANNER), - Qt::DecorationRole) - .value(); + QPixmap banner = model + ->data(model->index(source_index.row(), GameListModel::COL_BANNER), + Qt::DecorationRole) + .value(); - return pixmap.scaled(LARGE_BANNER_SIZE * model->GetScale() * pixmap.devicePixelRatio(), - Qt::KeepAspectRatio, Qt::SmoothTransformation); + banner = banner.scaled(pixmap.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + + pixmap.fill(); + + QPainter painter(&pixmap); + + painter.drawPixmap(0, pixmap.height() / 2 - banner.height() / 2, banner.width(), + banner.height(), banner); + + return pixmap; } else {