From f9833bb8af74745a6039047c136787204f05dbb4 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 13 Jan 2024 01:19:51 +1000 Subject: [PATCH] Qt: Tidy up Tools menu Make System Console and Verbose contingent on Advanced Settings being enabled. Make Debug Console contingent on actually running under a debugger. --- common/Console.cpp | 9 +++++++++ common/Console.h | 1 + pcsx2-qt/MainWindow.cpp | 39 ++++++++++++++++++++++++++------------- pcsx2-qt/MainWindow.h | 1 + 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/common/Console.cpp b/common/Console.cpp index a8f1b991cc2cf..73b353cb2f527 100644 --- a/common/Console.cpp +++ b/common/Console.cpp @@ -271,6 +271,15 @@ __ri void Log::WriteToDebug(LOGLEVEL level, ConsoleColors color, std::string_vie #endif } +bool Log::IsDebugOutputAvailable() +{ +#ifdef _WIN32 + return IsDebuggerPresent(); +#else + return false; +#endif +} + bool Log::IsDebugOutputEnabled() { return (s_console_level > LOGLEVEL_NONE); diff --git a/common/Console.h b/common/Console.h index 250007ab06119..78184d725b922 100644 --- a/common/Console.h +++ b/common/Console.h @@ -73,6 +73,7 @@ namespace Log void SetConsoleOutputLevel(LOGLEVEL level); // adds a debug console output + bool IsDebugOutputAvailable(); bool IsDebugOutputEnabled(); void SetDebugOutputLevel(LOGLEVEL level); diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index c11323334717d..5c2fbd0526cef 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -178,11 +178,8 @@ QWidget* MainWindow::getContentParent() void MainWindow::setupAdditionalUi() { - const bool show_advanced_settings = QtHost::ShouldShowAdvancedSettings(); - makeIconsMasks(menuBar()); - - m_ui.menuDebug->menuAction()->setVisible(show_advanced_settings); + updateAdvancedSettingsVisibility(); const bool toolbar_visible = Host::GetBaseBoolSettingValue("UI", "ShowToolbar", false); m_ui.actionViewToolbar->setChecked(toolbar_visible); @@ -367,14 +364,18 @@ void MainWindow::connectSignals() SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionViewStatusBarVerbose, "UI", "VerboseStatusBar", false); SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableSystemConsole, "Logging", "EnableSystemConsole", false); -#ifdef _WIN32 - // Debug console only exists on Windows. - SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableDebugConsole, "Logging", "EnableDebugConsole", false); -#else - m_ui.menuTools->removeAction(m_ui.actionEnableDebugConsole); - m_ui.actionEnableDebugConsole->deleteLater(); - m_ui.actionEnableDebugConsole = nullptr; -#endif + + if (Log::IsDebugOutputAvailable()) + { + SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableDebugConsole, "Logging", "EnableDebugConsole", false); + } + else + { + m_ui.menuTools->removeAction(m_ui.actionEnableDebugConsole); + m_ui.actionEnableDebugConsole->deleteLater(); + m_ui.actionEnableDebugConsole = nullptr; + } + #ifndef PCSX2_DEVBUILD SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableVerboseLogging, "Logging", "EnableVerbose", false); #else @@ -669,13 +670,25 @@ void MainWindow::onShowAdvancedSettingsToggled(bool checked) Host::SetBaseBoolSettingValue("UI", "ShowAdvancedSettings", checked); Host::CommitBaseSettingChanges(); - m_ui.menuDebug->menuAction()->setVisible(checked); + updateAdvancedSettingsVisibility(); // just recreate the entire settings window, it's easier. if (m_settings_window) recreateSettings(); } +void MainWindow::updateAdvancedSettingsVisibility() +{ + const bool enabled = QtHost::ShouldShowAdvancedSettings(); + + m_ui.menuDebug->menuAction()->setVisible(enabled); + + m_ui.actionEnableSystemConsole->setVisible(enabled); + if (m_ui.actionEnableDebugConsole) + m_ui.actionEnableDebugConsole->setVisible(enabled); + m_ui.actionEnableVerboseLogging->setVisible(enabled); +} + void MainWindow::onToolsVideoCaptureToggled(bool checked) { if (!s_vm_valid) diff --git a/pcsx2-qt/MainWindow.h b/pcsx2-qt/MainWindow.h index 19343050465b2..39bf985cf2ec2 100644 --- a/pcsx2-qt/MainWindow.h +++ b/pcsx2-qt/MainWindow.h @@ -222,6 +222,7 @@ private Q_SLOTS: void updateDisplayRelatedActions(bool has_surface, bool render_to_main, bool fullscreen); void updateGameDependentActions(); void updateStatusBarWidgetVisibility(); + void updateAdvancedSettingsVisibility(); void updateWindowTitle(); void updateWindowState(bool force_visible = false); void setProgressBar(int current, int total);