From 3d7fdf0eda0a8dd0f318e29974319ffe3a3f88a0 Mon Sep 17 00:00:00 2001 From: cold-brewed Date: Thu, 8 Sep 2022 11:19:37 -0400 Subject: [PATCH] qt: Fix searching for icon packs in roms dir --- src/qt/qt_progsettings.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/qt/qt_progsettings.cpp b/src/qt/qt_progsettings.cpp index 0b4f0e955..dcfdbab85 100644 --- a/src/qt/qt_progsettings.cpp +++ b/src/qt/qt_progsettings.cpp @@ -33,6 +33,8 @@ extern "C" #include <86box/version.h> #include <86box/config.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; QString ProgSettings::getIconSetPath() { - QString roms_root; - if (rom_path[0]) - roms_root = rom_path; - else { - roms_root = QString("%1/roms").arg(exe_path); - } - - if (iconset_to_qt.isEmpty()) - { + if (iconset_to_qt.isEmpty()) { + QVector roms_dirs; + // Walk rom_paths to get the candidates + for (rom_path_t *emu_rom_path = &rom_paths; emu_rom_path != nullptr; emu_rom_path = emu_rom_path->next) { + roms_dirs.append(QFileInfo(emu_rom_path->path)); + } + // Always include default bundled icons iconset_to_qt.insert("", ":/settings/win/icons"); - QDir dir(roms_root + "/icons/"); - if (dir.isReadable()) - { - auto dirList = dir.entryList(QDir::AllDirs | QDir::Executable | QDir::Readable); - for (auto &curIconSet : dirList) - { - if (curIconSet == "." || curIconSet == "..") continue; - iconset_to_qt.insert(curIconSet, (dir.canonicalPath() + '/') + curIconSet); + for (auto &checked_dir : roms_dirs) { + // Check for icons subdir in each candidate + QDir roms_icons_dir(checked_dir.filePath() + "/icons"); + if (roms_icons_dir.isReadable()) { + auto dirList = roms_icons_dir.entryList(QDir::AllDirs | QDir::Executable | QDir::Readable); + for (auto &curIconSet : dirList) { + if (curIconSet == "." || curIconSet == "..") { + continue; + } + iconset_to_qt.insert(curIconSet, (roms_icons_dir.canonicalPath() + '/') + curIconSet); + } } } }