mirror of https://github.com/mgba-emu/mgba.git
Qt: Re-add battle chip icon scaling
This commit is contained in:
parent
d1c6bcacd9
commit
6f7573dda4
|
@ -35,7 +35,7 @@ QVariant BattleChipModel::data(const QModelIndex& index, int role) const {
|
|||
case Qt::DisplayRole:
|
||||
return item.name;
|
||||
case Qt::DecorationRole:
|
||||
return item.icon;
|
||||
return item.icon.scaled(item.icon.size() * m_scale);
|
||||
case Qt::UserRole:
|
||||
return item.id;
|
||||
}
|
||||
|
@ -151,12 +151,16 @@ void BattleChipModel::clear() {
|
|||
endResetModel();
|
||||
}
|
||||
|
||||
void BattleChipModel::setScale(int scale) {
|
||||
m_scale = scale;
|
||||
}
|
||||
|
||||
BattleChipModel::BattleChip BattleChipModel::createChip(int id) const {
|
||||
QString path = QString(":/exe/exe%1/%2.png").arg(m_flavor).arg(id, 3, 10, QLatin1Char('0'));
|
||||
if (!QFile(path).exists()) {
|
||||
path = QString(":/exe/exe%1/placeholder.png").arg(m_flavor);
|
||||
}
|
||||
QIcon icon(path);
|
||||
QPixmap icon(path);
|
||||
|
||||
BattleChip chip = {
|
||||
id,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
||||
namespace QGBA {
|
||||
|
||||
|
@ -34,18 +34,20 @@ public slots:
|
|||
void removeChip(const QModelIndex&);
|
||||
void setChips(QList<int> ids);
|
||||
void clear();
|
||||
void setScale(int);
|
||||
|
||||
private:
|
||||
struct BattleChip {
|
||||
int id;
|
||||
QString name;
|
||||
QIcon icon;
|
||||
QPixmap icon;
|
||||
};
|
||||
|
||||
BattleChip createChip(int id) const;
|
||||
|
||||
QMap<int, QString> m_chipIdToName;
|
||||
int m_flavor;
|
||||
int m_scale = 1;
|
||||
|
||||
QList<BattleChip> m_deck;
|
||||
};
|
||||
|
|
|
@ -40,6 +40,7 @@ BattleChipView::BattleChipView(std::shared_ptr<CoreController> controller, Windo
|
|||
#endif
|
||||
m_ui.chipList->setIconSize(m_ui.chipList->iconSize() * size);
|
||||
m_ui.chipList->setGridSize(m_ui.chipList->gridSize() * size);
|
||||
m_model.setScale(size);
|
||||
|
||||
connect(m_ui.chipId, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), m_ui.inserted, [this]() {
|
||||
m_ui.inserted->setChecked(Qt::Unchecked);
|
||||
|
|
Loading…
Reference in New Issue