Rework Profiles to use JSON format

* Update OpenRGB Plugin Interface to include functions for loading/saving profile JSON data into OpenRGB profiles
    * Update ProfileManager to handle auto-load profiles (Exit, Open, Resume, Suspend) and move their settings to ProfileManager section
    * Update ProfileManager to store profiles in "profiles" folder in .json format
    * Update ProfileManager to store size profile in sizes.json
    * Update ProfileManager to perform device UpdateMode/UpdateColors when loading profile
    * Code cleanup of ProfileManager and profile-related code
This commit is contained in:
Adam Honse
2025-11-09 15:12:11 -06:00
parent 1403f91b3a
commit 29285a2f1e
17 changed files with 1201 additions and 865 deletions

View File

@@ -103,6 +103,9 @@ using namespace std::chrono_literals;
ResourceManager *ResourceManager::get()
{
/*-----------------------------------------------------*\
| If ResourceManager does not exist yet, create it |
\*-----------------------------------------------------*/
if(!instance)
{
instance = new ResourceManager();
@@ -113,6 +116,25 @@ ResourceManager *ResourceManager::get()
ResourceManager::ResourceManager()
{
/*-----------------------------------------------------*\
| Initialize global instance pointer the when created |
| There should only ever be one instance of |
| ResourceManager |
\*-----------------------------------------------------*/
if(!instance)
{
instance = this;
}
/*-----------------------------------------------------*\
| If, for whatever reason, ResourceManager already |
| exists, delete this instance as only one should exist |
\*-----------------------------------------------------*/
else
{
delete this;
return;
}
/*-----------------------------------------------------*\
| Initialize Detection Variables |
\*-----------------------------------------------------*/
@@ -126,6 +148,7 @@ ResourceManager::ResourceManager()
init_finished = false;
initial_detection = true;
background_thread_running = true;
plugin_manager = NULL;
/*-----------------------------------------------------*\
| Start the background detection thread in advance; it |
@@ -189,7 +212,7 @@ ResourceManager::ResourceManager()
\*-----------------------------------------------------*/
profile_manager = new ProfileManager(GetConfigurationDirectory());
server->SetProfileManager(profile_manager);
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes", true);
rgb_controllers_sizes = profile_manager->GetControllerListFromSizes();
}
ResourceManager::~ResourceManager()
@@ -252,7 +275,7 @@ void ResourceManager::RegisterRGBController(RGBController *rgb_controller)
\*-------------------------------------------------*/
for(unsigned int controller_size_idx = detection_prev_size; controller_size_idx < rgb_controllers_hw.size(); controller_size_idx++)
{
profile_manager->LoadDeviceFromListWithOptions(rgb_controllers_sizes, detection_size_entry_used, rgb_controllers_hw[controller_size_idx], true, false);
profile_manager->LoadControllerFromListWithOptions(rgb_controllers_sizes, detection_size_entry_used, rgb_controllers_hw[controller_size_idx], true, false);
}
UpdateDeviceList();
@@ -691,7 +714,7 @@ void ResourceManager::SetConfigurationDirectory(const filesystem::path &director
profile_manager->SetConfigurationDirectory(directory);
rgb_controllers_sizes.clear();
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes", true);
rgb_controllers_sizes = profile_manager->GetControllerListFromSizes();
}
NetworkServer* ResourceManager::GetServer()