Qt: Expand romFilters functionality

This commit is contained in:
Vicki Pfau 2023-09-12 01:55:14 -07:00
parent 131b983894
commit 8610147ad7
2 changed files with 38 additions and 21 deletions

View File

@ -65,13 +65,19 @@ bool convertAddress(const QHostAddress* input, Address* output) {
return true;
}
QString romFilters(bool includeMvl) {
QString romFilters(bool includeMvl, mPlatform platform, bool rawOnly) {
QStringList filters;
QStringList formats;
#ifdef M_CORE_GBA
QStringList gbaFormats{
"*.gba",
"*.agb",
"*.mb",
"*.rom",
"*.bin"};
if (!rawOnly) {
gbaFormats += QStringList{
#if defined(USE_LIBZIP) || defined(USE_MINIZIP)
"*.zip",
#endif
@ -81,12 +87,14 @@ QString romFilters(bool includeMvl) {
#ifdef USE_ELF
"*.elf",
#endif
"*.agb",
"*.mb",
"*.rom",
"*.bin"};
};
}
if (platform == mPLATFORM_NONE || platform == mPLATFORM_GBA) {
formats.append(gbaFormats);
}
if (platform == mPLATFORM_NONE) {
filters.append(QCoreApplication::translate("QGBA", "Game Boy Advance ROMs (%1)", nullptr).arg(gbaFormats.join(QChar(' '))));
}
#endif
#ifdef M_CORE_GB
@ -94,16 +102,25 @@ QString romFilters(bool includeMvl) {
"*.gb",
"*.gbc",
"*.sgb",
"*.rom",
"*.bin"};
if (!rawOnly) {
gbFormats += QStringList{
#if defined(USE_LIBZIP) || defined(USE_MINIZIP)
"*.zip",
#endif
#ifdef USE_LZMA
"*.7z",
#endif
"*.rom",
"*.bin"};
};
}
if (platform == mPLATFORM_NONE || platform == mPLATFORM_GBA) {
formats.append(gbFormats);
}
if (platform == mPLATFORM_NONE) {
filters.append(QCoreApplication::translate("QGBA", "Game Boy ROMs (%1)", nullptr).arg(gbFormats.join(QChar(' '))));
}
#endif
formats.removeDuplicates();

View File

@ -112,7 +112,7 @@ constexpr int saturateCast<int, unsigned>(unsigned value) {
return static_cast<int>(value);
}
QString romFilters(bool includeMvl = false);
QString romFilters(bool includeMvl = false, mPlatform platform = mPLATFORM_NONE, bool rawOnly = false);
bool extractMatchingFile(VDir* dir, std::function<QString (VDirEntry*)> filter);
QString keyName(int key);