From 8fb3085b0778ccdb90fdca91a7600b89db518b3b Mon Sep 17 00:00:00 2001 From: spycrab Date: Mon, 30 Jul 2018 03:16:37 +0200 Subject: Revert "Revert "Qt/GameList: Add option to show covers in grid mode"" --- Source/Core/DolphinQt/GameList/GridProxyModel.cpp | 35 +++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'Source/Core/DolphinQt/GameList/GridProxyModel.cpp') diff --git a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp index 516357ac76..36df8306c0 100644 --- a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp +++ b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp @@ -4,11 +4,16 @@ #include "DolphinQt/GameList/GridProxyModel.h" +#include #include #include #include "DolphinQt/GameList/GameListModel.h" +#include "Core/Config/UISettings.h" + +#include "UICommon/GameFile.h" + const QSize LARGE_BANNER_SIZE(144, 48); GridProxyModel::GridProxyModel(QObject* parent) : QSortFilterProxyModel(parent) @@ -27,12 +32,30 @@ QVariant GridProxyModel::data(const QModelIndex& i, int role) const } else if (role == Qt::DecorationRole) { - auto pixmap = sourceModel() - ->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER), - Qt::DecorationRole) - .value(); - return pixmap.scaled(LARGE_BANNER_SIZE * pixmap.devicePixelRatio(), Qt::KeepAspectRatio, - Qt::SmoothTransformation); + auto* model = static_cast(sourceModel()); + + const auto& buffer = model->GetGameFile(source_index.row())->GetCoverImage().buffer; + + QPixmap pixmap; + + if (buffer.empty() || !Config::Get(Config::MAIN_USE_GAME_COVERS)) + { + pixmap = 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); + } + else + { + pixmap = QPixmap::fromImage(QImage::fromData( + reinterpret_cast(&buffer[0]), static_cast(buffer.size()))); + + return pixmap.scaled(QSize(160, 224) * model->GetScale() * pixmap.devicePixelRatio(), + Qt::KeepAspectRatio, Qt::SmoothTransformation); + } } return QVariant(); } -- cgit v1.2.3