From 56c8843406c7072539887126c8f5ee7db91b63d0 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 4 Mar 2022 19:46:47 +1000 Subject: [PATCH] Qt: Add log options to debug menu --- pcsx2-qt/MainWindow.cpp | 21 ++++ pcsx2-qt/MainWindow.h | 1 + pcsx2-qt/MainWindow.ui | 272 +++++++++++++++++++++++++--------------- pcsx2-qt/QtHost.cpp | 15 +-- 4 files changed, 198 insertions(+), 111 deletions(-) diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index adebb3e67..70f249e32 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -39,6 +39,7 @@ #include "Settings/ControllerSettingsDialog.h" #include "Settings/GameListSettingsWidget.h" #include "Settings/InterfaceSettingsWidget.h" +#include "SettingWidgetBinder.h" #include "svnrev.h" static constexpr char DISC_IMAGE_FILTER[] = @@ -170,6 +171,21 @@ void MainWindow::connectSignals() }); connect(m_ui.actionGridViewRefreshCovers, &QAction::triggered, m_game_list_widget, &GameListWidget::refreshGridCovers); + SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableSystemConsole, "Logging", "EnableSystemConsole", false); + connect(m_ui.actionEnableSystemConsole, &QAction::triggered, this, &MainWindow::onLoggingOptionChanged); +#ifndef PCSX2_DEVBUILD + SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableVerboseLogging, "Logging", "EnableVerbose", false); + connect(m_ui.actionEnableVerboseLogging, &QAction::triggered, this, &MainWindow::onLoggingOptionChanged); +#else + // Dev builds always have verbose logging. + m_ui.actionEnableVerboseLogging->setChecked(true); + m_ui.actionEnableVerboseLogging->setEnabled(false); +#endif + SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableEEConsoleLogging, "Logging", "EnableEEConsole", false); + connect(m_ui.actionEnableEEConsoleLogging, &QAction::triggered, this, &MainWindow::onLoggingOptionChanged); + SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableIOPConsoleLogging, "Logging", "EnableIOPConsole", false); + connect(m_ui.actionEnableIOPConsoleLogging, &QAction::triggered, this, &MainWindow::onLoggingOptionChanged); + // These need to be queued connections to stop crashing due to menus opening/closing and switching focus. connect(m_game_list_widget, &GameListWidget::refreshProgress, this, &MainWindow::onGameListRefreshProgress); connect(m_game_list_widget, &GameListWidget::refreshComplete, this, &MainWindow::onGameListRefreshComplete); @@ -883,6 +899,11 @@ void MainWindow::onThemeChangedFromSettings() g_main_window->doSettings(); } +void MainWindow::onLoggingOptionChanged() +{ + QtHost::UpdateLogging(); +} + void MainWindow::onVMStarting() { m_vm_valid = true; diff --git a/pcsx2-qt/MainWindow.h b/pcsx2-qt/MainWindow.h index ecb741e7e..25a829941 100644 --- a/pcsx2-qt/MainWindow.h +++ b/pcsx2-qt/MainWindow.h @@ -92,6 +92,7 @@ private Q_SLOTS: void onToolsOpenDataDirectoryTriggered(); void onThemeChanged(); void onThemeChangedFromSettings(); + void onLoggingOptionChanged(); void onVMStarting(); void onVMStarted(); diff --git a/pcsx2-qt/MainWindow.ui b/pcsx2-qt/MainWindow.ui index 17c9972af..aa0a7c82b 100644 --- a/pcsx2-qt/MainWindow.ui +++ b/pcsx2-qt/MainWindow.ui @@ -45,7 +45,8 @@ Change Disc - + + .. @@ -59,7 +60,8 @@ Cheats - + + .. @@ -67,7 +69,8 @@ Load State - + + .. @@ -75,7 +78,8 @@ Save State - + + .. @@ -141,6 +145,11 @@ + + + + + @@ -151,7 +160,8 @@ &Window Size - + + .. @@ -185,6 +195,9 @@ + + true + Toolbar @@ -203,9 +216,6 @@ false - - false - @@ -227,143 +237,160 @@ + + + .. + Start &File... - - - + + + .. + Start &Disc... - - - + + + .. + Start &BIOS - - - + + + .. + &Scan For New Games - - - + + + .. + &Rescan All Games - - - + + + .. + Shut &Down - - - + + + .. + &Reset - - - true + + + .. + &Pause - - - + + + .. + &Load State - - - + + + .. + &Save State - - - + + + .. + E&xit - - - + + + .. + &BIOS - - - + + + .. + System - - - + + + .. + Emulation - - - + + + .. + &Controllers - - - + + + .. + &Hotkeys - - - + + + .. + &Graphics - - - @@ -371,12 +398,13 @@ + + + .. + Fullscreen - - - @@ -400,7 +428,8 @@ - + + .. Check for &Updates... @@ -421,60 +450,67 @@ + + + .. + Change Disc... - - - + + + .. + Cheats... - - - + + + .. + &Audio - - - + + + .. + Game List - - - + + + .. + Interface - - - + + + .. + Add Game Directory... - - - + + + .. + &Settings... - - - @@ -502,20 +538,22 @@ + + + .. + &Screenshot - - - + + + .. + &Memory Cards - - - @@ -551,42 +589,46 @@ + + + .. + Game &List - - - false + + + .. + System &Display - - - false + + + .. + Game &Properties - - - + + + .. + Game &Grid - - - @@ -640,6 +682,32 @@ Reload Cheats/Patches + + + true + + + Enable System Console + + + + + true + + + Enable Verbose Logging + + + + + Enable EE Console Logging + + + + + Enable IOP Console Logging + + diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index e44dafb43..1aa79d6de 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -438,17 +438,14 @@ static const IConsoleWriter ConsoleWriter_WinQt = void QtHost::UpdateLogging() { // TODO: Make this an actual option. - bool console_logging_enabled = false; + const bool system_console_enabled = QtHost::GetBaseBoolSettingValue("Logging", "EnableSystemConsole", false); -#if defined(_DEBUG) || defined(PCSX2_DEVBUILD) - console_logging_enabled = true; -#endif + const bool any_logging_sinks = system_console_enabled; + DevConWriterEnabled = any_logging_sinks && QtHost::GetBaseBoolSettingValue("Logging", "EnableVerbose", false); + SysConsole.eeConsole.Enabled = any_logging_sinks && QtHost::GetBaseBoolSettingValue("Logging", "EnableEEConsole", true); + SysConsole.iopConsole.Enabled = any_logging_sinks && QtHost::GetBaseBoolSettingValue("Logging", "EnableIOPConsole", true); - DevConWriterEnabled = console_logging_enabled; - SysConsole.eeConsole.Enabled = console_logging_enabled; - SysConsole.iopConsole.Enabled = console_logging_enabled; - - if (console_logging_enabled) + if (system_console_enabled) { #ifdef _WIN32 s_debugger_attached = IsDebuggerPresent();