From bd9f1695cf7b50b8bc6594fe87a1e3a8fcccd446 Mon Sep 17 00:00:00 2001 From: Akatsuki Levi Date: Wed, 13 Mar 2024 17:46:44 -0300 Subject: [PATCH] feat: Reduced clutter on game list --- src/common/settings.h | 1 - src/suyu/game_list.cpp | 36 ++++++++++++++++++----------------- src/suyu/game_list.h | 1 + src/suyu/game_list_worker.cpp | 24 +++++++++++------------ src/suyu/main.cpp | 24 ----------------------- src/suyu/main.h | 1 - src/suyu/main.ui | 2 +- 7 files changed, 33 insertions(+), 56 deletions(-) diff --git a/src/common/settings.h b/src/common/settings.h index f1e0fb00b2..d010713ea6 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -611,7 +611,6 @@ struct Values { Category::Network}; // WebService - Setting enable_telemetry{linkage, false, "enable_telemetry", Category::WebService}; Setting web_api_url{linkage, "http://74.113.97.71:3000", "web_api_url", Category::WebService}; Setting suyu_username{linkage, std::string(), "suyu_username", diff --git a/src/suyu/game_list.cpp b/src/suyu/game_list.cpp index 478838bc84..2c06aa69df 100644 --- a/src/suyu/game_list.cpp +++ b/src/suyu/game_list.cpp @@ -3,7 +3,6 @@ // Modified by palfaiate on <2024/03/07> -#include #include #include #include @@ -413,6 +412,10 @@ void GameList::AddEntry(const QList& entry_items, GameListDir* p parent->appendRow(entry_items); } +void GameList::AddRootEntry(const QList& entry_items) { + item_model->invisibleRootItem()->appendRow(entry_items); +} + void GameList::ValidateEntry(const QModelIndex& item) { const auto selected = item.sibling(item.row(), 0); @@ -468,7 +471,7 @@ bool GameList::IsEmpty() const { void GameList::DonePopulating(const QStringList& watch_list) { emit ShowList(!IsEmpty()); - item_model->invisibleRootItem()->appendRow(new GameListAddDir()); + // item_model->invisibleRootItem()->appendRow(new GameListAddDir()); // Add favorites row item_model->invisibleRootItem()->insertRow(0, new GameListFavorites()); @@ -887,22 +890,21 @@ void GameList::AddFavorite(u64 program_id) { auto* favorites_row = item_model->item(0); for (int i = 1; i < item_model->rowCount() - 1; i++) { - const auto* folder = item_model->item(i); - for (int j = 0; j < folder->rowCount(); j++) { - if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() == - program_id) { - QList list; - for (int k = 0; k < COLUMN_COUNT; k++) { - list.append(folder->child(j, k)->clone()); - } - list[0]->setData(folder->child(j)->data(GameListItem::SortRole), - GameListItem::SortRole); - list[0]->setText(folder->child(j)->data(Qt::DisplayRole).toString()); - - favorites_row->appendRow(list); - return; - } + const auto* game = item_model->item(i); + if (game->data(GameListItemPath::ProgramIdRole).toULongLong() != program_id) { + continue; } + + QList list; + for (int j = 0; j < COLUMN_COUNT; j++) { + list.append(item_model->item(i, j)->clone()); + } + + list[0]->setData(game->data(GameListItem::SortRole), GameListItem::SortRole); + list[0]->setText(game->data(Qt::DisplayRole).toString()); + + favorites_row->appendRow(list); + return; } } diff --git a/src/suyu/game_list.h b/src/suyu/game_list.h index f8796fa821..c9b41687de 100644 --- a/src/suyu/game_list.h +++ b/src/suyu/game_list.h @@ -137,6 +137,7 @@ private: void AddDirEntry(GameListDir* entry_items); void AddEntry(const QList& entry_items, GameListDir* parent); + void AddRootEntry(const QList& entry_items); void DonePopulating(const QStringList& watch_list); private: diff --git a/src/suyu/game_list_worker.cpp b/src/suyu/game_list_worker.cpp index 9243464780..112e64b66b 100644 --- a/src/suyu/game_list_worker.cpp +++ b/src/suyu/game_list_worker.cpp @@ -234,8 +234,8 @@ GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_, const PlayTime::PlayTimeManager& play_time_manager_, Core::System& system_) : vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_}, - compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, system{ - system_} { + compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, + system{system_} { // We want the game list to manage our lifetime. setAutoDelete(false); } @@ -330,13 +330,13 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { auto entry = MakeGameListEntry(file->GetFullPath(), name, file->GetSize(), icon, *loader, program_id, compatibility_list, play_time_manager, patch); - RecordEvent([=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); + RecordEvent([=](GameList* game_list) { game_list->AddRootEntry(entry); }); } } void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan, GameListDir* parent_dir) { - const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool { + const auto callback = [this, target](const std::filesystem::path& path) -> bool { if (stop_requested) { // Breaks the callback loop. return false; @@ -408,8 +408,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, id, compatibility_list, play_time_manager, patch); - RecordEvent( - [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); + RecordEvent([=](GameList* game_list) { game_list->AddRootEntry(entry); }); } } else { std::vector icon; @@ -425,8 +424,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, program_id, compatibility_list, play_time_manager, patch); - RecordEvent( - [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); + RecordEvent([=](GameList* game_list) { game_list->AddRootEntry(entry); }); } } } else if (is_dir) { @@ -448,9 +446,11 @@ void GameListWorker::run() { watch_list.clear(); provider->ClearAllEntries(); + /* const auto DirEntryReady = [&](GameListDir* game_list_dir) { RecordEvent([=](GameList* game_list) { game_list->AddDirEntry(game_list_dir); }); }; + */ for (UISettings::GameDir& game_dir : game_dirs) { if (stop_requested) { @@ -459,20 +459,20 @@ void GameListWorker::run() { if (game_dir.path == std::string("SDMC")) { auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir); - DirEntryReady(game_list_dir); + // DirEntryReady(game_list_dir); AddTitlesToGameList(game_list_dir); } else if (game_dir.path == std::string("UserNAND")) { auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir); - DirEntryReady(game_list_dir); + // DirEntryReady(game_list_dir); AddTitlesToGameList(game_list_dir); } else if (game_dir.path == std::string("SysNAND")) { auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir); - DirEntryReady(game_list_dir); + // DirEntryReady(game_list_dir); AddTitlesToGameList(game_list_dir); } else { watch_list.append(QString::fromStdString(game_dir.path)); auto* const game_list_dir = new GameListDir(game_dir); - DirEntryReady(game_list_dir); + // DirEntryReady(game_list_dir); ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path, game_dir.deep_scan, game_list_dir); ScanFileSystem(ScanTarget::PopulateGameList, game_dir.path, game_dir.deep_scan, diff --git a/src/suyu/main.cpp b/src/suyu/main.cpp index 4a5ed8ed1a..784486c78c 100644 --- a/src/suyu/main.cpp +++ b/src/suyu/main.cpp @@ -186,28 +186,9 @@ constexpr size_t CopyBufferSize = 1_MiB; * user. This is 32-bits - if we have more than 32 callouts, we should retire and recycle old ones. */ enum class CalloutFlag : uint32_t { - Telemetry = 0x1, DRDDeprecation = 0x2, }; -void GMainWindow::ShowTelemetryCallout() { - if (UISettings::values.callout_flags.GetValue() & - static_cast(CalloutFlag::Telemetry)) { - return; - } - - UISettings::values.callout_flags = - UISettings::values.callout_flags.GetValue() | static_cast(CalloutFlag::Telemetry); - const QString telemetry_message = - tr("Anonymous " - "data is collected to help improve suyu. " - "

Would you like to share your usage data with us?"); - if (!question(this, tr("Telemetry"), telemetry_message)) { - Settings::values.enable_telemetry = false; - system->ApplySettings(); - } -} - const int GMainWindow::max_recent_files_item; static void RemoveCachedContents() { @@ -415,9 +396,6 @@ GMainWindow::GMainWindow(std::unique_ptr config_, bool has_broken_vulk game_list->LoadCompatibilityList(); game_list->PopulateAsync(UISettings::values.game_dirs); - // Show one-time "callout" messages to the user - ShowTelemetryCallout(); - // make sure menubar has the arrow cursor instead of inheriting from this ui->menubar->setCursor(QCursor()); statusBar()->setCursor(QCursor()); @@ -3606,8 +3584,6 @@ void GMainWindow::OnConfigure() { SetDefaultUIGeometry(); RestoreUIState(); - - ShowTelemetryCallout(); } InitializeHotkeys(); diff --git a/src/suyu/main.h b/src/suyu/main.h index 1705c491bf..6a157ed97e 100644 --- a/src/suyu/main.h +++ b/src/suyu/main.h @@ -275,7 +275,6 @@ private: void BootGameFromList(const QString& filename, StartGameType with_config); void ShutdownGame(); - void ShowTelemetryCallout(); void SetDiscordEnabled(bool state); void LoadAmiibo(const QString& filename); diff --git a/src/suyu/main.ui b/src/suyu/main.ui index 439dc4ba36..c660b3d3a2 100644 --- a/src/suyu/main.ui +++ b/src/suyu/main.ui @@ -45,7 +45,7 @@ 0 0 1280 - 22 + 21