Qt: Reduce game list jank after shutting down VM

Prevents progress bar briefly appearing, and the list scrolling to the
top when you exit a game.
This commit is contained in:
Stenzek
2024-08-03 00:50:02 +10:00
parent 3a83c4265c
commit 9a626caad9
8 changed files with 98 additions and 27 deletions

View File

@ -119,15 +119,15 @@ static std::string GetCustomPropertiesFile();
static FileSystem::ManagedCFilePtr OpenMemoryCardTimestampCache(bool for_write);
static bool UpdateMemcardTimestampCache(const MemcardTimestampCacheEntry& entry);
} // namespace GameList
static std::vector<GameList::Entry> s_entries;
static EntryList s_entries;
static std::recursive_mutex s_mutex;
static GameList::CacheMap s_cache_map;
static std::vector<GameList::MemcardTimestampCacheEntry> s_memcard_timestamp_cache_entries;
static CacheMap s_cache_map;
static std::vector<MemcardTimestampCacheEntry> s_memcard_timestamp_cache_entries;
static bool s_game_list_loaded = false;
} // namespace GameList
const char* GameList::GetEntryTypeName(EntryType type)
{
static std::array<const char*, static_cast<int>(EntryType::Count)> names = {
@ -823,6 +823,13 @@ void GameList::Refresh(bool invalidate_cache, bool only_cache, ProgressCallback*
CreateDiscSetEntries(played_time);
}
GameList::EntryList GameList::TakeEntryList()
{
EntryList ret = std::move(s_entries);
s_entries = {};
return ret;
}
void GameList::CreateDiscSetEntries(const PlayedTimeMap& played_time_map)
{
std::unique_lock lock(s_mutex);

View File

@ -71,6 +71,8 @@ struct Entry
ALWAYS_INLINE EntryType GetSortType() const { return (type == EntryType::DiscSet) ? EntryType::Disc : type; }
};
using EntryList = std::vector<Entry>;
const char* GetEntryTypeName(EntryType type);
const char* GetEntryTypeDisplayName(EntryType type);
@ -97,6 +99,10 @@ bool IsGameListLoaded();
/// If only_cache is set, no new files will be scanned, only those present in the cache.
void Refresh(bool invalidate_cache, bool only_cache = false, ProgressCallback* progress = nullptr);
/// Moves the current game list, which can be temporarily displayed in the UI until refresh completes.
/// The caller **must** call Refresh() afterward, otherwise it will be permanently lost.
EntryList TakeEntryList();
/// Add played time for the specified serial.
void AddPlayedTimeForSerial(const std::string& serial, std::time_t last_time, std::time_t add_time);
void ClearPlayedTimeForSerial(const std::string& serial);