Skip to content

Commit

Permalink
Qt: Hide system console if enabled in nogui mode
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek authored and refractionpcsx2 committed Jul 17, 2022
1 parent bcde888 commit 06e7d6c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pcsx2-qt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ void MainWindow::onThemeChangedFromSettings()

void MainWindow::onLoggingOptionChanged()
{
Host::UpdateLogging();
Host::UpdateLogging(QtHost::InNoGUIMode());
}

void MainWindow::onInputRecNewActionTriggered()
Expand Down
2 changes: 1 addition & 1 deletion pcsx2-qt/QtHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ bool QtHost::InitializeConfig()
// TODO: Handle reset to defaults if load fails.
EmuFolders::LoadConfig(*s_base_settings_interface.get());
EmuFolders::EnsureFoldersExist();
Host::UpdateLogging();
Host::UpdateLogging(QtHost::InNoGUIMode());
return true;
}

Expand Down
31 changes: 15 additions & 16 deletions pcsx2/Frontend/LogSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// Used on both Windows and Linux.
#ifdef _WIN32
static const wchar_t s_console_colors[][ConsoleColors_Count] = {
#define CC(x) L ## x
#define CC(x) L##x
#else
static const char s_console_colors[][ConsoleColors_Count] = {
#define CC(x) x
Expand Down Expand Up @@ -167,10 +167,10 @@ static void ConsoleQt_DoWriteLn(const char* fmt)
std::unique_lock lock(s_log_mutex);

// find time since start of process, but save a syscall if we're not writing timestamps
float message_time = s_log_timestamps ?
static_cast<float>(
Common::Timer::ConvertValueToSeconds(Common::Timer::GetCurrentValue() - s_log_start_timestamp)) :
0.0f;
float message_time =
s_log_timestamps ?
static_cast<float>(Common::Timer::ConvertValueToSeconds(Common::Timer::GetCurrentValue() - s_log_start_timestamp)) :
0.0f;

// split newlines up
const char* start = fmt;
Expand Down Expand Up @@ -253,15 +253,14 @@ static void ConsoleQt_Newline()
ConsoleQt_DoWriteLn("");
}

static const IConsoleWriter ConsoleWriter_WinQt =
{
ConsoleQt_DoWrite,
ConsoleQt_DoWriteLn,
ConsoleQt_DoSetColor,
static const IConsoleWriter ConsoleWriter_WinQt = {
ConsoleQt_DoWrite,
ConsoleQt_DoWriteLn,
ConsoleQt_DoSetColor,

ConsoleQt_DoWrite,
ConsoleQt_Newline,
ConsoleQt_SetTitle,
ConsoleQt_DoWrite,
ConsoleQt_Newline,
ConsoleQt_SetTitle,
};

static void UpdateLoggingSinks(bool system_console, bool file_log)
Expand Down Expand Up @@ -370,9 +369,9 @@ void Host::InitializeEarlyConsole()
UpdateLoggingSinks(true, false);
}

void Host::UpdateLogging()
void Host::UpdateLogging(bool disable_system_console)
{
const bool system_console_enabled = Host::GetBaseBoolSettingValue("Logging", "EnableSystemConsole", false);
const bool system_console_enabled = !disable_system_console && Host::GetBaseBoolSettingValue("Logging", "EnableSystemConsole", false);
const bool file_logging_enabled = Host::GetBaseBoolSettingValue("Logging", "EnableFileLogging", false);

s_log_timestamps = Host::GetBaseBoolSettingValue("Logging", "EnableTimestamps", true);
Expand All @@ -381,7 +380,7 @@ void Host::UpdateLogging()
DevConWriterEnabled = any_logging_sinks && (IsDevBuild || Host::GetBaseBoolSettingValue("Logging", "EnableVerbose", false));
SysConsole.eeConsole.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableEEConsole", false);
SysConsole.iopConsole.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableIOPConsole", false);

// Input Recording Logs
SysConsole.recordingConsole.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableInputRecordingLogs", true);
SysConsole.controlInfo.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableControllerLogs", false);
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/Frontend/LogSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace Host
{
/// Updates the Console handler based on the current configuration.
void UpdateLogging();
void UpdateLogging(bool disable_system_console);

/// Initializes early console logging (for printing command line arguments).
void InitializeEarlyConsole();
Expand Down

0 comments on commit 06e7d6c

Please sign in to comment.