From 2d8eba5bafd7fe9da00c8a57c605a503c3ece478 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Wed, 1 May 2019 23:21:04 +0200 Subject: yuzu: Add support for multiple game directories Ported from https://github.com/citra-emu/citra/pull/3617. --- src/yuzu/configuration/config.cpp | 42 ++++++++++++++++++++++++---- src/yuzu/configuration/configure_general.cpp | 5 ---- src/yuzu/configuration/configure_general.ui | 7 ----- 3 files changed, 36 insertions(+), 18 deletions(-) (limited to 'src/yuzu/configuration') diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 0456248ac..f2f116a87 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -517,10 +517,35 @@ void Config::ReadPathValues() { UISettings::values.roms_path = ReadSetting(QStringLiteral("romsPath")).toString(); UISettings::values.symbols_path = ReadSetting(QStringLiteral("symbolsPath")).toString(); UISettings::values.screenshot_path = ReadSetting(QStringLiteral("screenshotPath")).toString(); - UISettings::values.game_directory_path = + UISettings::values.game_dir_deprecated = ReadSetting(QStringLiteral("gameListRootDir"), QStringLiteral(".")).toString(); - UISettings::values.game_directory_deepscan = + UISettings::values.game_dir_deprecated_deepscan = ReadSetting(QStringLiteral("gameListDeepScan"), false).toBool(); + int gamedirs_size = qt_config->beginReadArray(QStringLiteral("gamedirs")); + for (int i = 0; i < gamedirs_size; ++i) { + qt_config->setArrayIndex(i); + UISettings::GameDir game_dir; + game_dir.path = ReadSetting(QStringLiteral("path")).toString(); + game_dir.deep_scan = ReadSetting(QStringLiteral("deep_scan"), false).toBool(); + game_dir.expanded = ReadSetting(QStringLiteral("expanded"), true).toBool(); + UISettings::values.game_dirs.append(game_dir); + } + qt_config->endArray(); + // create NAND and SD card directories if empty, these are not removable through the UI, + // also carries over old game list settings if present + if (UISettings::values.game_dirs.isEmpty()) { + UISettings::GameDir game_dir; + game_dir.path = QStringLiteral("INSTALLED"); + game_dir.expanded = true; + UISettings::values.game_dirs.append(game_dir); + game_dir.path = QStringLiteral("SYSTEM"); + UISettings::values.game_dirs.append(game_dir); + if (UISettings::values.game_dir_deprecated != QStringLiteral(".")) { + game_dir.path = UISettings::values.game_dir_deprecated; + game_dir.deep_scan = UISettings::values.game_dir_deprecated_deepscan; + UISettings::values.game_dirs.append(game_dir); + } + } UISettings::values.recent_files = ReadSetting(QStringLiteral("recentFiles")).toStringList(); qt_config->endGroup(); @@ -899,10 +924,15 @@ void Config::SavePathValues() { WriteSetting(QStringLiteral("romsPath"), UISettings::values.roms_path); WriteSetting(QStringLiteral("symbolsPath"), UISettings::values.symbols_path); WriteSetting(QStringLiteral("screenshotPath"), UISettings::values.screenshot_path); - WriteSetting(QStringLiteral("gameListRootDir"), UISettings::values.game_directory_path, - QStringLiteral(".")); - WriteSetting(QStringLiteral("gameListDeepScan"), UISettings::values.game_directory_deepscan, - false); + qt_config->beginWriteArray(QStringLiteral("gamedirs")); + for (int i = 0; i < UISettings::values.game_dirs.size(); ++i) { + qt_config->setArrayIndex(i); + const auto& game_dir = UISettings::values.game_dirs.at(i); + WriteSetting(QStringLiteral("path"), game_dir.path); + WriteSetting(QStringLiteral("deep_scan"), game_dir.deep_scan, false); + WriteSetting(QStringLiteral("expanded"), game_dir.expanded, true); + } + qt_config->endArray(); WriteSetting(QStringLiteral("recentFiles"), UISettings::values.recent_files); qt_config->endGroup(); diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 75fcbfea3..727836b17 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -19,22 +19,17 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) } SetConfiguration(); - - connect(ui->toggle_deepscan, &QCheckBox::stateChanged, this, - [] { UISettings::values.is_game_list_reload_pending.exchange(true); }); } ConfigureGeneral::~ConfigureGeneral() = default; void ConfigureGeneral::SetConfiguration() { - ui->toggle_deepscan->setChecked(UISettings::values.game_directory_deepscan); ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); } void ConfigureGeneral::ApplyConfiguration() { - UISettings::values.game_directory_deepscan = ui->toggle_deepscan->isChecked(); UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); UISettings::values.theme = diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 184fdd329..e747a4ce2 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui @@ -24,13 +24,6 @@ - - - - Search sub-directories for games - - - -- cgit v1.2.3 From 7a8f4840205799d837ac32401b4143c716a8bc3d Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Fri, 3 May 2019 19:21:57 +0200 Subject: Address trivial review comments --- src/yuzu/configuration/config.cpp | 4 +-- src/yuzu/game_list.cpp | 71 ++++++++++++++++++++------------------- src/yuzu/game_list.h | 2 +- src/yuzu/game_list_p.h | 21 +++++++----- src/yuzu/game_list_worker.cpp | 6 ++-- src/yuzu/main.cpp | 6 ++-- src/yuzu/main.h | 2 +- 7 files changed, 59 insertions(+), 53 deletions(-) (limited to 'src/yuzu/configuration') diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index f2f116a87..b2683faf8 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -521,7 +521,7 @@ void Config::ReadPathValues() { ReadSetting(QStringLiteral("gameListRootDir"), QStringLiteral(".")).toString(); UISettings::values.game_dir_deprecated_deepscan = ReadSetting(QStringLiteral("gameListDeepScan"), false).toBool(); - int gamedirs_size = qt_config->beginReadArray(QStringLiteral("gamedirs")); + const int gamedirs_size = qt_config->beginReadArray(QStringLiteral("gamedirs")); for (int i = 0; i < gamedirs_size; ++i) { qt_config->setArrayIndex(i); UISettings::GameDir game_dir; @@ -927,7 +927,7 @@ void Config::SavePathValues() { qt_config->beginWriteArray(QStringLiteral("gamedirs")); for (int i = 0; i < UISettings::values.game_dirs.size(); ++i) { qt_config->setArrayIndex(i); - const auto& game_dir = UISettings::values.game_dirs.at(i); + const auto& game_dir = UISettings::values.game_dirs[i]; WriteSetting(QStringLiteral("path"), game_dir.path); WriteSetting(QStringLiteral("deep_scan"), game_dir.deep_scan, false); WriteSetting(QStringLiteral("expanded"), game_dir.expanded, true); diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 65947c59b..e5627abd4 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -87,12 +87,12 @@ QString GameList::getLastFilterResultItem() { QStandardItem* folder; QStandardItem* child; QString file_path; - int folder_count = item_model->rowCount(); + const int folder_count = item_model->rowCount(); for (int i = 0; i < folder_count; ++i) { folder = item_model->item(i, 0); - QModelIndex folder_index = folder->index(); - int childrenCount = folder->rowCount(); - for (int j = 0; j < childrenCount; ++j) { + const QModelIndex folder_index = folder->index(); + const int children_count = folder->rowCount(); + for (int j = 0; j < children_count; ++j) { if (!tree_view->isRowHidden(j, folder_index)) { child = folder->child(j, 0); file_path = child->data(GameListItemPath::FullPathRole).toString(); @@ -160,7 +160,7 @@ static bool ContainsAllWords(const QString& haystack, const QString& userinput) // Syncs the expanded state of Game Directories with settings to persist across sessions void GameList::onItemExpanded(const QModelIndex& item) { - GameListItemType type = item.data(GameListItem::TypeRole).value(); + const auto type = item.data(GameListItem::TypeRole).value(); if (type == GameListItemType::CustomDir || type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir) item.data(GameListDir::GameDirRole).value()->expanded = @@ -169,11 +169,11 @@ void GameList::onItemExpanded(const QModelIndex& item) { // Event in order to filter the gamelist after editing the searchfield void GameList::onTextChanged(const QString& new_text) { - int folder_count = tree_view->model()->rowCount(); + const int folder_count = tree_view->model()->rowCount(); QString edit_filter_text = new_text.toLower(); QStandardItem* folder; QStandardItem* child; - int childrenTotal = 0; + int children_total = 0; QModelIndex root_index = item_model->invisibleRootItem()->index(); // If the searchfield is empty every item is visible @@ -181,22 +181,22 @@ void GameList::onTextChanged(const QString& new_text) { if (edit_filter_text.isEmpty()) { for (int i = 0; i < folder_count; ++i) { folder = item_model->item(i, 0); - QModelIndex folder_index = folder->index(); - int childrenCount = folder->rowCount(); - for (int j = 0; j < childrenCount; ++j) { - ++childrenTotal; + const QModelIndex folder_index = folder->index(); + const int children_count = folder->rowCount(); + for (int j = 0; j < children_count; ++j) { + ++children_total; tree_view->setRowHidden(j, folder_index, false); } } - search_field->setFilterResult(childrenTotal, childrenTotal); + search_field->setFilterResult(children_total, children_total); } else { int result_count = 0; for (int i = 0; i < folder_count; ++i) { folder = item_model->item(i, 0); - QModelIndex folder_index = folder->index(); - int childrenCount = folder->rowCount(); - for (int j = 0; j < childrenCount; ++j) { - ++childrenTotal; + const QModelIndex folder_index = folder->index(); + const int children_count = folder->rowCount(); + for (int j = 0; j < children_count; ++j) { + ++children_total; const QStandardItem* child = folder->child(j, 0); const QString file_path = child->data(GameListItemPath::FullPathRole).toString().toLower(); @@ -220,7 +220,7 @@ void GameList::onTextChanged(const QString& new_text) { } else { tree_view->setRowHidden(j, folder_index, true); } - search_field->setFilterResult(result_count, childrenTotal); + search_field->setFilterResult(result_count, children_total); } } } @@ -230,7 +230,7 @@ void GameList::onUpdateThemedIcons() { for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) { QStandardItem* child = item_model->invisibleRootItem()->child(i); - int icon_size = UISettings::values.icon_size; + const int icon_size = UISettings::values.icon_size; switch (child->data(GameListItem::TypeRole).value()) { case GameListItemType::InstalledDir: child->setData( @@ -249,8 +249,9 @@ void GameList::onUpdateThemedIcons() { case GameListItemType::CustomDir: { const UISettings::GameDir* game_dir = child->data(GameListDir::GameDirRole).value(); - QString icon_name = QFileInfo::exists(game_dir->path) ? QStringLiteral("folder") - : QStringLiteral("bad_folder"); + const QString icon_name = QFileInfo::exists(game_dir->path) + ? QStringLiteral("folder") + : QStringLiteral("bad_folder"); child->setData( QIcon::fromTheme(icon_name).pixmap(icon_size).scaled( icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), @@ -357,14 +358,14 @@ void GameList::AddEntry(const QList& entry_items, GameListDir* p } void GameList::ValidateEntry(const QModelIndex& item) { - auto selected = item.sibling(item.row(), 0); + const auto selected = item.sibling(item.row(), 0); switch (selected.data(GameListItem::TypeRole).value()) { case GameListItemType::Game: { - QString file_path = selected.data(GameListItemPath::FullPathRole).toString(); + const QString file_path = selected.data(GameListItemPath::FullPathRole).toString(); if (file_path.isEmpty()) return; - QFileInfo file_info(file_path); + const QFileInfo file_info(file_path); if (!file_info.exists()) return; @@ -391,7 +392,7 @@ void GameList::ValidateEntry(const QModelIndex& item) { bool GameList::isEmpty() { for (int i = 0; i < item_model->rowCount(); i++) { const QStandardItem* child = item_model->invisibleRootItem()->child(i); - GameListItemType type = static_cast(child->type()); + const auto type = static_cast(child->type()); if (!child->hasChildren() && (type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir)) { item_model->invisibleRootItem()->removeRow(child->row()); @@ -422,16 +423,16 @@ void GameList::DonePopulating(QStringList watch_list) { QCoreApplication::processEvents(); } tree_view->setEnabled(true); - int folder_count = tree_view->model()->rowCount(); - int childrenTotal = 0; + const int folder_count = tree_view->model()->rowCount(); + int children_total = 0; for (int i = 0; i < folder_count; ++i) { - int childrenCount = item_model->item(i, 0)->rowCount(); - for (int j = 0; j < childrenCount; ++j) { - ++childrenTotal; + int children_count = item_model->item(i, 0)->rowCount(); + for (int j = 0; j < children_count; ++j) { + ++children_total; } } - search_field->setFilterResult(childrenTotal, childrenTotal); - if (childrenTotal > 0) { + search_field->setFilterResult(children_total, children_total); + if (children_total > 0) { search_field->setFocus(); } } @@ -441,7 +442,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { if (!item.isValid()) return; - auto selected = item.sibling(item.row(), 0); + const auto selected = item.sibling(item.row(), 0); QMenu context_menu; switch (selected.data(GameListItem::TypeRole).value()) { case GameListItemType::Game: @@ -523,7 +524,7 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { QAction* move_down = context_menu.addAction(tr(u8"\U000025bc Move Down ")); QAction* open_directory_location = context_menu.addAction(tr("Open Directory Location")); - int row = selected.row(); + const int row = selected.row(); move_up->setEnabled(row > 0); move_down->setEnabled(row < item_model->rowCount() - 2); @@ -532,7 +533,7 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { // find the indices of the items in settings and swap them UISettings::values.game_dirs.swap( UISettings::values.game_dirs.indexOf(game_dir), - UISettings::values.game_dirs.indexOf(*selected.sibling(selected.row() - 1, 0) + UISettings::values.game_dirs.indexOf(*selected.sibling(row - 1, 0) .data(GameListDir::GameDirRole) .value())); // move the treeview items @@ -549,7 +550,7 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { .data(GameListDir::GameDirRole) .value())); // move the treeview items - QList item = item_model->takeRow(row); + const QList item = item_model->takeRow(row); item_model->invisibleRootItem()->insertRow(row + 1, item); tree_view->setExpanded(selected, game_dir.expanded); }); diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index a2b58aba5..cf5bd3a39 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h @@ -80,7 +80,7 @@ signals: void NavigateToGamedbEntryRequested(u64 program_id, const CompatibilityList& compatibility_list); void OpenPerGameGeneralRequested(const std::string& file); - void OpenDirectory(QString directory); + void OpenDirectory(const QString& directory); void AddDirectory(); void ShowList(bool show); diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index f5abb759d..13623f526 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -220,12 +220,14 @@ public: UISettings::GameDir* game_dir = &directory; setData(QVariant::fromValue(game_dir), GameDirRole); - int icon_size = UISettings::values.icon_size; + const int icon_size = UISettings::values.icon_size; switch (dir_type) { case GameListItemType::InstalledDir: - setData(QIcon::fromTheme("sd_card").pixmap(icon_size).scaled( - icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); + setData( + QIcon::fromTheme(QStringLiteral("sd_card")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); setData("Installed Titles", Qt::DisplayRole); break; case GameListItemType::SystemDir: @@ -235,7 +237,9 @@ public: setData("System Titles", Qt::DisplayRole); break; case GameListItemType::CustomDir: - QString icon_name = QFileInfo::exists(game_dir->path) ? "folder" : "bad_folder"; + const QString icon_name = QFileInfo::exists(game_dir->path) + ? QStringLiteral("folder") + : QStringLiteral("bad_folder"); setData(QIcon::fromTheme(icon_name).pixmap(icon_size).scaled( icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::DecorationRole); @@ -257,9 +261,10 @@ public: explicit GameListAddDir() { setData(type(), TypeRole); - int icon_size = UISettings::values.icon_size; - setData(QIcon::fromTheme("plus").pixmap(icon_size).scaled( - icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + const int icon_size = UISettings::values.icon_size; + setData(QIcon::fromTheme(QStringLiteral("plus")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::DecorationRole); setData("Add New Game Directory", Qt::DisplayRole); } diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 8c6621c98..e1e69bc1a 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -354,16 +354,16 @@ void GameListWorker::run() { for (UISettings::GameDir& game_dir : game_dirs) { if (game_dir.path == "INSTALLED") { - GameListDir* game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir); + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir); emit DirEntryReady({game_list_dir}); AddTitlesToGameList(game_list_dir); } else if (game_dir.path == "SYSTEM") { - GameListDir* game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); emit DirEntryReady({game_list_dir}); AddTitlesToGameList(game_list_dir); } else { watch_list.append(game_dir.path); - GameListDir* game_list_dir = new GameListDir(game_dir); + auto* const game_list_dir = new GameListDir(game_dir); emit DirEntryReady({game_list_dir}); provider->ClearAllEntries(); ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path.toStdString(), 2, diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index b2de9545b..3146e054c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1309,11 +1309,11 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, QDesktopServices::openUrl(QUrl(QStringLiteral("https://yuzu-emu.org/game/") + directory)); } -void GMainWindow::OnGameListOpenDirectory(QString directory) { +void GMainWindow::OnGameListOpenDirectory(const QString& directory) { QString path; if (directory == QStringLiteral("INSTALLED")) { // TODO: Find a better solution when installing files to the SD card gets implemented - path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir).c_str() + + path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + std::string("user/Contents/registered")); } else if (directory == QStringLiteral("SYSTEM")) { path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir).c_str() + @@ -1329,7 +1329,7 @@ void GMainWindow::OnGameListOpenDirectory(QString directory) { } void GMainWindow::OnGameListAddDirectory() { - QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); + const QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); if (dir_path.isEmpty()) return; UISettings::GameDir game_dir{dir_path, false, true}; diff --git a/src/yuzu/main.h b/src/yuzu/main.h index b7398b6c7..7d16188cb 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -187,7 +187,7 @@ private slots: void OnGameListCopyTID(u64 program_id); void OnGameListNavigateToGamedbEntry(u64 program_id, const CompatibilityList& compatibility_list); - void OnGameListOpenDirectory(QString path); + void OnGameListOpenDirectory(const QString& directory); void OnGameListAddDirectory(); void OnGameListShowList(bool show); void OnGameListOpenPerGameProperties(const std::string& file); -- cgit v1.2.3 From 5aaafa6a56101a18759264bbf1ef9293d424f899 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Sun, 5 May 2019 03:07:09 +0200 Subject: Separate UserNand and Sdmc directories --- src/yuzu/configuration/config.cpp | 6 ++++-- src/yuzu/game_list.cpp | 23 ++++++++++++++++------- src/yuzu/game_list_p.h | 29 ++++++++++++++++++++--------- src/yuzu/game_list_worker.cpp | 25 ++++++++++++++----------- src/yuzu/main.cpp | 8 +++++--- 5 files changed, 59 insertions(+), 32 deletions(-) (limited to 'src/yuzu/configuration') diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index b2683faf8..f594106bf 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -535,10 +535,12 @@ void Config::ReadPathValues() { // also carries over old game list settings if present if (UISettings::values.game_dirs.isEmpty()) { UISettings::GameDir game_dir; - game_dir.path = QStringLiteral("INSTALLED"); + game_dir.path = QStringLiteral("SDMC"); game_dir.expanded = true; UISettings::values.game_dirs.append(game_dir); - game_dir.path = QStringLiteral("SYSTEM"); + game_dir.path = QStringLiteral("UserNAND"); + UISettings::values.game_dirs.append(game_dir); + game_dir.path = QStringLiteral("SysNAND"); UISettings::values.game_dirs.append(game_dir); if (UISettings::values.game_dir_deprecated != QStringLiteral(".")) { game_dir.path = UISettings::values.game_dir_deprecated; diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 51ced635b..cab982385 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -161,8 +161,8 @@ static bool ContainsAllWords(const QString& haystack, const QString& userinput) // Syncs the expanded state of Game Directories with settings to persist across sessions void GameList::onItemExpanded(const QModelIndex& item) { const auto type = item.data(GameListItem::TypeRole).value(); - if (type == GameListItemType::CustomDir || type == GameListItemType::InstalledDir || - type == GameListItemType::SystemDir) + if (type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir || + type == GameListItemType::UserNandDir || type == GameListItemType::SysNandDir) item.data(GameListDir::GameDirRole).value()->expanded = tree_view->isExpanded(item); } @@ -232,14 +232,21 @@ void GameList::onUpdateThemedIcons() { const int icon_size = UISettings::values.icon_size; switch (child->data(GameListItem::TypeRole).value()) { - case GameListItemType::InstalledDir: + case GameListItemType::SdmcDir: child->setData( QIcon::fromTheme(QStringLiteral("sd_card")) .pixmap(icon_size) .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::DecorationRole); break; - case GameListItemType::SystemDir: + case GameListItemType::UserNandDir: + child->setData( + QIcon::fromTheme(QStringLiteral("chip")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); + break; + case GameListItemType::SysNandDir: child->setData( QIcon::fromTheme(QStringLiteral("chip")) .pixmap(icon_size) @@ -394,7 +401,8 @@ bool GameList::isEmpty() const { const QStandardItem* child = item_model->invisibleRootItem()->child(i); const auto type = static_cast(child->type()); if (!child->hasChildren() && - (type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir)) { + (type == GameListItemType::SdmcDir || type == GameListItemType::UserNandDir || + type == GameListItemType::SysNandDir)) { item_model->invisibleRootItem()->removeRow(child->row()); i--; }; @@ -450,8 +458,9 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { AddPermDirPopup(context_menu, selected); AddCustomDirPopup(context_menu, selected); break; - case GameListItemType::InstalledDir: - case GameListItemType::SystemDir: + case GameListItemType::SdmcDir: + case GameListItemType::UserNandDir: + case GameListItemType::SysNandDir: AddPermDirPopup(context_menu, selected); break; } diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 047061e6c..87eb71c17 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -26,9 +26,10 @@ enum class GameListItemType { Game = QStandardItem::UserType + 1, CustomDir = QStandardItem::UserType + 2, - InstalledDir = QStandardItem::UserType + 3, - SystemDir = QStandardItem::UserType + 4, - AddDir = QStandardItem::UserType + 5 + SdmcDir = QStandardItem::UserType + 3, + UserNandDir = QStandardItem::UserType + 4, + SysNandDir = QStandardItem::UserType + 5, + AddDir = QStandardItem::UserType + 6 }; Q_DECLARE_METATYPE(GameListItemType); @@ -222,18 +223,28 @@ public: const int icon_size = UISettings::values.icon_size; switch (dir_type) { - case GameListItemType::InstalledDir: + case GameListItemType::SdmcDir: setData( QIcon::fromTheme(QStringLiteral("sd_card")) .pixmap(icon_size) .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::DecorationRole); - setData(QObject::tr("Installed Titles"), Qt::DisplayRole); + setData(QObject::tr("Installed SD Titles"), Qt::DisplayRole); break; - case GameListItemType::SystemDir: - setData(QIcon::fromTheme("chip").pixmap(icon_size).scaled( - icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); + case GameListItemType::UserNandDir: + setData( + QIcon::fromTheme(QStringLiteral("chip")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); + setData(QObject::tr("Installed NAND Titles"), Qt::DisplayRole); + break; + case GameListItemType::SysNandDir: + setData( + QIcon::fromTheme(QStringLiteral("chip")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); setData(QObject::tr("System Titles"), Qt::DisplayRole); break; case GameListItemType::CustomDir: diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index e1e69bc1a..c715bcef4 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -240,15 +240,14 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { std::vector> installed_games; installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application, ContentRecordType::Program); - if (parent_dir->type() == static_cast(GameListItemType::InstalledDir)) { + + if (parent_dir->type() == static_cast(GameListItemType::SdmcDir)) { installed_games = cache.ListEntriesFilterOrigin( - ContentProviderUnionSlot::UserNAND, TitleType::Application, ContentRecordType::Program); - auto installed_sdmc_games = cache.ListEntriesFilterOrigin( ContentProviderUnionSlot::SDMC, TitleType::Application, ContentRecordType::Program); - - installed_games.insert(installed_games.end(), installed_sdmc_games.begin(), - installed_sdmc_games.end()); - } else if (parent_dir->type() == static_cast(GameListItemType::SystemDir)) { + } else if (parent_dir->type() == static_cast(GameListItemType::UserNandDir)) { + installed_games = cache.ListEntriesFilterOrigin( + ContentProviderUnionSlot::UserNAND, TitleType::Application, ContentRecordType::Program); + } else if (parent_dir->type() == static_cast(GameListItemType::SysNandDir)) { installed_games = cache.ListEntriesFilterOrigin( ContentProviderUnionSlot::SysNAND, TitleType::Application, ContentRecordType::Program); } @@ -353,12 +352,16 @@ void GameListWorker::run() { stop_processing = false; for (UISettings::GameDir& game_dir : game_dirs) { - if (game_dir.path == "INSTALLED") { - auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir); + if (game_dir.path == QStringLiteral("SDMC")) { + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir); + emit DirEntryReady({game_list_dir}); + AddTitlesToGameList(game_list_dir); + } else if (game_dir.path == QStringLiteral("UserNAND")) { + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir); emit DirEntryReady({game_list_dir}); AddTitlesToGameList(game_list_dir); - } else if (game_dir.path == "SYSTEM") { - auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); + } else if (game_dir.path == QStringLiteral("SysNAND")) { + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir); emit DirEntryReady({game_list_dir}); AddTitlesToGameList(game_list_dir); } else { diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 72c3eb069..6d249cb3e 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1311,11 +1311,13 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, void GMainWindow::OnGameListOpenDirectory(const QString& directory) { QString path; - if (directory == QStringLiteral("INSTALLED")) { - // TODO: Find a better solution when installing files to the SD card gets implemented + if (directory == QStringLiteral("SDMC")) { + path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + + "Nintendo/Contents/registered"); + } else if (directory == QStringLiteral("UserNAND")) { path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "user/Contents/registered"); - } else if (directory == QStringLiteral("SYSTEM")) { + } else if (directory == QStringLiteral("SysNAND")) { path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "system/Contents/registered"); } else { -- cgit v1.2.3