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
}
bool Log::IsDebugOutputAvailable()
{
#ifdef _WIN32
return IsDebuggerPresent();
#else
return false;
#endif
}
bool Log::IsDebugOutputEnabled()
{
return (s_console_level > LOGLEVEL_NONE);

View File

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

View File

@ -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)

View File

@ -222,6 +222,7 @@ private:
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);