Qt: Hide system console if enabled in nogui mode

This commit is contained in:
Connor McLaughlin 2022-07-18 00:54:48 +10:00 committed by refractionpcsx2
parent bcde888257
commit 06e7d6c3df
4 changed files with 18 additions and 19 deletions

View File

@ -1393,7 +1393,7 @@ void MainWindow::onThemeChangedFromSettings()
void MainWindow::onLoggingOptionChanged() void MainWindow::onLoggingOptionChanged()
{ {
Host::UpdateLogging(); Host::UpdateLogging(QtHost::InNoGUIMode());
} }
void MainWindow::onInputRecNewActionTriggered() void MainWindow::onInputRecNewActionTriggered()

View File

@ -227,7 +227,7 @@ bool QtHost::InitializeConfig()
// TODO: Handle reset to defaults if load fails. // TODO: Handle reset to defaults if load fails.
EmuFolders::LoadConfig(*s_base_settings_interface.get()); EmuFolders::LoadConfig(*s_base_settings_interface.get());
EmuFolders::EnsureFoldersExist(); EmuFolders::EnsureFoldersExist();
Host::UpdateLogging(); Host::UpdateLogging(QtHost::InNoGUIMode());
return true; return true;
} }

View File

@ -36,7 +36,7 @@
// Used on both Windows and Linux. // Used on both Windows and Linux.
#ifdef _WIN32 #ifdef _WIN32
static const wchar_t s_console_colors[][ConsoleColors_Count] = { static const wchar_t s_console_colors[][ConsoleColors_Count] = {
#define CC(x) L ## x #define CC(x) L##x
#else #else
static const char s_console_colors[][ConsoleColors_Count] = { static const char s_console_colors[][ConsoleColors_Count] = {
#define CC(x) x #define CC(x) x
@ -167,9 +167,9 @@ static void ConsoleQt_DoWriteLn(const char* fmt)
std::unique_lock lock(s_log_mutex); std::unique_lock lock(s_log_mutex);
// find time since start of process, but save a syscall if we're not writing timestamps // find time since start of process, but save a syscall if we're not writing timestamps
float message_time = s_log_timestamps ? float message_time =
static_cast<float>( s_log_timestamps ?
Common::Timer::ConvertValueToSeconds(Common::Timer::GetCurrentValue() - s_log_start_timestamp)) : static_cast<float>(Common::Timer::ConvertValueToSeconds(Common::Timer::GetCurrentValue() - s_log_start_timestamp)) :
0.0f; 0.0f;
// split newlines up // split newlines up
@ -253,8 +253,7 @@ static void ConsoleQt_Newline()
ConsoleQt_DoWriteLn(""); ConsoleQt_DoWriteLn("");
} }
static const IConsoleWriter ConsoleWriter_WinQt = static const IConsoleWriter ConsoleWriter_WinQt = {
{
ConsoleQt_DoWrite, ConsoleQt_DoWrite,
ConsoleQt_DoWriteLn, ConsoleQt_DoWriteLn,
ConsoleQt_DoSetColor, ConsoleQt_DoSetColor,
@ -370,9 +369,9 @@ void Host::InitializeEarlyConsole()
UpdateLoggingSinks(true, false); 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); const bool file_logging_enabled = Host::GetBaseBoolSettingValue("Logging", "EnableFileLogging", false);
s_log_timestamps = Host::GetBaseBoolSettingValue("Logging", "EnableTimestamps", true); s_log_timestamps = Host::GetBaseBoolSettingValue("Logging", "EnableTimestamps", true);

View File

@ -18,7 +18,7 @@
namespace Host namespace Host
{ {
/// Updates the Console handler based on the current configuration. /// 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). /// Initializes early console logging (for printing command line arguments).
void InitializeEarlyConsole(); void InitializeEarlyConsole();