mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
Qt: properly scale icons in trophy manager
This commit is contained in:
parent
76a1fd5c88
commit
65134f73d6
1 changed files with 30 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
|||
#include "trophy_manager_dialog.h"
|
||||
#include "trophy_manager_dialog.h"
|
||||
#include "custom_table_widget_item.h"
|
||||
#include "table_item_delegate.h"
|
||||
#include "qt_utils.h"
|
||||
|
@ -470,23 +470,22 @@ void trophy_manager_dialog::HandleRepaintUiRequest()
|
|||
void trophy_manager_dialog::ResizeGameIcon(int index)
|
||||
{
|
||||
QTableWidgetItem* item = m_game_table->item(index, GameColumns::GameIcon);
|
||||
const QPixmap pixmap = item->data(Qt::UserRole).value<QPixmap>();
|
||||
const QSize original_size = pixmap.size();
|
||||
const QPixmap icon = item->data(Qt::UserRole).value<QPixmap>();
|
||||
const int dpr = devicePixelRatio();
|
||||
|
||||
QPixmap new_pixmap = QPixmap(original_size);
|
||||
new_pixmap.fill(m_game_icon_color);
|
||||
QPixmap new_icon = QPixmap(icon.size() * dpr);
|
||||
new_icon.setDevicePixelRatio(dpr);
|
||||
new_icon.fill(m_game_icon_color);
|
||||
|
||||
QPainter painter(&new_pixmap);
|
||||
|
||||
if (!pixmap.isNull())
|
||||
if (!icon.isNull())
|
||||
{
|
||||
painter.drawPixmap(QPoint(0, 0), pixmap);
|
||||
QPainter painter(&new_icon);
|
||||
painter.drawPixmap(QPoint(0, 0), icon);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
painter.end();
|
||||
|
||||
const QPixmap scaled = new_pixmap.scaled(m_game_icon_size, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation);
|
||||
item->setData(Qt::DecorationRole, scaled);
|
||||
const QPixmap scaled_icon = new_icon.scaled(m_game_icon_size * dpr, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation);
|
||||
item->setData(Qt::DecorationRole, scaled_icon);
|
||||
}
|
||||
|
||||
void trophy_manager_dialog::ResizeGameIcons()
|
||||
|
@ -507,12 +506,27 @@ void trophy_manager_dialog::ResizeTrophyIcons()
|
|||
if (m_game_combo->count() <= 0)
|
||||
return;
|
||||
|
||||
int db_pos = m_game_combo->currentData().toInt();
|
||||
const int db_pos = m_game_combo->currentData().toInt();
|
||||
const int dpr = devicePixelRatio();
|
||||
const int new_height = m_icon_height * dpr;
|
||||
|
||||
for (int i = 0; i < m_trophy_table->rowCount(); ++i)
|
||||
{
|
||||
int trophy_id = m_trophy_table->item(i, TrophyColumns::Id)->text().toInt();
|
||||
QPixmap scaled = m_trophies_db[db_pos]->trophy_images[trophy_id].scaledToHeight(m_icon_height, Qt::SmoothTransformation);
|
||||
const int trophy_id = m_trophy_table->item(i, TrophyColumns::Id)->text().toInt();
|
||||
const QPixmap icon = m_trophies_db[db_pos]->trophy_images[trophy_id];
|
||||
|
||||
QPixmap new_icon = QPixmap(icon.size() * dpr);
|
||||
new_icon.setDevicePixelRatio(dpr);
|
||||
new_icon.fill(m_game_icon_color);
|
||||
|
||||
if (!icon.isNull())
|
||||
{
|
||||
QPainter painter(&new_icon);
|
||||
painter.drawPixmap(QPoint(0, 0), icon);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
const QPixmap scaled = new_icon.scaledToHeight(new_height, Qt::SmoothTransformation);
|
||||
m_trophy_table->item(i, TrophyColumns::Icon)->setData(Qt::DecorationRole, scaled);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue