qt: Fix searching for icon packs in roms dir

This commit is contained in:
cold-brewed
2022-09-08 11:19:37 -04:00
parent d2dc53fbfb
commit 3d7fdf0eda

View File

@@ -33,6 +33,8 @@ extern "C"
#include <86box/version.h> #include <86box/version.h>
#include <86box/config.h> #include <86box/config.h>
#include <86box/plat.h> #include <86box/plat.h>
#include <86box/mem.h>
#include <86box/rom.h>
} }
@@ -43,24 +45,25 @@ ProgSettings::CustomTranslator* ProgSettings::translator = nullptr;
QTranslator* ProgSettings::qtTranslator = nullptr; QTranslator* ProgSettings::qtTranslator = nullptr;
QString ProgSettings::getIconSetPath() QString ProgSettings::getIconSetPath()
{ {
QString roms_root; if (iconset_to_qt.isEmpty()) {
if (rom_path[0]) QVector<QFileInfo> roms_dirs;
roms_root = rom_path; // Walk rom_paths to get the candidates
else { for (rom_path_t *emu_rom_path = &rom_paths; emu_rom_path != nullptr; emu_rom_path = emu_rom_path->next) {
roms_root = QString("%1/roms").arg(exe_path); roms_dirs.append(QFileInfo(emu_rom_path->path));
} }
// Always include default bundled icons
if (iconset_to_qt.isEmpty())
{
iconset_to_qt.insert("", ":/settings/win/icons"); iconset_to_qt.insert("", ":/settings/win/icons");
QDir dir(roms_root + "/icons/"); for (auto &checked_dir : roms_dirs) {
if (dir.isReadable()) // Check for icons subdir in each candidate
{ QDir roms_icons_dir(checked_dir.filePath() + "/icons");
auto dirList = dir.entryList(QDir::AllDirs | QDir::Executable | QDir::Readable); if (roms_icons_dir.isReadable()) {
for (auto &curIconSet : dirList) auto dirList = roms_icons_dir.entryList(QDir::AllDirs | QDir::Executable | QDir::Readable);
{ for (auto &curIconSet : dirList) {
if (curIconSet == "." || curIconSet == "..") continue; if (curIconSet == "." || curIconSet == "..") {
iconset_to_qt.insert(curIconSet, (dir.canonicalPath() + '/') + curIconSet); continue;
}
iconset_to_qt.insert(curIconSet, (roms_icons_dir.canonicalPath() + '/') + curIconSet);
}
} }
} }
} }