summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/GameList/GridProxyModel.cpp
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2018-07-30 03:16:37 +0200
committerspycrab <spycrab@users.noreply.github.com>2018-07-30 03:16:37 +0200
commit8fb3085b0778ccdb90fdca91a7600b89db518b3b (patch)
tree9beda711a1c742ef302950b56c10f0793cca98b3 /Source/Core/DolphinQt/GameList/GridProxyModel.cpp
parentae0748ab078c1853c9e74ed8ebe729e44b6b03a2 (diff)
Revert "Revert "Qt/GameList: Add option to show covers in grid mode""
Diffstat (limited to 'Source/Core/DolphinQt/GameList/GridProxyModel.cpp')
-rw-r--r--Source/Core/DolphinQt/GameList/GridProxyModel.cpp35
1 files changed, 29 insertions, 6 deletions
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 <QImage>
#include <QPixmap>
#include <QSize>
#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<QPixmap>();
- return pixmap.scaled(LARGE_BANNER_SIZE * pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
- Qt::SmoothTransformation);
+ auto* model = static_cast<GameListModel*>(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<QPixmap>();
+
+ return pixmap.scaled(LARGE_BANNER_SIZE * model->GetScale() * pixmap.devicePixelRatio(),
+ Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
+ else
+ {
+ pixmap = QPixmap::fromImage(QImage::fromData(
+ reinterpret_cast<const unsigned char*>(&buffer[0]), static_cast<int>(buffer.size())));
+
+ return pixmap.scaled(QSize(160, 224) * model->GetScale() * pixmap.devicePixelRatio(),
+ Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
}
return QVariant();
}