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

19
cli.cpp
View File

@@ -865,7 +865,7 @@ bool OptionSize(std::vector<DeviceOptions>* current_devices, std::string argumen
/*---------------------------------------------------------*\
| Save the profile |
\*---------------------------------------------------------*/
ResourceManager::get()->GetProfileManager()->SaveProfile("sizes", true);
ResourceManager::get()->GetProfileManager()->SaveSizes();
}
return true;
@@ -880,23 +880,6 @@ bool OptionProfile(std::string argument, std::vector<RGBController *>& rgb_contr
\*---------------------------------------------------------*/
if(ResourceManager::get()->GetProfileManager()->LoadProfile(argument))
{
/*-----------------------------------------------------*\
| Change device mode if profile loading was successful |
\*-----------------------------------------------------*/
for(std::size_t controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++)
{
RGBController* device = rgb_controllers[controller_idx];
device->DeviceUpdateMode();
LOG_DEBUG("[CLI] Updating mode for %s to %i", device->GetName().c_str(), device->GetActiveMode());
if(device->GetModeColorMode(device->GetActiveMode()) == MODE_COLORS_PER_LED)
{
device->DeviceUpdateLEDs();
LOG_DEBUG("[CLI] Mode uses per-LED color, also updating LEDs");
}
}
std::cout << "Profile loaded successfully" << std::endl;
return true;
}