Skip to content

Commit

Permalink
Qt: Tidy up Tools menu
Browse files Browse the repository at this point in the history
Make System Console and Verbose contingent on Advanced Settings being enabled.
Make Debug Console contingent on actually running under a debugger.
  • Loading branch information
stenzek committed Jan 13, 2024
1 parent 4b6ddaf commit f9833bb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
9 changes: 9 additions & 0 deletions common/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions common/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ namespace Log
void SetConsoleOutputLevel(LOGLEVEL level);

// adds a debug console output
bool IsDebugOutputAvailable();
bool IsDebugOutputEnabled();
void SetDebugOutputLevel(LOGLEVEL level);

Expand Down
39 changes: 26 additions & 13 deletions pcsx2-qt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pcsx2-qt/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f9833bb

Please sign in to comment.