mirror of https://github.com/PCSX2/pcsx2.git
Qt: Add -nogui command line parameter
This commit is contained in:
parent
a35990ee4c
commit
5fc07180dd
|
@ -108,7 +108,7 @@ void EmuThread::startVM(std::shared_ptr<VMBootParameters> boot_params)
|
|||
|
||||
// create the display, this may take a while...
|
||||
m_is_fullscreen = boot_params->fullscreen.value_or(Host::GetBaseBoolSettingValue("UI", "StartFullscreen", false));
|
||||
m_is_rendering_to_main = !Host::GetBaseBoolSettingValue("UI", "RenderToSeparateWindow", false);
|
||||
m_is_rendering_to_main = shouldRenderToMain();
|
||||
m_is_surfaceless = false;
|
||||
m_save_state_on_shutdown = false;
|
||||
if (!VMManager::Initialize(*boot_params))
|
||||
|
@ -452,7 +452,7 @@ void EmuThread::checkForSettingChanges()
|
|||
|
||||
if (VMManager::HasValidVM())
|
||||
{
|
||||
const bool render_to_main = !Host::GetBaseBoolSettingValue("UI", "RenderToSeparateWindow", false);
|
||||
const bool render_to_main = shouldRenderToMain();
|
||||
if (!m_is_fullscreen && m_is_rendering_to_main != render_to_main)
|
||||
{
|
||||
m_is_rendering_to_main = render_to_main;
|
||||
|
@ -469,6 +469,11 @@ void EmuThread::checkForSettingChanges()
|
|||
updatePerformanceMetrics(true);
|
||||
}
|
||||
|
||||
bool EmuThread::shouldRenderToMain() const
|
||||
{
|
||||
return !Host::GetBaseBoolSettingValue("UI", "RenderToSeparateWindow", false) && !QtHost::InNoGUIMode();
|
||||
}
|
||||
|
||||
void EmuThread::toggleSoftwareRendering()
|
||||
{
|
||||
if (!isOnEmuThread())
|
||||
|
|
|
@ -135,6 +135,7 @@ private:
|
|||
void destroyVM();
|
||||
void executeVM();
|
||||
void checkForSettingChanges();
|
||||
bool shouldRenderToMain() const;
|
||||
|
||||
void createBackgroundControllerPollTimer();
|
||||
void destroyBackgroundControllerPollTimer();
|
||||
|
|
|
@ -799,7 +799,7 @@ void MainWindow::updateWindowState(bool force_visible)
|
|||
if (m_is_closing)
|
||||
return;
|
||||
|
||||
const bool hide_window = !g_emu_thread->isRenderingToMain() && Host::GetBaseBoolSettingValue("UI", "HideMainWindowWhenRunning", false);
|
||||
const bool hide_window = !g_emu_thread->isRenderingToMain() && shouldHideMainWindow();
|
||||
const bool disable_resize = Host::GetBaseBoolSettingValue("UI", "DisableWindowResize", false);
|
||||
const bool has_window = s_vm_valid || m_display_widget;
|
||||
|
||||
|
@ -869,6 +869,11 @@ bool MainWindow::shouldHideMouseCursor() const
|
|||
return isRenderingFullscreen() && Host::GetBoolSettingValue("UI", "HideMouseCursor", false);
|
||||
}
|
||||
|
||||
bool MainWindow::shouldHideMainWindow() const
|
||||
{
|
||||
return Host::GetBaseBoolSettingValue("UI", "HideMainWindowWhenRunning", false) || QtHost::InNoGUIMode();
|
||||
}
|
||||
|
||||
void MainWindow::switchToGameListView()
|
||||
{
|
||||
if (isShowingGameList())
|
||||
|
@ -990,10 +995,10 @@ bool MainWindow::requestShutdown(bool allow_confirm /* = true */, bool allow_sav
|
|||
|
||||
if (!m_is_closing && QtHost::InBatchMode())
|
||||
{
|
||||
// Closing the window should shut down everything. If we don't set the closing flag here,
|
||||
// the VM shutdown may not complete by the time closeEvent() is called, leading to a confirm.
|
||||
// If we don't set the closing flag here, the VM shutdown may not complete by the time closeEvent() is called,
|
||||
// leading to a confirm.
|
||||
m_is_closing = true;
|
||||
close();
|
||||
QGuiApplication::quit();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1005,7 +1010,9 @@ void MainWindow::requestExit()
|
|||
if (!requestShutdown(true, true, true))
|
||||
return;
|
||||
|
||||
close();
|
||||
// We could use close here, but if we're not visible (e.g. quitting from fullscreen), closing the window
|
||||
// doesn't quit the application.
|
||||
QGuiApplication::quit();
|
||||
}
|
||||
|
||||
void MainWindow::checkForSettingChanges()
|
||||
|
|
|
@ -197,6 +197,7 @@ private:
|
|||
bool isRenderingFullscreen() const;
|
||||
bool isRenderingToMain() const;
|
||||
bool shouldHideMouseCursor() const;
|
||||
bool shouldHideMainWindow() const;
|
||||
void switchToGameListView();
|
||||
void switchToEmulationView();
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ const IConsoleWriter* PatchesCon = &Console;
|
|||
static std::unique_ptr<QTimer> s_settings_save_timer;
|
||||
static std::unique_ptr<INISettingsInterface> s_base_settings_interface;
|
||||
static bool s_batch_mode = false;
|
||||
static bool s_nogui_mode = false;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Initialization/Shutdown
|
||||
|
@ -341,6 +342,11 @@ bool QtHost::InBatchMode()
|
|||
return s_batch_mode;
|
||||
}
|
||||
|
||||
bool QtHost::InNoGUIMode()
|
||||
{
|
||||
return s_nogui_mode;
|
||||
}
|
||||
|
||||
void QtHost::RunOnUIThread(const std::function<void()>& func, bool block /*= false*/)
|
||||
{
|
||||
// main window always exists, so it's fine to attach it to that.
|
||||
|
@ -489,6 +495,7 @@ void QtHost::PrintCommandLineHelp(const char* progname)
|
|||
std::fprintf(stderr, " -help: Displays this information and exits.\n");
|
||||
std::fprintf(stderr, " -version: Displays version information and exits.\n");
|
||||
std::fprintf(stderr, " -batch: Enables batch mode (exits after shutting down).\n");
|
||||
std::fprintf(stderr, " -nogui: Hides main window while running (implies batch mode).\n");
|
||||
std::fprintf(stderr, " -elf <file>: Overrides the boot ELF with the specified filename.\n");
|
||||
std::fprintf(stderr, " -disc <path>: Uses the specified host DVD drive as a source.\n");
|
||||
std::fprintf(stderr, " -bios: Starts the BIOS (System Menu/OSDSYS).\n");
|
||||
|
@ -539,6 +546,12 @@ bool QtHost::ParseCommandLineOptions(int argc, char* argv[], std::shared_ptr<VMB
|
|||
s_batch_mode = true;
|
||||
continue;
|
||||
}
|
||||
else if (CHECK_ARG("-nogui"))
|
||||
{
|
||||
s_batch_mode = true;
|
||||
s_nogui_mode = true;
|
||||
continue;
|
||||
}
|
||||
else if (CHECK_ARG("-fastboot"))
|
||||
{
|
||||
AutoBoot(autoboot)->fast_boot = true;
|
||||
|
@ -625,7 +638,9 @@ bool QtHost::ParseCommandLineOptions(int argc, char* argv[], std::shared_ptr<VMB
|
|||
// scanning the game list).
|
||||
if (s_batch_mode && !autoboot)
|
||||
{
|
||||
QMessageBox::critical(nullptr, QStringLiteral("Error"), QStringLiteral("Cannot use batch mode, because no boot filename was specified."));
|
||||
QMessageBox::critical(nullptr, QStringLiteral("Error"), s_nogui_mode ?
|
||||
QStringLiteral("Cannot use no-gui mode, because no boot filename was specified.") :
|
||||
QStringLiteral("Cannot use batch mode, because no boot filename was specified."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -700,6 +715,7 @@ int main(int argc, char* argv[])
|
|||
if (!s_batch_mode)
|
||||
main_window->refreshGameList(false);
|
||||
|
||||
if (!s_nogui_mode)
|
||||
main_window->show();
|
||||
|
||||
if (autoboot)
|
||||
|
|
|
@ -43,6 +43,9 @@ namespace QtHost
|
|||
/// 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();
|
||||
|
||||
/// Executes a function on the UI thread.
|
||||
void RunOnUIThread(const std::function<void()>& func, bool block = false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue