Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: Tidy up Tools menu #10618

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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