mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
Qt: Cleanup game-install assistant pull request
Use paths instead of IDs, disable typemap.
This commit is contained in:
parent
60baa49007
commit
75494066ea
@ -97,25 +97,24 @@ Q_SIGNALS:
|
||||
void Refreshed();
|
||||
|
||||
public:
|
||||
|
||||
template <typename KeyType>
|
||||
struct GameIdsTable
|
||||
{
|
||||
// List of Game IDS an operation has been done on for the use of the slot function
|
||||
std::set<QString> m_done_ids;
|
||||
// List of game paths an operation has been done on for the use of the slot function
|
||||
std::set<std::string> m_done_paths;
|
||||
};
|
||||
|
||||
template <typename KeySlot, typename Func>
|
||||
// Enqueue slot for refreshed signal
|
||||
// Allowing for an individual container for each distinct use case (currently disabled and contains only one such entry)
|
||||
template <typename KeySlot = void, typename Func>
|
||||
void AddRefreshedSlot(Func&& func)
|
||||
{
|
||||
if (!m_refresh_funcs_manage_type.has_value())
|
||||
{
|
||||
m_refresh_funcs_manage_type.emplace();
|
||||
}
|
||||
// NOTE: Remove assert when the need for individual containers arises
|
||||
static_assert(std::is_void_v<KeySlot>);
|
||||
|
||||
connect(this, &game_list_frame::Refreshed, this, [this, func = std::move(func)]() mutable
|
||||
{
|
||||
func(m_refresh_funcs_manage_type->get<GameIdsTable<KeySlot>>().m_done_ids);
|
||||
func(m_refresh_funcs_manage_type->get<GameIdsTable<KeySlot>>().m_done_paths);
|
||||
}, Qt::SingleShotConnection);
|
||||
}
|
||||
|
||||
@ -195,7 +194,6 @@ private:
|
||||
const std::array<int, 1> m_parsing_threads{0};
|
||||
QFutureWatcher<void> m_parsing_watcher;
|
||||
QFutureWatcher<void> m_refresh_watcher;
|
||||
usz m_refresh_counter = 0;
|
||||
QSet<QString> m_hidden_list;
|
||||
bool m_show_hidden{false};
|
||||
|
||||
@ -213,5 +211,5 @@ private:
|
||||
bool m_draw_compat_status_to_grid = false;
|
||||
bool m_show_custom_icons = true;
|
||||
bool m_play_hover_movies = true;
|
||||
std::optional<auto_typemap<game_list_frame>> m_refresh_funcs_manage_type;
|
||||
std::optional<auto_typemap<game_list_frame>> m_refresh_funcs_manage_type{std::in_place};
|
||||
};
|
||||
|
@ -1095,27 +1095,30 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
|
||||
bootable_paths_installed[bootable_paths[index]] = packages[index].title_id;
|
||||
}
|
||||
|
||||
// Need to test here due to potential std::move later
|
||||
const bool installed_a_whole_package_without_new_software = bootable_paths_installed.empty() && !cancelled;
|
||||
|
||||
if (!bootable_paths_installed.empty())
|
||||
{
|
||||
m_game_list_frame->AddRefreshedSlot<class KeyType>([this, paths = std::move(bootable_paths_installed)](std::set<QString>& IDs) mutable
|
||||
m_game_list_frame->AddRefreshedSlot([this, paths = std::move(bootable_paths_installed)](std::set<std::string>& claimed_paths) mutable
|
||||
{
|
||||
// Try to claim operaions on ID
|
||||
for (auto it = paths.begin(); it != paths.end();)
|
||||
{
|
||||
if (IDs.count(it->second))
|
||||
std::string resolved_path = Emu.GetCallbacks().resolve_path(it->first);
|
||||
|
||||
if (resolved_path.empty() || claimed_paths.count(resolved_path))
|
||||
{
|
||||
it = paths.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
IDs.emplace(it->second);
|
||||
claimed_paths.emplace(std::move(resolved_path));
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully installed software from package(s)!"), std::move(paths));
|
||||
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully installed software from package(s)!"), paths);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1127,12 +1130,6 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
|
||||
if (installed_a_whole_package_without_new_software)
|
||||
{
|
||||
m_gui_settings->ShowInfoBox(tr("Success!"), tr("Successfully installed software from package(s)!"), gui::ib_pkg_success, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!cancelled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2406,7 +2403,7 @@ void main_window::CreateConnects()
|
||||
|
||||
// Only select one folder for now
|
||||
paths << QFileDialog::getExistingDirectory(this, tr("Select a folder containing one or more games"), qstr(fs::get_config_dir()), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
AddGamesFromDirs(paths);
|
||||
AddGamesFromDirs(std::move(paths));
|
||||
});
|
||||
|
||||
connect(ui->bootRecentMenu, &QMenu::aboutToShow, this, [this]()
|
||||
@ -3500,7 +3497,7 @@ void main_window::closeEvent(QCloseEvent* closeEvent)
|
||||
Add valid disc games to gamelist (games.yml)
|
||||
@param paths = dir paths to scan for game
|
||||
*/
|
||||
void main_window::AddGamesFromDirs(const QStringList& paths)
|
||||
void main_window::AddGamesFromDirs(QStringList&& paths)
|
||||
{
|
||||
if (paths.isEmpty())
|
||||
{
|
||||
@ -3508,7 +3505,7 @@ void main_window::AddGamesFromDirs(const QStringList& paths)
|
||||
}
|
||||
|
||||
// Obtain list of previously existing entries under the specificied parent paths for comparison
|
||||
std::unordered_set<std::string_view> existing;
|
||||
std::unordered_set<std::string> existing;
|
||||
|
||||
for (const game_info& game : m_game_list_frame->GetGameInfo())
|
||||
{
|
||||
@ -3530,7 +3527,7 @@ void main_window::AddGamesFromDirs(const QStringList& paths)
|
||||
Emu.AddGamesFromDir(sstr(path));
|
||||
}
|
||||
|
||||
m_game_list_frame->AddRefreshedSlot<class KeyType>([this, paths = std::move(paths), existing = std::move(existing)](std::set<QString>& IDs)
|
||||
m_game_list_frame->AddRefreshedSlot([this, paths = std::move(paths), existing = std::move(existing)](std::set<std::string>& claimed_paths)
|
||||
{
|
||||
// Execute followup operations only for newly added entries under the specified paths
|
||||
std::map<std::string, QString> paths_added; // -> title id
|
||||
@ -3543,13 +3540,14 @@ void main_window::AddGamesFromDirs(const QStringList& paths)
|
||||
{
|
||||
if (Emu.IsPathInsideDir(game->info.path, sstr(dir_path)))
|
||||
{
|
||||
// Try to claim operaion on ID
|
||||
const QString title_id = qstr(game->info.serial);
|
||||
// Try to claim operaion on directory path
|
||||
|
||||
if (!IDs.count(title_id))
|
||||
std::string resolved_path = Emu.GetCallbacks().resolve_path(game->info.path);
|
||||
|
||||
if (!resolved_path.empty() && !claimed_paths.count(resolved_path))
|
||||
{
|
||||
IDs.emplace(title_id);
|
||||
paths_added.emplace(game->info.path, title_id);
|
||||
claimed_paths.emplace(game->info.path);
|
||||
paths_added.emplace(game->info.path, qstr(game->info.serial));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -3560,7 +3558,7 @@ void main_window::AddGamesFromDirs(const QStringList& paths)
|
||||
|
||||
if (!paths_added.empty())
|
||||
{
|
||||
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully added software to game list from path(s)!"), std::move(paths_added));
|
||||
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully added software to game list from path(s)!"), paths_added);
|
||||
}
|
||||
});
|
||||
|
||||
@ -3741,7 +3739,7 @@ void main_window::dropEvent(QDropEvent* event)
|
||||
}
|
||||
case drop_type::drop_dir: // import valid games to gamelist (games.yaml)
|
||||
{
|
||||
AddGamesFromDirs(drop_paths);
|
||||
AddGamesFromDirs(std::move(drop_paths));
|
||||
break;
|
||||
}
|
||||
case drop_type::drop_game: // import valid games to gamelist (games.yaml)
|
||||
|
@ -166,7 +166,7 @@ private:
|
||||
u64 m_drop_file_timestamp = umax;
|
||||
drop_type m_drop_file_cached_drop_type = drop_type::drop_error;
|
||||
drop_type IsValidFile(const QMimeData& md, QStringList* drop_paths = nullptr);
|
||||
void AddGamesFromDirs(const QStringList& paths);
|
||||
void AddGamesFromDirs(QStringList&& paths);
|
||||
|
||||
QAction* CreateRecentAction(const q_string_pair& entry, const uint& sc_idx);
|
||||
void BootRecentAction(const QAction* act);
|
||||
|
Loading…
x
Reference in New Issue
Block a user