Host: Move Batch/NoGUI mode check to Host

Moved from QtHost to Host for more accesibility
This commit is contained in:
KamFretoZ 2025-06-09 19:00:05 +07:00 committed by lightningterror
parent b30444c0d0
commit f87175dc7f
6 changed files with 24 additions and 14 deletions

View File

@ -43,7 +43,7 @@ void LogWindow::updateSettings()
{ {
std::unique_lock lock(s_log_mutex); std::unique_lock lock(s_log_mutex);
const bool new_enabled = Host::GetBaseBoolSettingValue("Logging", "EnableLogWindow", false) && !QtHost::InNoGUIMode(); const bool new_enabled = Host::GetBaseBoolSettingValue("Logging", "EnableLogWindow", false) && !Host::InNoGUIMode();
const bool attach_to_main = Host::GetBaseBoolSettingValue("Logging", "AttachLogWindowToMainWindow", true); const bool attach_to_main = Host::GetBaseBoolSettingValue("Logging", "AttachLogWindowToMainWindow", true);
const bool curr_enabled = Log::IsHostOutputEnabled(); const bool curr_enabled = Log::IsHostOutputEnabled();

View File

@ -1130,7 +1130,7 @@ bool MainWindow::shouldHideMainWindow() const
// NOTE: We can't use isRenderingToMain() here, because this happens post-fullscreen-switch. // NOTE: We can't use isRenderingToMain() here, because this happens post-fullscreen-switch.
return (Host::GetBoolSettingValue("UI", "HideMainWindowWhenRunning", false) && !g_emu_thread->shouldRenderToMain()) || return (Host::GetBoolSettingValue("UI", "HideMainWindowWhenRunning", false) && !g_emu_thread->shouldRenderToMain()) ||
(g_emu_thread->shouldRenderToMain() && (isRenderingFullscreen() || m_is_temporarily_windowed)) || (g_emu_thread->shouldRenderToMain() && (isRenderingFullscreen() || m_is_temporarily_windowed)) ||
QtHost::InNoGUIMode(); Host::InNoGUIMode();
} }
bool MainWindow::shouldMouseLock() const bool MainWindow::shouldMouseLock() const
@ -1306,7 +1306,7 @@ bool MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b
// reshow the main window during display updates, because otherwise fullscreen transitions and renderer switches // reshow the main window during display updates, because otherwise fullscreen transitions and renderer switches
// would briefly show and then hide the main window. So instead, we do it on shutdown, here. Except if we're in // would briefly show and then hide the main window. So instead, we do it on shutdown, here. Except if we're in
// batch mode, when we're going to exit anyway. // batch mode, when we're going to exit anyway.
if (!isRenderingToMain() && isHidden() && !QtHost::InBatchMode() && !g_emu_thread->isRunningFullscreenUI()) if (!isRenderingToMain() && isHidden() && !Host::InBatchMode() && !g_emu_thread->isRunningFullscreenUI())
updateWindowState(true); updateWindowState(true);
// Clear the VM valid state early. That way we can't do anything in the UI if we take a while to shut down. // Clear the VM valid state early. That way we can't do anything in the UI if we take a while to shut down.
@ -2060,7 +2060,7 @@ void MainWindow::onVMStopped()
updateInputRecordingActions(false); updateInputRecordingActions(false);
// If we're closing or in batch mode, quit the whole application now. // If we're closing or in batch mode, quit the whole application now.
if (m_is_closing || QtHost::InBatchMode()) if (m_is_closing || Host::InBatchMode())
{ {
quit(); quit();
return; return;

View File

@ -602,7 +602,7 @@ void Host::CheckForSettingsChanges(const Pcsx2Config& old_config)
bool EmuThread::shouldRenderToMain() const bool EmuThread::shouldRenderToMain() const
{ {
return !Host::GetBoolSettingValue("UI", "RenderToSeparateWindow", false) && !QtHost::InNoGUIMode(); return !Host::GetBoolSettingValue("UI", "RenderToSeparateWindow", false) && !Host::InNoGUIMode();
} }
void EmuThread::toggleSoftwareRendering() void EmuThread::toggleSoftwareRendering()
@ -1268,7 +1268,7 @@ void Host::RequestVMShutdown(bool allow_confirm, bool allow_save_state, bool def
// This will probably call shutdownVM() again, but by the time it runs, we'll have already shut down // This will probably call shutdownVM() again, but by the time it runs, we'll have already shut down
// and it'll be a noop. // and it'll be a noop.
if (QtHost::InBatchMode()) if (Host::InBatchMode())
QMetaObject::invokeMethod(g_main_window, "requestExit", Qt::QueuedConnection, Q_ARG(bool, false)); QMetaObject::invokeMethod(g_main_window, "requestExit", Qt::QueuedConnection, Q_ARG(bool, false));
} }
} }
@ -1437,12 +1437,12 @@ void Host::CommitBaseSettingChanges()
} }
} }
bool QtHost::InBatchMode() bool Host::InBatchMode()
{ {
return s_batch_mode; return s_batch_mode;
} }
bool QtHost::InNoGUIMode() bool Host::InNoGUIMode()
{ {
return s_nogui_mode; return s_nogui_mode;
} }

View File

@ -245,12 +245,6 @@ namespace QtHost
/// Sets the icon theme, based on the current style (light/dark). /// Sets the icon theme, based on the current style (light/dark).
void SetIconThemeFromStyle(); void SetIconThemeFromStyle();
/// Sets batch mode (exit after game shutdown).
bool InBatchMode();
/// Sets NoGUI mode (implys batch mode, does not display main window, exits on shutdown).
bool InNoGUIMode();
/// Returns true if the calling thread is the UI thread. /// Returns true if the calling thread is the UI thread.
bool IsOnUIThread(); bool IsOnUIThread();

View File

@ -67,6 +67,12 @@ namespace Host
bool ConfirmMessage(const std::string_view title, const std::string_view message); bool ConfirmMessage(const std::string_view title, const std::string_view message);
bool ConfirmFormattedMessage(const std::string_view title, const char* format, ...); bool ConfirmFormattedMessage(const std::string_view title, const char* format, ...);
/// Sets batch mode (exit after game shutdown).
bool InBatchMode();
/// Sets NoGUI mode (implys batch mode, does not display main window, exits on shutdown).
bool InNoGUIMode();
/// Opens a URL, using the default application. /// Opens a URL, using the default application.
void OpenURL(const std::string_view url); void OpenURL(const std::string_view url);

View File

@ -56,6 +56,16 @@ void Host::OpenURL(const std::string_view url)
{ {
} }
bool Host::InBatchMode()
{
return false;
}
bool Host::InNoGUIMode()
{
return false;
}
bool Host::CopyTextToClipboard(const std::string_view text) bool Host::CopyTextToClipboard(const std::string_view text)
{ {
return false; return false;