Qt: Add placeholders, minor revamps
Vicki Pfau vi@endrift.com
Thu, 21 Feb 2019 18:18:52 -0800
9 files changed,
22 insertions(+),
7 deletions(-)
M
src/platform/qt/BattleChipView.cpp
→
src/platform/qt/BattleChipView.cpp
@@ -11,6 +11,7 @@ #include "GBAApp.h"
#include <QtAlgorithms> #include <QFile> +#include <QFontMetrics> #include <QResource> #include <QStringList>@@ -32,6 +33,13 @@ title[8] = '\0';
core->getGameCode(core, title); QString qtitle(title); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + int size = QFontMetrics(QFont()).height() / ((int) ceil(devicePixelRatioF()) * 16); +#else + int size = QFontMetrics(QFont()).height() / (devicePixelRatio() * 16); +#endif + m_ui.chipList->setGridSize(m_ui.chipList->gridSize() * size); + m_ui.chipList->setIconSize(m_ui.chipList->iconSize() * size); connect(m_ui.chipId, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), m_ui.inserted, [this]() { m_ui.inserted->setChecked(Qt::Unchecked);@@ -124,7 +132,11 @@ return;
} QListWidgetItem* add = new QListWidgetItem(m_chipIdToName[insertedChip]); add->setData(Qt::UserRole, insertedChip); - add->setIcon(QIcon(QString(":/res/exe%1/%2.png").arg(m_flavor).arg(insertedChip, 3, 10, QLatin1Char('0')))); + QString path = QString(":/res/exe%1/%2.png").arg(m_flavor).arg(insertedChip, 3, 10, QLatin1Char('0')); + if (!QFile(path).exists()) { + path = QString(":/res/exe%1/placeholder.png").arg(m_flavor); + } + add->setIcon(QIcon(path)); m_ui.chipList->addItem(add); }@@ -143,7 +155,7 @@ flavor = GBA_FLAVOR_BEAST_LINK_GATE;
} m_flavor = flavor; - QFile file(QString(":/res/chip-names-%1.txt").arg(flavor)); + QFile file(QString(":/res/exe%1/chip-names.txt").arg(flavor)); file.open(QIODevice::ReadOnly | QIODevice::Text); int id = 0; while (true) {
M
src/platform/qt/BattleChipView.ui
→
src/platform/qt/BattleChipView.ui
@@ -151,8 +151,8 @@ <enum>QListView::Adjust</enum>
</property> <property name="gridSize"> <size> - <width>160</width> - <height>128</height> + <width>80</width> + <height>72</height> </size> </property> <property name="viewMode">
M
src/platform/qt/resources.qrc
→
src/platform/qt/resources.qrc
@@ -4,8 +4,11 @@ <file>../../../res/mgba-1024.png</file>
<file>../../../res/keymap.qpic</file> <file>../../../res/patrons.txt</file> <file>../../../res/no-cam.png</file> - <file>../../../res/chip-names-4.txt</file> - <file>../../../res/chip-names-5.txt</file> - <file>../../../res/chip-names-6.txt</file> + <file>../../../res/exe4/chip-names.txt</file> + <file>../../../res/exe4/placeholder.png</file> + <file>../../../res/exe5/chip-names.txt</file> + <file>../../../res/exe5/placeholder.png</file> + <file>../../../res/exe6/chip-names.txt</file> + <file>../../../res/exe6/placeholder.png</file> </qresource> </RCC>