mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 00:11:24 +12: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 "custom_table_widget_item.h"
|
||||||
#include "table_item_delegate.h"
|
#include "table_item_delegate.h"
|
||||||
#include "qt_utils.h"
|
#include "qt_utils.h"
|
||||||
|
@ -470,23 +470,22 @@ void trophy_manager_dialog::HandleRepaintUiRequest()
|
||||||
void trophy_manager_dialog::ResizeGameIcon(int index)
|
void trophy_manager_dialog::ResizeGameIcon(int index)
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = m_game_table->item(index, GameColumns::GameIcon);
|
QTableWidgetItem* item = m_game_table->item(index, GameColumns::GameIcon);
|
||||||
const QPixmap pixmap = item->data(Qt::UserRole).value<QPixmap>();
|
const QPixmap icon = item->data(Qt::UserRole).value<QPixmap>();
|
||||||
const QSize original_size = pixmap.size();
|
const int dpr = devicePixelRatio();
|
||||||
|
|
||||||
QPixmap new_pixmap = QPixmap(original_size);
|
QPixmap new_icon = QPixmap(icon.size() * dpr);
|
||||||
new_pixmap.fill(m_game_icon_color);
|
new_icon.setDevicePixelRatio(dpr);
|
||||||
|
new_icon.fill(m_game_icon_color);
|
||||||
|
|
||||||
QPainter painter(&new_pixmap);
|
if (!icon.isNull())
|
||||||
|
|
||||||
if (!pixmap.isNull())
|
|
||||||
{
|
{
|
||||||
painter.drawPixmap(QPoint(0, 0), pixmap);
|
QPainter painter(&new_icon);
|
||||||
|
painter.drawPixmap(QPoint(0, 0), icon);
|
||||||
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.end();
|
const QPixmap scaled_icon = new_icon.scaled(m_game_icon_size * dpr, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation);
|
||||||
|
item->setData(Qt::DecorationRole, scaled_icon);
|
||||||
const QPixmap scaled = new_pixmap.scaled(m_game_icon_size, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation);
|
|
||||||
item->setData(Qt::DecorationRole, scaled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void trophy_manager_dialog::ResizeGameIcons()
|
void trophy_manager_dialog::ResizeGameIcons()
|
||||||
|
@ -507,12 +506,27 @@ void trophy_manager_dialog::ResizeTrophyIcons()
|
||||||
if (m_game_combo->count() <= 0)
|
if (m_game_combo->count() <= 0)
|
||||||
return;
|
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)
|
for (int i = 0; i < m_trophy_table->rowCount(); ++i)
|
||||||
{
|
{
|
||||||
int trophy_id = m_trophy_table->item(i, TrophyColumns::Id)->text().toInt();
|
const 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 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);
|
m_trophy_table->item(i, TrophyColumns::Icon)->setData(Qt::DecorationRole, scaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue