Clean up comment formatting in SettingsManager and main cpp files

This commit is contained in:
Adam Honse 2025-07-07 01:22:45 -05:00
parent 37cd743315
commit 5ac2ece8b4
2 changed files with 78 additions and 69 deletions

View file

@ -28,12 +28,13 @@ SettingsManager::~SettingsManager()
json SettingsManager::GetSettings(std::string settings_key) json SettingsManager::GetSettings(std::string settings_key)
{ {
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Check to see if the key exists in the settings store and | | Check to see if the key exists in the settings store |
| return the settings associated with the key if it exists | | and return the settings associated with the key if it |
| We lock the mutex to protect the value from changing | | exists. We lock the mutex to protect the value from |
| while data is being read and copy before unlocking | | changing while data is being read and copy before |
\*---------------------------------------------------------*/ | unlocking. |
\*-----------------------------------------------------*/
json result; json result;
mutex.lock(); mutex.lock();
@ -56,29 +57,29 @@ void SettingsManager::SetSettings(std::string settings_key, json new_settings)
void SettingsManager::LoadSettings(const filesystem::path& filename) void SettingsManager::LoadSettings(const filesystem::path& filename)
{ {
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Clear any stored settings before loading | | Clear any stored settings before loading |
\*---------------------------------------------------------*/ \*-----------------------------------------------------*/
mutex.lock(); mutex.lock();
settings_data.clear(); 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; settings_filename = filename;
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Open input file in binary mode | | Open input file in binary mode |
\*---------------------------------------------------------*/ \*-----------------------------------------------------*/
config_found = filesystem::exists(filename); config_found = filesystem::exists(filename);
if(config_found) if(config_found)
{ {
std::ifstream settings_file(settings_filename, std::ios::in | std::ios::binary); 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) if(settings_file)
{ {
try try
@ -87,12 +88,13 @@ void SettingsManager::LoadSettings(const filesystem::path& filename)
} }
catch(const std::exception& e) catch(const std::exception& e)
{ {
/*-------------------------------------------------*\ /*-----------------------------------------*\
| If an exception was caught, that means the JSON | | If an exception was caught, that means |
| parsing failed. Clear out any data in the store | | the JSON parsing failed. Clear out any |
| as it is corrupt. | | data in the store as it is corrupt. We |
| We could attempt a reload for backup location | | could attempt a reload for backup |
\*-------------------------------------------------*/ | location |
\*-----------------------------------------*/
LOG_ERROR("[SettingsManager] JSON parsing failed: %s", e.what()); LOG_ERROR("[SettingsManager] JSON parsing failed: %s", e.what());
settings_data.clear(); settings_data.clear();

View file

@ -103,7 +103,11 @@ void WaitWhileServerOnline(NetworkServer* srv)
#ifdef _WIN32 #ifdef _WIN32
void InstallWinRing0() 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); uint system_path_length = GetSystemDirectory(winring0_install_location, MAX_PATH);
std::string winring0_filename = "WinRing0.sys"; std::string winring0_filename = "WinRing0.sys";
BOOL bIsWow64 = false; BOOL bIsWow64 = false;
@ -194,43 +198,44 @@ int main(int argc, char* argv[])
{ {
int exitval = EXIT_SUCCESS; int exitval = EXIT_SUCCESS;
#ifdef _WIN32 #ifdef _WIN32
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Windows only - Attach console output | | Windows only - Attach console output |
\*---------------------------------------------------------*/ \*-----------------------------------------------------*/
if (AttachConsole(ATTACH_PARENT_PROCESS)) if (AttachConsole(ATTACH_PARENT_PROCESS))
{ {
/*---------------------------------------------------------*\ /*-------------------------------------------------*\
| We are running under some terminal context; otherwise | | We are running under some terminal context; |
| leave the GUI and CRT alone | | otherwise leave the GUI and CRT alone |
\*---------------------------------------------------------*/ \*-------------------------------------------------*/
freopen("CONIN$", "r", stdin); freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr); freopen("CONOUT$", "w", stderr);
} }
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Windows only - Start timer resolution correction thread | | Windows only - Start timer resolution correction |
\*---------------------------------------------------------*/ | thread |
\*-----------------------------------------------------*/
std::thread * InitializeTimerResolutionThread; std::thread * InitializeTimerResolutionThread;
InitializeTimerResolutionThread = new std::thread(InitializeTimerResolutionThreadFunction); InitializeTimerResolutionThread = new std::thread(InitializeTimerResolutionThreadFunction);
InitializeTimerResolutionThread->detach(); InitializeTimerResolutionThread->detach();
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Windows only - Install SMBus Driver WinRing0 | | Windows only - Install SMBus Driver WinRing0 |
\*---------------------------------------------------------*/ \*-----------------------------------------------------*/
InstallWinRing0(); InstallWinRing0();
#endif #endif
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Mac x86/x64 only - Install SMBus Driver macUSPCIO | | Mac x86/x64 only - Install SMBus Driver macUSPCIO |
\*---------------------------------------------------------*/ \*-----------------------------------------------------*/
#ifdef _MACOSX_X86_X64 #ifdef _MACOSX_X86_X64
InitMacUSPCIODriver(); InitMacUSPCIODriver();
#endif #endif
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| Process command line arguments before detection | | Process command line arguments before detection |
\*---------------------------------------------------------*/ \*-----------------------------------------------------*/
unsigned int ret_flags = cli_pre_detection(argc, argv); unsigned int ret_flags = cli_pre_detection(argc, argv);
ResourceManager::get()->Initialize( ResourceManager::get()->Initialize(
@ -239,26 +244,27 @@ int main(int argc, char* argv[])
ret_flags & RET_FLAG_START_SERVER, ret_flags & RET_FLAG_START_SERVER,
ret_flags & RET_FLAG_CLI_POST_DETECTION); ret_flags & RET_FLAG_CLI_POST_DETECTION);
/*---------------------------------------------------------*\ /*-----------------------------------------------------*\
| If the command line parser indicates that the GUI should | | If the command line parser indicates that the GUI |
| run, or if there were no command line arguments, start the| | should run, or if there were no command line |
| GUI. | | arguments, start the GUI. |
\*---------------------------------------------------------*/ \*-----------------------------------------------------*/
if(ret_flags & RET_FLAG_START_GUI) if(ret_flags & RET_FLAG_START_GUI)
{ {
LOG_TRACE("[main] initializing 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) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
#endif #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) #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) && defined(Q_OS_WIN)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif #endif
@ -267,9 +273,9 @@ int main(int argc, char* argv[])
QGuiApplication::setDesktopFileName("org.openrgb.OpenRGB"); QGuiApplication::setDesktopFileName("org.openrgb.OpenRGB");
LOG_TRACE("[main] QApplication created"); LOG_TRACE("[main] QApplication created");
/*---------------------------------------------------------*\ /*-------------------------------------------------*\
| Main UI widget | | Main UI widget |
\*---------------------------------------------------------*/ \*-------------------------------------------------*/
OpenRGBDialog dlg; OpenRGBDialog dlg;
LOG_TRACE("[main] Dialog created"); LOG_TRACE("[main] Dialog created");
@ -283,12 +289,13 @@ int main(int argc, char* argv[])
if(ret_flags & RET_FLAG_START_MINIMIZED) if(ret_flags & RET_FLAG_START_MINIMIZED)
{ {
#ifdef _WIN32 #ifdef _WIN32
/*---------------------------------------------------------*\ /*---------------------------------------------*\
| Show the window always, even if it will immediately be | | Show the window always, even if it will |
| hidden. On Windows, events are not delivered to | | immediately be hidden. On Windows, events |
| nativeEventFilter (for SuspendResume) until the window | | are not delivered to nativeEventFilter (for |
| has been shown once. | | SuspendResume) until the window has been |
\*---------------------------------------------------------*/ | shown once. |
\*---------------------------------------------*/
dlg.showMinimized(); dlg.showMinimized();
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
@ -310,11 +317,11 @@ int main(int argc, char* argv[])
} }
else else
{ {
/*---------------------------------------------------------*\ /*-------------------------------------------------*\
| If no GUI is needed, we let the background threads run | | If no GUI is needed, we let the background |
| as long as they need, but we need to AT LEAST wait for | | threads run as long as they need, but we need to |
| initialization to finish | | AT LEAST wait for initialization to finish |
\*---------------------------------------------------------*/ \*-------------------------------------------------*/
ResourceManager::get()->WaitForInitialization(); ResourceManager::get()->WaitForInitialization();
if(ret_flags & RET_FLAG_START_SERVER) if(ret_flags & RET_FLAG_START_SERVER)