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.
This commit is contained in:
Stenzek 2024-01-13 01:19:51 +10:00 committed by Connor McLaughlin
parent 4b6ddaf09e
commit f9833bb8af
4 changed files with 37 additions and 13 deletions

View File

@ -271,6 +271,15 @@ cleanup:
#endif #endif
} }
bool Log::IsDebugOutputAvailable()
{
#ifdef _WIN32
return IsDebuggerPresent();
#else
return false;
#endif
}
bool Log::IsDebugOutputEnabled() bool Log::IsDebugOutputEnabled()
{ {
return (s_console_level > LOGLEVEL_NONE); return (s_console_level > LOGLEVEL_NONE);

View File

@ -73,6 +73,7 @@ namespace Log
void SetConsoleOutputLevel(LOGLEVEL level); void SetConsoleOutputLevel(LOGLEVEL level);
// adds a debug console output // adds a debug console output
bool IsDebugOutputAvailable();
bool IsDebugOutputEnabled(); bool IsDebugOutputEnabled();
void SetDebugOutputLevel(LOGLEVEL level); void SetDebugOutputLevel(LOGLEVEL level);

View File

@ -178,11 +178,8 @@ QWidget* MainWindow::getContentParent()
void MainWindow::setupAdditionalUi() void MainWindow::setupAdditionalUi()
{ {
const bool show_advanced_settings = QtHost::ShouldShowAdvancedSettings();
makeIconsMasks(menuBar()); makeIconsMasks(menuBar());
updateAdvancedSettingsVisibility();
m_ui.menuDebug->menuAction()->setVisible(show_advanced_settings);
const bool toolbar_visible = Host::GetBaseBoolSettingValue("UI", "ShowToolbar", false); const bool toolbar_visible = Host::GetBaseBoolSettingValue("UI", "ShowToolbar", false);
m_ui.actionViewToolbar->setChecked(toolbar_visible); 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.actionViewStatusBarVerbose, "UI", "VerboseStatusBar", false);
SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableSystemConsole, "Logging", "EnableSystemConsole", false); SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableSystemConsole, "Logging", "EnableSystemConsole", false);
#ifdef _WIN32
// Debug console only exists on Windows. if (Log::IsDebugOutputAvailable())
{
SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableDebugConsole, "Logging", "EnableDebugConsole", false); SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableDebugConsole, "Logging", "EnableDebugConsole", false);
#else }
else
{
m_ui.menuTools->removeAction(m_ui.actionEnableDebugConsole); m_ui.menuTools->removeAction(m_ui.actionEnableDebugConsole);
m_ui.actionEnableDebugConsole->deleteLater(); m_ui.actionEnableDebugConsole->deleteLater();
m_ui.actionEnableDebugConsole = nullptr; m_ui.actionEnableDebugConsole = nullptr;
#endif }
#ifndef PCSX2_DEVBUILD #ifndef PCSX2_DEVBUILD
SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableVerboseLogging, "Logging", "EnableVerbose", false); SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionEnableVerboseLogging, "Logging", "EnableVerbose", false);
#else #else
@ -669,13 +670,25 @@ void MainWindow::onShowAdvancedSettingsToggled(bool checked)
Host::SetBaseBoolSettingValue("UI", "ShowAdvancedSettings", checked); Host::SetBaseBoolSettingValue("UI", "ShowAdvancedSettings", checked);
Host::CommitBaseSettingChanges(); Host::CommitBaseSettingChanges();
m_ui.menuDebug->menuAction()->setVisible(checked); updateAdvancedSettingsVisibility();
// just recreate the entire settings window, it's easier. // just recreate the entire settings window, it's easier.
if (m_settings_window) if (m_settings_window)
recreateSettings(); 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) void MainWindow::onToolsVideoCaptureToggled(bool checked)
{ {
if (!s_vm_valid) if (!s_vm_valid)

View File

@ -222,6 +222,7 @@ private:
void updateDisplayRelatedActions(bool has_surface, bool render_to_main, bool fullscreen); void updateDisplayRelatedActions(bool has_surface, bool render_to_main, bool fullscreen);
void updateGameDependentActions(); void updateGameDependentActions();
void updateStatusBarWidgetVisibility(); void updateStatusBarWidgetVisibility();
void updateAdvancedSettingsVisibility();
void updateWindowTitle(); void updateWindowTitle();
void updateWindowState(bool force_visible = false); void updateWindowState(bool force_visible = false);
void setProgressBar(int current, int total); void setProgressBar(int current, int total);