From 5ac2ece8b464f51767da851a04718aa140f13202 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Mon, 7 Jul 2025 01:22:45 -0500 Subject: [PATCH] Clean up comment formatting in SettingsManager and main cpp files --- SettingsManager.cpp | 50 ++++++++++++----------- main.cpp | 97 ++++++++++++++++++++++++--------------------- 2 files changed, 78 insertions(+), 69 deletions(-) diff --git a/SettingsManager.cpp b/SettingsManager.cpp index fde61b13..6dc5a80a 100644 --- a/SettingsManager.cpp +++ b/SettingsManager.cpp @@ -28,12 +28,13 @@ SettingsManager::~SettingsManager() json SettingsManager::GetSettings(std::string settings_key) { - /*---------------------------------------------------------*\ - | Check to see if the key exists in the settings store and | - | return the settings associated with the key if it exists | - | We lock the mutex to protect the value from changing | - | while data is being read and copy before unlocking | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Check to see if the key exists in the settings store | + | and return the settings associated with the key if it | + | exists. We lock the mutex to protect the value from | + | changing while data is being read and copy before | + | unlocking. | + \*-----------------------------------------------------*/ json result; mutex.lock(); @@ -56,29 +57,29 @@ void SettingsManager::SetSettings(std::string settings_key, json new_settings) void SettingsManager::LoadSettings(const filesystem::path& filename) { - /*---------------------------------------------------------*\ - | Clear any stored settings before loading | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any stored settings before loading | + \*-----------------------------------------------------*/ mutex.lock(); settings_data.clear(); - /*---------------------------------------------------------*\ - | Store settings filename, so we can save to it later | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Store settings filename, so we can save to it later | + \*-----------------------------------------------------*/ settings_filename = filename; - /*---------------------------------------------------------*\ - | Open input file in binary mode | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Open input file in binary mode | + \*-----------------------------------------------------*/ config_found = filesystem::exists(filename); if(config_found) { std::ifstream settings_file(settings_filename, std::ios::in | std::ios::binary); - /*---------------------------------------------------------*\ - | Read settings into JSON store | - \*---------------------------------------------------------*/ + /*-------------------------------------------------*\ + | Read settings into JSON store | + \*-------------------------------------------------*/ if(settings_file) { try @@ -87,12 +88,13 @@ void SettingsManager::LoadSettings(const filesystem::path& filename) } catch(const std::exception& e) { - /*-------------------------------------------------*\ - | If an exception was caught, that means the JSON | - | parsing failed. Clear out any data in the store | - | as it is corrupt. | - | We could attempt a reload for backup location | - \*-------------------------------------------------*/ + /*-----------------------------------------*\ + | If an exception was caught, that means | + | the JSON parsing failed. Clear out any | + | data in the store as it is corrupt. We | + | could attempt a reload for backup | + | location | + \*-----------------------------------------*/ LOG_ERROR("[SettingsManager] JSON parsing failed: %s", e.what()); settings_data.clear(); diff --git a/main.cpp b/main.cpp index 598906b1..473c4d45 100644 --- a/main.cpp +++ b/main.cpp @@ -103,7 +103,11 @@ void WaitWhileServerOnline(NetworkServer* srv) #ifdef _WIN32 void InstallWinRing0() { - TCHAR winring0_install_location[MAX_PATH]; // driver final location usually C:\windows\system32\drivers\WinRing0x64.sys + /*-----------------------------------------------------*\ + | Driver final location usually | + | C:\windows\system32\drivers\WinRing0x64.sys | + \*-----------------------------------------------------*/ + TCHAR winring0_install_location[MAX_PATH]; uint system_path_length = GetSystemDirectory(winring0_install_location, MAX_PATH); std::string winring0_filename = "WinRing0.sys"; BOOL bIsWow64 = false; @@ -194,43 +198,44 @@ int main(int argc, char* argv[]) { int exitval = EXIT_SUCCESS; #ifdef _WIN32 - /*---------------------------------------------------------*\ - | Windows only - Attach console output | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Windows only - Attach console output | + \*-----------------------------------------------------*/ if (AttachConsole(ATTACH_PARENT_PROCESS)) { - /*---------------------------------------------------------*\ - | We are running under some terminal context; otherwise | - | leave the GUI and CRT alone | - \*---------------------------------------------------------*/ + /*-------------------------------------------------*\ + | We are running under some terminal context; | + | otherwise leave the GUI and CRT alone | + \*-------------------------------------------------*/ freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); } - /*---------------------------------------------------------*\ - | Windows only - Start timer resolution correction thread | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Windows only - Start timer resolution correction | + | thread | + \*-----------------------------------------------------*/ std::thread * InitializeTimerResolutionThread; InitializeTimerResolutionThread = new std::thread(InitializeTimerResolutionThreadFunction); InitializeTimerResolutionThread->detach(); - /*---------------------------------------------------------*\ - | Windows only - Install SMBus Driver WinRing0 | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Windows only - Install SMBus Driver WinRing0 | + \*-----------------------------------------------------*/ InstallWinRing0(); #endif - /*---------------------------------------------------------*\ - | Mac x86/x64 only - Install SMBus Driver macUSPCIO | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Mac x86/x64 only - Install SMBus Driver macUSPCIO | + \*-----------------------------------------------------*/ #ifdef _MACOSX_X86_X64 InitMacUSPCIODriver(); #endif - /*---------------------------------------------------------*\ - | Process command line arguments before detection | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Process command line arguments before detection | + \*-----------------------------------------------------*/ unsigned int ret_flags = cli_pre_detection(argc, argv); ResourceManager::get()->Initialize( @@ -239,26 +244,27 @@ int main(int argc, char* argv[]) ret_flags & RET_FLAG_START_SERVER, ret_flags & RET_FLAG_CLI_POST_DETECTION); - /*---------------------------------------------------------*\ - | If the command line parser indicates that the GUI should | - | run, or if there were no command line arguments, start the| - | GUI. | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | If the command line parser indicates that the GUI | + | should run, or if there were no command line | + | arguments, start the GUI. | + \*-----------------------------------------------------*/ if(ret_flags & RET_FLAG_START_GUI) { LOG_TRACE("[main] initializing GUI"); - /*-----------------------------------------------------*\ - | Enable high DPI scaling support | - \*-----------------------------------------------------*/ + /*-------------------------------------------------*\ + | Enable high DPI scaling support | + \*-------------------------------------------------*/ #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); #endif - /*-----------------------------------------------------*\ - | Enable high DPI fractional scaling support on Windows | - \*-----------------------------------------------------*/ + /*-------------------------------------------------*\ + | Enable high DPI fractional scaling support on | + | Windows | + \*-------------------------------------------------*/ #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) && defined(Q_OS_WIN) QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif @@ -267,9 +273,9 @@ int main(int argc, char* argv[]) QGuiApplication::setDesktopFileName("org.openrgb.OpenRGB"); LOG_TRACE("[main] QApplication created"); - /*---------------------------------------------------------*\ - | Main UI widget | - \*---------------------------------------------------------*/ + /*-------------------------------------------------*\ + | Main UI widget | + \*-------------------------------------------------*/ OpenRGBDialog dlg; LOG_TRACE("[main] Dialog created"); @@ -283,12 +289,13 @@ int main(int argc, char* argv[]) if(ret_flags & RET_FLAG_START_MINIMIZED) { #ifdef _WIN32 - /*---------------------------------------------------------*\ - | Show the window always, even if it will immediately be | - | hidden. On Windows, events are not delivered to | - | nativeEventFilter (for SuspendResume) until the window | - | has been shown once. | - \*---------------------------------------------------------*/ + /*---------------------------------------------*\ + | Show the window always, even if it will | + | immediately be hidden. On Windows, events | + | are not delivered to nativeEventFilter (for | + | SuspendResume) until the window has been | + | shown once. | + \*---------------------------------------------*/ dlg.showMinimized(); #endif #ifdef __APPLE__ @@ -310,11 +317,11 @@ int main(int argc, char* argv[]) } else { - /*---------------------------------------------------------*\ - | If no GUI is needed, we let the background threads run | - | as long as they need, but we need to AT LEAST wait for | - | initialization to finish | - \*---------------------------------------------------------*/ + /*-------------------------------------------------*\ + | If no GUI is needed, we let the background | + | threads run as long as they need, but we need to | + | AT LEAST wait for initialization to finish | + \*-------------------------------------------------*/ ResourceManager::get()->WaitForInitialization(); if(ret_flags & RET_FLAG_START_SERVER)