mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-23 07:12:46 +01:00
citra-qt: Don't attempt to scan files with unsupported extensions (#2402)
This commit is contained in:
parent
da6a40e3d1
commit
30ff675f02
3 changed files with 20 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
|
@ -131,6 +132,14 @@ void GameList::LoadInterfaceLayout() {
|
||||||
item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
|
item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QStringList GameList::supported_file_extensions = {"3ds", "3dsx", "elf", "axf",
|
||||||
|
"cci", "cxi", "app"};
|
||||||
|
|
||||||
|
static bool HasSupportedFileExtension(const std::string& file_name) {
|
||||||
|
QFileInfo file = QFileInfo(file_name.c_str());
|
||||||
|
return GameList::supported_file_extensions.contains(file.completeSuffix(), Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) {
|
void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) {
|
||||||
const auto callback = [this, recursion](unsigned* num_entries_out, const std::string& directory,
|
const auto callback = [this, recursion](unsigned* num_entries_out, const std::string& directory,
|
||||||
const std::string& virtual_name) -> bool {
|
const std::string& virtual_name) -> bool {
|
||||||
|
@ -139,7 +148,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
||||||
if (stop_processing)
|
if (stop_processing)
|
||||||
return false; // Breaks the callback loop.
|
return false; // Breaks the callback loop.
|
||||||
|
|
||||||
if (!FileUtil::IsDirectory(physical_name)) {
|
if (!FileUtil::IsDirectory(physical_name) && HasSupportedFileExtension(physical_name)) {
|
||||||
std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(physical_name);
|
std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(physical_name);
|
||||||
if (!loader)
|
if (!loader)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
void SaveInterfaceLayout();
|
void SaveInterfaceLayout();
|
||||||
void LoadInterfaceLayout();
|
void LoadInterfaceLayout();
|
||||||
|
|
||||||
|
static const QStringList supported_file_extensions;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GameChosen(QString game_path);
|
void GameChosen(QString game_path);
|
||||||
void ShouldCancelWorker();
|
void ShouldCancelWorker();
|
||||||
|
|
|
@ -466,9 +466,14 @@ void GMainWindow::OnGameListOpenSaveFolder(u64 program_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnMenuLoadFile() {
|
void GMainWindow::OnMenuLoadFile() {
|
||||||
QString filename =
|
QString extensions;
|
||||||
QFileDialog::getOpenFileName(this, tr("Load File"), UISettings::values.roms_path,
|
for (const auto& piece : game_list->supported_file_extensions)
|
||||||
tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)"));
|
extensions += "*." + piece + " ";
|
||||||
|
|
||||||
|
QString file_filter = tr("3DS executable") + " (" + extensions + ")";
|
||||||
|
|
||||||
|
QString filename = QFileDialog::getOpenFileName(this, tr("Load File"),
|
||||||
|
UISettings::values.roms_path, file_filter);
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
UISettings::values.roms_path = QFileInfo(filename).path();
|
UISettings::values.roms_path = QFileInfo(filename).path();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue