diff options
| -rw-r--r-- | src/yuzu/game_list.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index a0e16641d..24f38a3c7 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -258,18 +258,20 @@ void GameList::AddEntry(const QList<QStandardItem*>& entry_items) { | |||
| 258 | 258 | ||
| 259 | void GameList::ValidateEntry(const QModelIndex& item) { | 259 | void GameList::ValidateEntry(const QModelIndex& item) { |
| 260 | // We don't care about the individual QStandardItem that was selected, but its row. | 260 | // We don't care about the individual QStandardItem that was selected, but its row. |
| 261 | int row = item_model->itemFromIndex(item)->row(); | 261 | const int row = item_model->itemFromIndex(item)->row(); |
| 262 | QStandardItem* child_file = item_model->invisibleRootItem()->child(row, COLUMN_NAME); | 262 | const QStandardItem* child_file = item_model->invisibleRootItem()->child(row, COLUMN_NAME); |
| 263 | QString file_path = child_file->data(GameListItemPath::FullPathRole).toString(); | 263 | const QString file_path = child_file->data(GameListItemPath::FullPathRole).toString(); |
| 264 | 264 | ||
| 265 | if (file_path.isEmpty()) | 265 | if (file_path.isEmpty()) |
| 266 | return; | 266 | return; |
| 267 | std::string std_file_path(file_path.toStdString()); | 267 | |
| 268 | if (!FileUtil::Exists(std_file_path)) | 268 | if (!QFileInfo::exists(file_path)) |
| 269 | return; | 269 | return; |
| 270 | if (FileUtil::IsDirectory(std_file_path)) { | 270 | |
| 271 | QDir dir(std_file_path.c_str()); | 271 | const QFileInfo file_info{file_path}; |
| 272 | QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files); | 272 | if (file_info.isDir()) { |
| 273 | const QDir dir{file_path}; | ||
| 274 | const QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files); | ||
| 273 | if (matching_main.size() == 1) { | 275 | if (matching_main.size() == 1) { |
| 274 | emit GameChosen(dir.path() + DIR_SEP + matching_main[0]); | 276 | emit GameChosen(dir.path() + DIR_SEP + matching_main[0]); |
| 275 | } | 277 | } |
| @@ -368,21 +370,23 @@ void GameList::LoadInterfaceLayout() { | |||
| 368 | const QStringList GameList::supported_file_extensions = {"nso", "nro", "nca", "xci"}; | 370 | const QStringList GameList::supported_file_extensions = {"nso", "nro", "nca", "xci"}; |
| 369 | 371 | ||
| 370 | static bool HasSupportedFileExtension(const std::string& file_name) { | 372 | static bool HasSupportedFileExtension(const std::string& file_name) { |
| 371 | QFileInfo file = QFileInfo(file_name.c_str()); | 373 | const QFileInfo file = QFileInfo(QString::fromStdString(file_name)); |
| 372 | return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive); | 374 | return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive); |
| 373 | } | 375 | } |
| 374 | 376 | ||
| 375 | static bool IsExtractedNCAMain(const std::string& file_name) { | 377 | static bool IsExtractedNCAMain(const std::string& file_name) { |
| 376 | return QFileInfo(file_name.c_str()).fileName() == "main"; | 378 | return QFileInfo(QString::fromStdString(file_name)).fileName() == "main"; |
| 377 | } | 379 | } |
| 378 | 380 | ||
| 379 | static QString FormatGameName(const std::string& physical_name) { | 381 | static QString FormatGameName(const std::string& physical_name) { |
| 380 | QFileInfo file_info(physical_name.c_str()); | 382 | const QString physical_name_as_qstring = QString::fromStdString(physical_name); |
| 383 | const QFileInfo file_info(physical_name_as_qstring); | ||
| 384 | |||
| 381 | if (IsExtractedNCAMain(physical_name)) { | 385 | if (IsExtractedNCAMain(physical_name)) { |
| 382 | return file_info.dir().path(); | 386 | return file_info.dir().path(); |
| 383 | } else { | ||
| 384 | return QString::fromStdString(physical_name); | ||
| 385 | } | 387 | } |
| 388 | |||
| 389 | return physical_name_as_qstring; | ||
| 386 | } | 390 | } |
| 387 | 391 | ||
| 388 | void GameList::RefreshGameDirectory() { | 392 | void GameList::RefreshGameDirectory() { |