mirror of https://github.com/PCSX2/pcsx2.git
Host: Add game list refresh/cancel calls
This commit is contained in:
parent
f260a8be66
commit
22bf3549b6
|
@ -905,6 +905,41 @@ void Host::RunOnCPUThread(std::function<void()> function, bool block /* = false
|
|||
Q_ARG(const std::function<void()>&, std::move(function)));
|
||||
}
|
||||
|
||||
void Host::RefreshGameListAsync(bool invalidate_cache)
|
||||
{
|
||||
QMetaObject::invokeMethod(g_main_window, "refreshGameList", Qt::QueuedConnection,
|
||||
Q_ARG(bool, invalidate_cache));
|
||||
}
|
||||
|
||||
void Host::CancelGameListRefresh()
|
||||
{
|
||||
QMetaObject::invokeMethod(g_main_window, "cancelGameListRefresh", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
|
||||
void Host::RequestExit(bool save_state_if_running)
|
||||
{
|
||||
if (VMManager::HasValidVM())
|
||||
g_emu_thread->shutdownVM(save_state_if_running);
|
||||
|
||||
QMetaObject::invokeMethod(g_main_window, "requestExit", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void Host::RequestVMShutdown(bool save_state)
|
||||
{
|
||||
if (VMManager::HasValidVM())
|
||||
g_emu_thread->shutdownVM(save_state);
|
||||
}
|
||||
|
||||
bool Host::IsFullscreen()
|
||||
{
|
||||
return g_emu_thread->isFullscreen();
|
||||
}
|
||||
|
||||
void Host::SetFullscreen(bool enabled)
|
||||
{
|
||||
g_emu_thread->setFullscreen(enabled);
|
||||
}
|
||||
|
||||
alignas(16) static SysMtgsThread s_mtgs_thread;
|
||||
|
||||
SysMtgsThread& GetMTGS()
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
static void stop();
|
||||
|
||||
__fi QEventLoop* getEventLoop() const { return m_event_loop; }
|
||||
__fi bool isFullscreen() const { return m_is_fullscreen; }
|
||||
|
||||
bool isOnEmuThread() const;
|
||||
|
||||
|
|
|
@ -163,13 +163,7 @@ bool GameListWidget::getShowGridCoverTitles() const
|
|||
|
||||
void GameListWidget::refresh(bool invalidate_cache)
|
||||
{
|
||||
if (m_refresh_thread)
|
||||
{
|
||||
m_refresh_thread->cancel();
|
||||
m_refresh_thread->wait();
|
||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
pxAssertRel(!m_refresh_thread, "Game list thread should be unreferenced by now");
|
||||
}
|
||||
cancelRefresh();
|
||||
|
||||
m_refresh_thread = new GameListRefreshThread(invalidate_cache);
|
||||
connect(m_refresh_thread, &GameListRefreshThread::refreshProgress, this, &GameListWidget::onRefreshProgress,
|
||||
|
@ -179,6 +173,17 @@ void GameListWidget::refresh(bool invalidate_cache)
|
|||
m_refresh_thread->start();
|
||||
}
|
||||
|
||||
void GameListWidget::cancelRefresh()
|
||||
{
|
||||
if (!m_refresh_thread)
|
||||
return;
|
||||
|
||||
m_refresh_thread->cancel();
|
||||
m_refresh_thread->wait();
|
||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
pxAssertRel(!m_refresh_thread, "Game list thread should be unreferenced by now");
|
||||
}
|
||||
|
||||
void GameListWidget::onRefreshProgress(const QString& status, int current, int total)
|
||||
{
|
||||
// switch away from the placeholder while we scan, in case we find anything
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
void initialize();
|
||||
|
||||
void refresh(bool invalidate_cache);
|
||||
void cancelRefresh();
|
||||
|
||||
bool isShowingGameList() const;
|
||||
bool isShowingGameGrid() const;
|
||||
|
|
|
@ -731,6 +731,11 @@ void MainWindow::refreshGameList(bool invalidate_cache)
|
|||
m_game_list_widget->refresh(invalidate_cache);
|
||||
}
|
||||
|
||||
void MainWindow::cancelGameListRefresh()
|
||||
{
|
||||
m_game_list_widget->cancelRefresh();
|
||||
}
|
||||
|
||||
void MainWindow::invalidateSaveStateCache()
|
||||
{
|
||||
m_save_states_invalidated = true;
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
public Q_SLOTS:
|
||||
void checkForUpdates(bool display_message);
|
||||
void refreshGameList(bool invalidate_cache);
|
||||
void cancelGameListRefresh();
|
||||
void invalidateSaveStateCache();
|
||||
void reportError(const QString& title, const QString& message);
|
||||
void runOnUIThread(const std::function<void()>& func);
|
||||
|
|
|
@ -116,6 +116,11 @@ std::vector<std::string> Host::GetStringListSetting(const char* section, const c
|
|||
return s_layered_settings_interface.GetStringList(section, key);
|
||||
}
|
||||
|
||||
SettingsInterface* Host::Internal::GetBaseSettingsLayer()
|
||||
{
|
||||
return s_layered_settings_interface.GetLayer(LayeredSettingsInterface::LAYER_BASE);
|
||||
}
|
||||
|
||||
void Host::Internal::SetBaseSettingsLayer(SettingsInterface* sif)
|
||||
{
|
||||
pxAssertRel(s_layered_settings_interface.GetLayer(LayeredSettingsInterface::LAYER_BASE) == nullptr, "Base layer has not been set");
|
||||
|
|
|
@ -47,6 +47,9 @@ namespace Host
|
|||
|
||||
namespace Internal
|
||||
{
|
||||
/// Retrieves the base settings layer. Must call with lock held.
|
||||
SettingsInterface* GetBaseSettingsLayer();
|
||||
|
||||
/// Sets the base settings layer. Should be called by the host at initialization time.
|
||||
void SetBaseSettingsLayer(SettingsInterface* sif);
|
||||
|
||||
|
|
|
@ -211,4 +211,23 @@ namespace Host
|
|||
|
||||
/// Safely executes a function on the VM thread.
|
||||
void RunOnCPUThread(std::function<void()> function, bool block = false);
|
||||
|
||||
/// Asynchronously starts refreshing the game list.
|
||||
void RefreshGameListAsync(bool invalidate_cache);
|
||||
|
||||
/// Cancels game list refresh, if there is one in progress.
|
||||
void CancelGameListRefresh();
|
||||
|
||||
/// Requests shut down and exit of the hosting application. This may not actually exit,
|
||||
/// if the user cancels the shutdown confirmation.
|
||||
void RequestExit(bool save_state_if_running);
|
||||
|
||||
/// Requests shut down of the current virtual machine.
|
||||
void RequestVMShutdown(bool save_state);
|
||||
|
||||
/// Returns true if the hosting application is currently fullscreen.
|
||||
bool IsFullscreen();
|
||||
|
||||
/// Alters fullscreen state of hosting application.
|
||||
void SetFullscreen(bool enabled);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue