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 4992d5a11d
commit eeee7c2bd1
17 changed files with 1320 additions and 950 deletions

View File

@@ -704,7 +704,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
memcpy(&new_size, data + sizeof(int), sizeof(int));
controllers[header.pkt_dev_idx]->ResizeZone(zone, new_size);
profile_manager->SaveProfile("sizes", true);
profile_manager->SaveSizes();
}
break;
@@ -909,11 +909,6 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
profile_manager->LoadProfile(profile_name);
}
for(RGBController* controller : controllers)
{
controller->UpdateLEDs();
}
break;
case NET_PACKET_ID_REQUEST_DELETE_PROFILE:
@@ -964,7 +959,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
memcpy(&zone, data, sizeof(int));
controllers[header.pkt_dev_idx]->ClearSegments(zone);
profile_manager->SaveProfile("sizes", true);
profile_manager->SaveSizes();
}
break;
@@ -979,7 +974,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
if(header.pkt_dev_idx < controllers.size())
{
controllers[header.pkt_dev_idx]->SetSegmentDescription((unsigned char *)data);
profile_manager->SaveProfile("sizes", true);
profile_manager->SaveSizes();
}
}
}

View File

@@ -15,6 +15,7 @@
#include <QtPlugin>
#include <QLabel>
#include <QMenu>
#include "nlohmann/json.hpp"
#include "ResourceManagerInterface.h"
#define OpenRGBPluginInterface_IID "com.OpenRGBPluginInterface"
@@ -87,6 +88,9 @@ public:
virtual QWidget* GetWidget() = 0;
virtual QMenu* GetTrayMenu() = 0;
virtual void Unload() = 0;
virtual void OnProfileAboutToLoad() = 0;
virtual void OnProfileLoad(nlohmann::json profile_data) = 0;
virtual nlohmann::json OnProfileSave() = 0;
virtual unsigned char* OnSDKCommand(unsigned int pkt_id, unsigned char * pkt_data, unsigned int *pkt_size) = 0;
};

View File

@@ -533,6 +533,58 @@ void PluginManager::UnloadPlugins()
}
}
void PluginManager::OnProfileAboutToLoad()
{
/*-----------------------------------------------------*\
| Loop through all plugins and signal profile about to |
| load |
\*-----------------------------------------------------*/
for(std::size_t plugin_idx = 0; plugin_idx < ActivePlugins.size(); plugin_idx++)
{
if(ActivePlugins[plugin_idx].enabled && ActivePlugins[plugin_idx].loader->isLoaded())
{
ActivePlugins[plugin_idx].plugin->OnProfileAboutToLoad();
}
}
}
void PluginManager::OnProfileLoad(nlohmann::json profile_data)
{
/*-----------------------------------------------------*\
| Loop through all plugins call their OnProfileLoad if |
| the profile data contains an entry for that plugin |
\*-----------------------------------------------------*/
for(std::size_t plugin_idx = 0; plugin_idx < ActivePlugins.size(); plugin_idx++)
{
if(ActivePlugins[plugin_idx].enabled && ActivePlugins[plugin_idx].loader->isLoaded())
{
if(profile_data.contains(ActivePlugins[plugin_idx].plugin->GetPluginInfo().Name))
{
ActivePlugins[plugin_idx].plugin->OnProfileLoad(profile_data[ActivePlugins[plugin_idx].plugin->GetPluginInfo().Name]);
}
}
}
}
nlohmann::json PluginManager::OnProfileSave()
{
nlohmann::json plugin_json;
/*-----------------------------------------------------*\
| Loop through all plugins and gather their profile |
| data |
\*-----------------------------------------------------*/
for(std::size_t plugin_idx = 0; plugin_idx < ActivePlugins.size(); plugin_idx++)
{
if(ActivePlugins[plugin_idx].enabled && ActivePlugins[plugin_idx].loader->isLoaded())
{
plugin_json[ActivePlugins[plugin_idx].plugin->GetPluginInfo().Name] = ActivePlugins[plugin_idx].plugin->OnProfileSave();
}
}
return(plugin_json);
}
unsigned char * PluginManager::OnSDKCommand(unsigned int plugin_idx, unsigned int pkt_id, unsigned char * pkt_data, unsigned int * pkt_size)
{
unsigned char * out_data = NULL;

View File

@@ -60,6 +60,9 @@ public:
void LoadPlugins();
void UnloadPlugins();
void OnProfileAboutToLoad();
void OnProfileLoad(nlohmann::json profile_data);
nlohmann::json OnProfileSave();
unsigned char * OnSDKCommand(unsigned int plugin_idx, unsigned int pkt_id, unsigned char * pkt_data, unsigned int * pkt_size);
std::vector<OpenRGBPluginEntry> ActivePlugins;

View File

@@ -12,6 +12,7 @@
#pragma once
#include <string>
#include "nlohmann/json.hpp"
class PluginManagerInterface
{
@@ -25,5 +26,8 @@ public:
virtual void LoadPlugins() = 0;
virtual void UnloadPlugins() = 0;
virtual void OnProfileAboutToLoad() = 0;
virtual void OnProfileLoad(nlohmann::json profile_data) = 0;
virtual nlohmann::json OnProfileSave() = 0;
virtual unsigned char * OnSDKCommand(unsigned int plugin_idx, unsigned int pkt_id, unsigned char * pkt_data, unsigned int * pkt_size) = 0;
};

View File

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,8 @@
| |
| OpenRGB profile manager |
| |
| Adam Honse <calcprogrammer1@gmail.com> 09 Nov 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
@@ -15,34 +17,37 @@
class ProfileManagerInterface
{
public:
virtual bool SaveProfile
(
std::string profile_name,
bool sizes = false
) = 0;
virtual bool LoadProfile(std::string profile_name) = 0;
virtual bool LoadSizeFromProfile(std::string profile_name) = 0;
virtual void DeleteProfile(std::string profile_name) = 0;
virtual unsigned char * GetProfileListDescription() = 0;
virtual void DeleteProfile(std::string profile_name) = 0;
std::vector<std::string> profile_list;
virtual std::string GetActiveProfile() = 0;
virtual std::vector<RGBController*> GetControllerListFromProfile(nlohmann::json profile_json) = 0;
virtual std::vector<RGBController*> GetControllerListFromSizes() = 0;
virtual std::vector<std::string> GetProfileList() = 0;
virtual unsigned char * GetProfileListDescription() = 0;
virtual bool LoadDeviceFromListWithOptions
(
std::vector<RGBController*>& temp_controllers,
std::vector<bool>& temp_controller_used,
RGBController* load_controller,
bool load_size,
bool load_settings
) = 0;
virtual bool LoadControllerFromListWithOptions
(
std::vector<RGBController*>& temp_controllers,
std::vector<bool>& temp_controller_used,
RGBController* load_controller,
bool load_size,
bool load_settings
) = 0;
virtual std::vector<RGBController*> LoadProfileToList
(
std::string profile_name,
bool sizes = false
) = 0;
virtual bool LoadProfile(std::string profile_name) = 0;
virtual nlohmann::json ReadProfileJSON(std::string profile_name) = 0;
virtual bool SaveProfile(std::string profile_name) = 0;
virtual bool SaveProfileFromJSON(nlohmann::json profile_json) = 0;
virtual bool SaveSizes() = 0;
virtual void SetConfigurationDirectory(const filesystem::path& directory) = 0;
virtual void SetProfileListFromDescription(char * data_buf) = 0;
virtual void UpdateProfileList() = 0;
virtual void SetConfigurationDirectory(const filesystem::path& directory) = 0;
protected:
virtual ~ProfileManagerInterface() {};
};
@@ -53,43 +58,70 @@ public:
ProfileManager(const filesystem::path& config_dir);
~ProfileManager();
bool SaveProfile
(
std::string profile_name,
bool sizes = false
);
bool LoadProfile(std::string profile_name);
bool LoadSizeFromProfile(std::string profile_name);
void DeleteProfile(std::string profile_name);
unsigned char * GetProfileListDescription();
void DeleteProfile(std::string profile_name);
std::vector<std::string> profile_list;
std::string GetActiveProfile();
std::vector<RGBController*> GetControllerListFromProfile(nlohmann::json profile_json);
std::vector<RGBController*> GetControllerListFromSizes();
std::vector<std::string> GetProfileList();
unsigned char * GetProfileListDescription();
bool LoadDeviceFromListWithOptions
(
std::vector<RGBController*>& temp_controllers,
std::vector<bool>& temp_controller_used,
RGBController* load_controller,
bool load_size,
bool load_settings
);
bool LoadAutoProfileExit();
bool LoadAutoProfileOpen();
bool LoadAutoProfileResume();
bool LoadAutoProfileSuspend();
std::vector<RGBController*> LoadProfileToList
(
std::string profile_name,
bool sizes = false
);
bool LoadControllerFromListWithOptions
(
std::vector<RGBController*>& temp_controllers,
std::vector<bool>& temp_controller_used,
RGBController* load_controller,
bool load_size,
bool load_settings
);
void SetConfigurationDirectory(const filesystem::path& directory);
bool LoadProfile(std::string profile_name);
nlohmann::json ReadProfileJSON(std::string profile_name);
bool SaveProfile(std::string profile_name);
bool SaveProfileFromJSON(nlohmann::json profile_json);
bool SaveSizes();
void SetConfigurationDirectory(const filesystem::path& directory);
void SetProfileListFromDescription(char * data_buf);
void UpdateProfileList();
private:
filesystem::path configuration_directory;
/*-----------------------------------------------------*\
| List of available profiles |
\*-----------------------------------------------------*/
std::vector<std::string> profile_list;
void UpdateProfileList();
bool LoadProfileWithOptions
(
std::string profile_name,
bool load_size,
bool load_settings
);
/*-----------------------------------------------------*\
| Active profile string |
\*-----------------------------------------------------*/
std::string active_profile;
/*-----------------------------------------------------*\
| Profile paths |
\*-----------------------------------------------------*/
filesystem::path configuration_directory;
filesystem::path profile_directory;
/*-----------------------------------------------------*\
| Private functions |
\*-----------------------------------------------------*/
bool LoadAutoProfile(std::string setting_name);
bool LoadProfileWithOptions
(
std::string profile_name,
bool load_size,
bool load_settings
);
nlohmann::json ReadProfileFileJSON(filesystem::path profile_filepath);
};

View File

@@ -3458,7 +3458,7 @@ nlohmann::json RGBController::GetDeviceDescriptionJSON()
\*-----------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
{
controller_json["leds"][led_idx] = GetLEDDescriptionJSON((int)led_idx);
controller_json["leds"][led_idx] = GetLEDDescriptionJSON(leds[led_idx]);
}
/*-----------------------------------------------------*\
@@ -3474,7 +3474,7 @@ nlohmann::json RGBController::GetDeviceDescriptionJSON()
\*-----------------------------------------------------*/
for(std::size_t mode_idx = 0; mode_idx < modes.size(); mode_idx++)
{
controller_json["modes"][mode_idx] = GetModeDescriptionJSON((int)mode_idx);
controller_json["modes"][mode_idx] = GetModeDescriptionJSON(modes[mode_idx]);
}
/*-----------------------------------------------------*\
@@ -3482,7 +3482,7 @@ nlohmann::json RGBController::GetDeviceDescriptionJSON()
\*-----------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
controller_json["zones"][zone_idx] = GetZoneDescriptionJSON((int)zone_idx);
controller_json["zones"][zone_idx] = GetZoneDescriptionJSON(zones[zone_idx]);
}
/*-----------------------------------------------------*\
@@ -3493,108 +3493,124 @@ nlohmann::json RGBController::GetDeviceDescriptionJSON()
return(controller_json);
}
nlohmann::json RGBController::GetLEDDescriptionJSON(int led)
nlohmann::json RGBController::GetLEDDescriptionJSON(led led)
{
nlohmann::json led_json;
/*-----------------------------------------------------*\
| LED Information |
\*-----------------------------------------------------*/
led_json["name"] = leds[led].name;
led_json["value"] = leds[led].value;
led_json["name"] = led.name;
led_json["value"] = led.value;
return(led_json);
}
nlohmann::json RGBController::GetModeDescriptionJSON(int mode)
nlohmann::json RGBController::GetMatrixMapDescriptionJSON(matrix_map_type* matrix_map)
{
nlohmann::json matrix_map_json;
if(matrix_map != NULL)
{
matrix_map_json["height"] = matrix_map->height;
matrix_map_json["width"] = matrix_map->width;
for(unsigned int matrix_map_idx = 0; matrix_map_idx < (matrix_map->height * matrix_map->width); matrix_map_idx++)
{
matrix_map_json["map"][matrix_map_idx] = matrix_map->map[matrix_map_idx];
}
}
return(matrix_map_json);
}
nlohmann::json RGBController::GetModeDescriptionJSON(mode mode)
{
nlohmann::json mode_json;
/*-----------------------------------------------------*\
| Mode Information |
\*-----------------------------------------------------*/
mode_json["name"] = modes[mode].name;
mode_json["value"] = modes[mode].value;
mode_json["flags"] = modes[mode].flags;
mode_json["speed_min"] = modes[mode].speed_min;
mode_json["speed_max"] = modes[mode].speed_max;
mode_json["brightness_min"] = modes[mode].brightness_min;
mode_json["brightness_max"] = modes[mode].brightness_max;
mode_json["colors_min"] = modes[mode].colors_min;
mode_json["colors_max"] = modes[mode].colors_max;
mode_json["name"] = mode.name;
mode_json["value"] = mode.value;
mode_json["flags"] = mode.flags;
mode_json["speed_min"] = mode.speed_min;
mode_json["speed_max"] = mode.speed_max;
mode_json["brightness_min"] = mode.brightness_min;
mode_json["brightness_max"] = mode.brightness_max;
mode_json["colors_min"] = mode.colors_min;
mode_json["colors_max"] = mode.colors_max;
/*-----------------------------------------------------*\
| Mode Settings |
\*-----------------------------------------------------*/
mode_json["speed"] = modes[mode].speed;
mode_json["brightness"] = modes[mode].brightness;
mode_json["direction"] = modes[mode].direction;
mode_json["color_mode"] = modes[mode].color_mode;
mode_json["speed"] = mode.speed;
mode_json["brightness"] = mode.brightness;
mode_json["direction"] = mode.direction;
mode_json["color_mode"] = mode.color_mode;
for(std::size_t color_idx = 0; color_idx < modes[mode].colors.size(); color_idx++)
for(std::size_t color_idx = 0; color_idx < mode.colors.size(); color_idx++)
{
mode_json["colors"][color_idx] = modes[mode].colors[color_idx];
mode_json["colors"][color_idx] = mode.colors[color_idx];
}
return(mode_json);
}
nlohmann::json RGBController::GetSegmentDescriptionJSON(int zone, int segment)
nlohmann::json RGBController::GetSegmentDescriptionJSON(segment segment)
{
nlohmann::json segment_json;
/*-----------------------------------------------------*\
| Segment Information |
\*-----------------------------------------------------*/
segment_json["name"] = zones[zone].segments[segment].name;
segment_json["type"] = zones[zone].segments[segment].type;
segment_json["start_idx"] = zones[zone].segments[segment].start_idx;
segment_json["leds_count"] = zones[zone].segments[segment].leds_count;
segment_json["name"] = segment.name;
segment_json["type"] = segment.type;
segment_json["start_idx"] = segment.start_idx;
segment_json["leds_count"] = segment.leds_count;
if(zones[zone].segments[segment].matrix_map != NULL)
if(segment.matrix_map != NULL)
{
segment_json["matrix_map"]["height"] = zones[zone].segments[segment].matrix_map->height;
segment_json["matrix_map"]["width"] = zones[zone].segments[segment].matrix_map->width;
for(unsigned int matrix_map_idx = 0; matrix_map_idx < (zones[zone].segments[segment].matrix_map->height * zones[zone].segments[segment].matrix_map->width); matrix_map_idx++)
{
segment_json["matrix_map"]["map"][matrix_map_idx] = zones[zone].segments[segment].matrix_map->map[matrix_map_idx];
}
segment_json["matrix_map"] = GetMatrixMapDescriptionJSON(segment.matrix_map);
}
return(segment_json);
}
nlohmann::json RGBController::GetZoneDescriptionJSON(int zone)
nlohmann::json RGBController::GetZoneDescriptionJSON(zone zone)
{
nlohmann::json zone_json;
/*-----------------------------------------------------*\
| Zone Information |
\*-----------------------------------------------------*/
zone_json["name"] = zones[zone].name;
zone_json["type"] = zones[zone].type;
zone_json["leds_count"] = zones[zone].leds_count;
zone_json["leds_min"] = zones[zone].leds_min;
zone_json["leds_max"] = zones[zone].leds_max;
zone_json["name"] = zone.name;
zone_json["type"] = zone.type;
zone_json["leds_count"] = zone.leds_count;
zone_json["leds_min"] = zone.leds_min;
zone_json["leds_max"] = zone.leds_max;
if(zones[zone].matrix_map != NULL)
if(zone.matrix_map != NULL)
{
zone_json["matrix_map"]["height"] = zones[zone].matrix_map->height;
zone_json["matrix_map"]["width"] = zones[zone].matrix_map->width;
for(unsigned int matrix_map_idx = 0; matrix_map_idx < (zones[zone].matrix_map->height * zones[zone].matrix_map->width); matrix_map_idx++)
{
zone_json["matrix_map"]["map"][matrix_map_idx] = zones[zone].matrix_map->map[matrix_map_idx];
}
zone_json["matrix_map"] = GetMatrixMapDescriptionJSON(zone.matrix_map);
}
for(std::size_t segment_idx = 0; segment_idx < zones[zone].segments.size(); segment_idx++)
for(std::size_t segment_idx = 0; segment_idx < zone.segments.size(); segment_idx++)
{
zone_json["segments"][segment_idx] = GetSegmentDescriptionJSON(zone, segment_idx);
zone_json["segments"][segment_idx] = GetSegmentDescriptionJSON(zone.segments[segment_idx]);
}
zone_json["flags"] = zones[zone].flags;
zone_json["flags"] = zone.flags;
for(std::size_t mode_idx = 0; mode_idx < zone.modes.size(); mode_idx++)
{
zone_json["modes"][mode_idx] = GetModeDescriptionJSON(zone.modes[mode_idx]);
}
if(zone.modes.size() > 0)
{
zone_json["active_mode"] = zone.active_mode;
}
return(zone_json);
}
@@ -3753,6 +3769,30 @@ led RGBController::SetLEDDescriptionJSON(nlohmann::json led_json)
return(new_led);
}
matrix_map_type* RGBController::SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json)
{
matrix_map_type* matrix_map = NULL;
if(matrix_map_json["matrix_map"].contains("width") &&
matrix_map_json["matrix_map"].contains("height") &&
matrix_map_json["matrix_map"].contains("map"))
{
matrix_map = new matrix_map_type;
matrix_map->width = matrix_map_json["matrix_map"]["width"];
matrix_map->height = matrix_map_json["matrix_map"]["height"];
matrix_map->map = new unsigned int[matrix_map->width * matrix_map->height];
for(unsigned int matrix_map_idx = 0; matrix_map_idx < matrix_map->width * matrix_map->height; matrix_map_idx++)
{
matrix_map->map[matrix_map_idx] = matrix_map_json["matrix_map"]["map"][matrix_map_idx];
}
}
return(matrix_map);
}
mode RGBController::SetModeDescriptionJSON(nlohmann::json mode_json)
{
mode new_mode;
@@ -3870,22 +3910,7 @@ segment RGBController::SetSegmentDescriptionJSON(nlohmann::json segment_json)
if(segment_json.contains("matrix_map"))
{
if(segment_json["matrix_map"].contains("width") &&
segment_json["matrix_map"].contains("height") &&
segment_json["matrix_map"].contains("map"))
{
new_segment.matrix_map = new matrix_map_type;
new_segment.matrix_map->width = segment_json["matrix_map"]["width"];
new_segment.matrix_map->height = segment_json["matrix_map"]["height"];
new_segment.matrix_map->map = new unsigned int[new_segment.matrix_map->width * new_segment.matrix_map->height];
for(unsigned int matrix_map_idx = 0; matrix_map_idx < new_segment.matrix_map->width * new_segment.matrix_map->height; matrix_map_idx++)
{
new_segment.matrix_map->map[matrix_map_idx] = segment_json["matrix_map"]["map"][matrix_map_idx];
}
}
new_segment.matrix_map = SetMatrixMapDescriptionJSON(segment_json["matrix_map"]);
}
return(new_segment);
@@ -3925,22 +3950,7 @@ zone RGBController::SetZoneDescriptionJSON(nlohmann::json zone_json)
if(zone_json.contains("matrix_map"))
{
if(zone_json["matrix_map"].contains("width") &&
zone_json["matrix_map"].contains("height") &&
zone_json["matrix_map"].contains("map"))
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->width = zone_json["matrix_map"]["width"];
new_zone.matrix_map->height = zone_json["matrix_map"]["height"];
new_zone.matrix_map->map = new unsigned int[new_zone.matrix_map->width * new_zone.matrix_map->height];
for(unsigned int matrix_map_idx = 0; matrix_map_idx < new_zone.matrix_map->width * new_zone.matrix_map->height; matrix_map_idx++)
{
new_zone.matrix_map->map[matrix_map_idx] = zone_json["matrix_map"]["map"][matrix_map_idx];
}
}
new_zone.matrix_map = SetMatrixMapDescriptionJSON(zone_json["matrix_map"]);
}
if(zone_json.contains("segments"))
@@ -3949,13 +3959,28 @@ zone RGBController::SetZoneDescriptionJSON(nlohmann::json zone_json)
for(std::size_t segment_idx = 0; segment_idx < new_zone.segments.size(); segment_idx++)
{
new_zone.segments[segment_idx] = SetSegmentDescriptionJSON(zone_json["segments"][segment_idx]);
new_zone.segments[segment_idx] = SetSegmentDescriptionJSON(zone_json["segments"][segment_idx]);
}
}
if(zone_json.contains("flags"))
{
new_zone.flags = zone_json["flags"];
new_zone.flags = zone_json["flags"];
}
if(zone_json.contains("modes"))
{
new_zone.modes.resize(zone_json["modes"].size());
for(std::size_t mode_idx = 0; mode_idx < new_zone.modes.size(); mode_idx++)
{
new_zone.modes[mode_idx] = SetModeDescriptionJSON(zone_json["modes"][mode_idx]);
}
}
if(zone_json.contains("active_mode"))
{
new_zone.active_mode = zone_json["active_mode"];
}
return(new_zone);

View File

@@ -431,13 +431,15 @@ public:
| JSON Description Functions |
\*-----------------------------------------------------*/
virtual nlohmann::json GetDeviceDescriptionJSON() = 0;
virtual nlohmann::json GetLEDDescriptionJSON(int led) = 0;
virtual nlohmann::json GetModeDescriptionJSON(int mode) = 0;
virtual nlohmann::json GetSegmentDescriptionJSON(int zone, int segment) = 0;
virtual nlohmann::json GetZoneDescriptionJSON(int zone) = 0;
virtual nlohmann::json GetLEDDescriptionJSON(led led) = 0;
virtual nlohmann::json GetMatrixMapDescriptionJSON(matrix_map_type* matrix_map) = 0;
virtual nlohmann::json GetModeDescriptionJSON(mode mode) = 0;
virtual nlohmann::json GetSegmentDescriptionJSON(segment segment) = 0;
virtual nlohmann::json GetZoneDescriptionJSON(zone zone) = 0;
virtual void SetDeviceDescriptionJSON(nlohmann::json controller_json) = 0;
virtual led SetLEDDescriptionJSON(nlohmann::json led_json) = 0;
virtual matrix_map_type* SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json) = 0;
virtual mode SetModeDescriptionJSON(nlohmann::json mode_json) = 0;
virtual segment SetSegmentDescriptionJSON(nlohmann::json segment_json) = 0;
virtual zone SetZoneDescriptionJSON(nlohmann::json zone_json) = 0;
@@ -625,13 +627,15 @@ public:
| JSON Description Functions |
\*-----------------------------------------------------*/
nlohmann::json GetDeviceDescriptionJSON();
nlohmann::json GetLEDDescriptionJSON(int led);
nlohmann::json GetModeDescriptionJSON(int mode);
nlohmann::json GetSegmentDescriptionJSON(int zone, int segment);
nlohmann::json GetZoneDescriptionJSON(int zone);
nlohmann::json GetLEDDescriptionJSON(led led);
nlohmann::json GetMatrixMapDescriptionJSON(matrix_map_type* matrix_map);
nlohmann::json GetModeDescriptionJSON(mode mode);
nlohmann::json GetSegmentDescriptionJSON(segment segment);
nlohmann::json GetZoneDescriptionJSON(zone zone);
void SetDeviceDescriptionJSON(nlohmann::json controller_json);
led SetLEDDescriptionJSON(nlohmann::json led_json);
matrix_map_type* SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json);
mode SetModeDescriptionJSON(nlohmann::json mode_json);
segment SetSegmentDescriptionJSON(nlohmann::json segment_json);
zone SetZoneDescriptionJSON(nlohmann::json zone_json);

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()

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;
}

View File

@@ -263,49 +263,6 @@ OpenRGBDialog::OpenRGBDialog(QWidget *parent) : QMainWindow(parent), ui(new Ui::
setGeometry(set_window);
}
/*-----------------------------------------------------*\
| If autoload_profiles doesn't exist or has missing |
| profiles, write it to config |
\*-----------------------------------------------------*/
json autoload_profiles;
if(ui_settings.contains("autoload_profiles"))
{
autoload_profiles = ui_settings["autoload_profiles"];
}
else
{
new_settings_keys = true;
}
if(!autoload_profiles.contains("exit_profile"))
{
json profile;
profile["enabled"] = false;
profile["name"] = "";
autoload_profiles["exit_profile"] = profile;
new_settings_keys = true;
}
if(!autoload_profiles.contains("resume_profile"))
{
json profile;
profile["enabled"] = false;
profile["name"] = "";
autoload_profiles["resume_profile"] = profile;
new_settings_keys = true;
}
if(!autoload_profiles.contains("suspend_profile"))
{
json profile;
profile["enabled"] = false;
profile["name"] = "";
autoload_profiles["suspend_profile"] = profile;
new_settings_keys = true;
}
ui_settings["autoload_profiles"] = autoload_profiles;
/*-----------------------------------------------------*\
| Register detection progress callback with resource |
| manager |
@@ -592,7 +549,6 @@ void OpenRGBDialog::handleAboutToQuit()
delete closeEvent;
}
void OpenRGBDialog::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
@@ -631,10 +587,8 @@ void OpenRGBDialog::closeEvent(QCloseEvent *event)
{
plugin_manager->UnloadPlugins();
if(SelectConfigProfile("exit_profile"))
if(ResourceManager::get()->GetProfileManager()->LoadAutoProfileExit())
{
on_ButtonLoadProfile_clicked();
/*---------------------------------------------*\
| Pause briefly to ensure that all profiles are |
| loaded. |
@@ -667,39 +621,6 @@ void OpenRGBDialog::keyPressEvent(QKeyEvent *event)
}
}
bool OpenRGBDialog::SelectConfigProfile(const std::string name)
{
/*-----------------------------------------------------*\
| Set automatic profile (if enabled and valid) |
\*-----------------------------------------------------*/
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
if(ui_settings.contains("autoload_profiles"))
{
json autoload_profiles = ui_settings["autoload_profiles"];
if(autoload_profiles.contains(name))
{
json profile = autoload_profiles[name];
if (profile.contains("enabled") && profile["enabled"].get<bool>() && profile.contains("name"))
{
/*-----------------------------------------*\
| Set the profile name from settings and |
| check the profile combobox for a match |
\*-----------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ProfileBox->findText(QString::fromStdString(profile_name));
if(profile_index > -1)
{
ui->ProfileBox->setCurrentIndex(profile_index);
return true;
}
}
}
}
return false;
}
void OpenRGBDialog::AddPluginsPage()
{
/*-----------------------------------------------------*\
@@ -1335,18 +1256,18 @@ void OpenRGBDialog::UpdateProfileList()
ui->ProfileBox->clear();
profileMenu->clear();
for(std::size_t profile_index = 0; profile_index < profile_manager->profile_list.size(); profile_index++)
for(std::size_t profile_index = 0; profile_index < profile_manager->GetProfileList().size(); profile_index++)
{
/*---------------------------------------------*\
| Fill in profile combo box |
\*---------------------------------------------*/
ui->ProfileBox->addItem(profile_manager->profile_list[profile_index].c_str());
ui->ProfileBox->addItem(profile_manager->GetProfileList()[profile_index].c_str());
/*---------------------------------------------*\
| Fill in profile tray icon menu |
\*---------------------------------------------*/
QAction* actionProfileSelected = new QAction(profile_manager->profile_list[profile_index].c_str(), this);
actionProfileSelected->setObjectName(profile_manager->profile_list[profile_index].c_str());
QAction* actionProfileSelected = new QAction(profile_manager->GetProfileList()[profile_index].c_str(), this);
actionProfileSelected->setObjectName(profile_manager->GetProfileList()[profile_index].c_str());
connect(actionProfileSelected, SIGNAL(triggered()), this, SLOT(on_ProfileSelected()));
profileMenu->addAction(actionProfileSelected);
}
@@ -1357,20 +1278,16 @@ void OpenRGBDialog::UpdateProfileList()
void OpenRGBDialog::OnSuspend()
{
if(SelectConfigProfile("suspend_profile"))
if(ResourceManager::get()->GetProfileManager()->LoadAutoProfileSuspend())
{
plugin_manager->UnloadPlugins();
on_ButtonLoadProfile_clicked();
}
}
void OpenRGBDialog::OnResume()
{
if(SelectConfigProfile("resume_profile"))
{
on_ButtonLoadProfile_clicked();
}
plugin_manager->LoadPlugins();
ResourceManager::get()->GetProfileManager()->LoadAutoProfileResume();
}
void OpenRGBDialog::on_Exit()
@@ -1489,10 +1406,23 @@ void OpenRGBDialog::onDetectionEnded()
{
ShowLEDView();
}
/*-----------------------------------------------------*\
| Load the on open automatic profile |
\*-----------------------------------------------------*/
ResourceManager::get()->GetProfileManager()->LoadAutoProfileOpen();
}
void OpenRGBDialog::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue)
{
/*-----------------------------------------------------*\
| Send the about to load profile signal to plugins |
\*-----------------------------------------------------*/
plugin_manager->OnProfileAboutToLoad();
/*-----------------------------------------------------*\
| Apply the color to all device pages |
\*-----------------------------------------------------*/
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetCustomMode(red, green, blue);
@@ -1508,7 +1438,7 @@ void OpenRGBDialog::on_SaveSizeProfile()
/*-------------------------------------------------*\
| Save the profile |
\*-------------------------------------------------*/
profile_manager->SaveProfile("sizes", true);
profile_manager->SaveSizes();
}
}
@@ -1646,13 +1576,7 @@ void OpenRGBDialog::on_ProfileSelected()
/*-------------------------------------------------*\
| Load the profile |
\*-------------------------------------------------*/
if(profile_manager->LoadProfile(profile_name))
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
}
}
profile_manager->LoadProfile(profile_name);
ui->ProfileBox->setCurrentIndex(ui->ProfileBox->findText(QString::fromStdString(profile_name)));
}
@@ -1672,13 +1596,7 @@ void OpenRGBDialog::on_ButtonLoadProfile_clicked()
/*-------------------------------------------------*\
| Load the profile |
\*-------------------------------------------------*/
if(profile_manager->LoadProfile(profile_name))
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
}
}
profile_manager->LoadProfile(profile_name);
}
}

View File

@@ -24,7 +24,7 @@ OpenRGBProfileSaveDialog::OpenRGBProfileSaveDialog(QWidget *parent) :
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
std::vector<std::string> filenames = ResourceManager::get()->GetProfileManager()->profile_list;
std::vector<std::string> filenames = ResourceManager::get()->GetProfileManager()->GetProfileList();
if(filenames.empty())
{

View File

@@ -254,6 +254,23 @@ OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) :
ui->CheckboxSharedSMBusAccess->hide();
#endif
/*-----------------------------------------------------*\
| Load server settings |
\*-----------------------------------------------------*/
json server_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Server");
if(server_settings.contains("all_devices"))
{
bool all_devices = server_settings["all_devices"];
ui->CheckboxAllDevices->setChecked(all_devices);
}
if(server_settings.contains("legacy_workaround"))
{
bool legacy_workaround = server_settings["legacy_workaround"];
ui->CheckboxLegacyWorkaround->setChecked(legacy_workaround);
}
UpdateProfiles();
/*---------------------------------------------------------*\
@@ -315,53 +332,57 @@ void OpenRGBSettingsPage::changeEvent(QEvent *event)
void OpenRGBSettingsPage::UpdateProfiles()
{
/*---------------------------------------------------------*\
| Load AutoStart settings |
\*---------------------------------------------------------*/
/*-----------------------------------------------------*\
| Load AutoStart settings |
\*-----------------------------------------------------*/
ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager();
/*---------------------------------------------------------*\
| Load profiles into combo box |
\*---------------------------------------------------------*/
/*-----------------------------------------------------*\
| Load profiles into combo box |
\*-----------------------------------------------------*/
if(profile_manager != NULL)
{
ui->ComboBoxAutoStartProfile->blockSignals(true);
ui->ComboBoxSuspendProfile->blockSignals(true);
ui->ComboBoxResumeProfile->blockSignals(true);
ui->ComboBoxExitProfile->blockSignals(true);
ui->ComboBoxOpenProfile->blockSignals(true);
ui->ComboBoxResumeProfile->blockSignals(true);
ui->ComboBoxSuspendProfile->blockSignals(true);
ui->ComboBoxAutoStartProfile->clear();
ui->ComboBoxSuspendProfile->clear();
ui->ComboBoxResumeProfile->clear();
ui->ComboBoxExitProfile->clear();
ui->ComboBoxOpenProfile->clear();
ui->ComboBoxResumeProfile->clear();
ui->ComboBoxSuspendProfile->clear();
for(std::size_t profile_index = 0; profile_index < profile_manager->profile_list.size(); profile_index++)
for(std::size_t profile_index = 0; profile_index < profile_manager->GetProfileList().size(); profile_index++)
{
QString new_profile = QString(profile_manager->profile_list[profile_index].c_str());
QString new_profile = QString(profile_manager->GetProfileList()[profile_index].c_str());
ui->ComboBoxAutoStartProfile->addItem(new_profile);
ui->ComboBoxSuspendProfile->addItem(new_profile);
ui->ComboBoxResumeProfile->addItem(new_profile);
ui->ComboBoxExitProfile->addItem(new_profile);
ui->ComboBoxOpenProfile->addItem(new_profile);
ui->ComboBoxResumeProfile->addItem(new_profile);
ui->ComboBoxSuspendProfile->addItem(new_profile);
}
ui->ComboBoxAutoStartProfile->blockSignals(false);
ui->ComboBoxSuspendProfile->blockSignals(false);
ui->ComboBoxResumeProfile->blockSignals(false);
ui->ComboBoxExitProfile->blockSignals(false);
ui->ComboBoxOpenProfile->blockSignals(false);
ui->ComboBoxResumeProfile->blockSignals(false);
ui->ComboBoxSuspendProfile->blockSignals(false);
}
/*---------------------------------------------------------*\
| Load user interface settings |
\*---------------------------------------------------------*/
/*-----------------------------------------------------*\
| Load user interface settings |
\*-----------------------------------------------------*/
json autostart_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("AutoStart");
if(autostart_settings.contains("profile"))
{
/*-----------------------------------------------------*\
| Set the profile name from settings and check the |
| profile combobox for a match |
\*-----------------------------------------------------*/
/*-------------------------------------------------*\
| Set the profile name from settings and check the |
| profile combobox for a match |
\*-------------------------------------------------*/
std::string profile_name = autostart_settings["profile"].get<std::string>();
int profile_index = ui->ComboBoxAutoStartProfile->findText(QString::fromStdString(profile_name));
@@ -371,112 +392,117 @@ void OpenRGBSettingsPage::UpdateProfiles()
}
}
/*---------------------------------------------------------*\
| Load user interface settings |
\*---------------------------------------------------------*/
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
/*-----------------------------------------------------*\
| Load profile manager settings |
\*-----------------------------------------------------*/
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
if(ui_settings.contains("autoload_profiles"))
if(profilemanager_settings.contains("exit_profile"))
{
json autoload_profiles = ui_settings["autoload_profiles"];
json profile = profilemanager_settings["exit_profile"];
if(autoload_profiles.contains("exit_profile"))
if(profile.contains("enabled"))
{
json profile = autoload_profiles["exit_profile"];
if(profile.contains("enabled"))
{
bool is_enabled = profile["enabled"].get<bool>();
ui->CheckboxSetOnExit->setChecked(is_enabled);
ui->ComboBoxExitProfile->setEnabled(is_enabled);
}
if(profile.contains("name"))
{
/*-----------------------------------------------------*\
| Set the profile name from settings and check the |
| profile combobox for a match |
\*-----------------------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ComboBoxExitProfile->findText(QString::fromStdString(profile_name));
if(profile_index > -1)
{
ui->ComboBoxExitProfile->setCurrentIndex(profile_index);
}
}
bool is_enabled = profile["enabled"].get<bool>();
ui->CheckboxSetOnExit->setChecked(is_enabled);
ui->ComboBoxExitProfile->setEnabled(is_enabled);
}
if(autoload_profiles.contains("resume_profile"))
if(profile.contains("name"))
{
json profile = autoload_profiles["resume_profile"];
/*---------------------------------------------*\
| Set the profile name from settings and check |
| the profile combobox for a match |
\*---------------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ComboBoxExitProfile->findText(QString::fromStdString(profile_name));
if(profile.contains("enabled"))
if(profile_index > -1)
{
bool is_enabled = profile["enabled"].get<bool>();
ui->CheckboxSetOnResume->setChecked(is_enabled);
ui->ComboBoxResumeProfile->setEnabled(is_enabled);
}
if(profile.contains("name"))
{
/*-----------------------------------------------------*\
| Set the profile name from settings and check the |
| profile combobox for a match |
\*-----------------------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ComboBoxResumeProfile->findText(QString::fromStdString(profile_name));
if(profile_index > -1)
{
ui->ComboBoxResumeProfile->setCurrentIndex(profile_index);
}
}
}
if(autoload_profiles.contains("suspend_profile"))
{
json profile = autoload_profiles["suspend_profile"];
if(profile.contains("enabled"))
{
bool is_enabled = profile["enabled"].get<bool>();
ui->CheckboxSetOnSuspend->setChecked(is_enabled);
ui->ComboBoxSuspendProfile->setEnabled(is_enabled);
}
if(profile.contains("name"))
{
/*-----------------------------------------------------*\
| Set the profile name from settings and check the |
| profile combobox for a match |
\*-----------------------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ComboBoxSuspendProfile->findText(QString::fromStdString(profile_name));
if(profile_index > -1)
{
ui->ComboBoxSuspendProfile->setCurrentIndex(profile_index);
}
ui->ComboBoxExitProfile->setCurrentIndex(profile_index);
}
}
}
/*---------------------------------------------------------*\
| Load server settings |
\*---------------------------------------------------------*/
json server_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Server");
if(server_settings.contains("all_devices"))
if(profilemanager_settings.contains("open_profile"))
{
bool all_devices = server_settings["all_devices"];
ui->CheckboxAllDevices->setChecked(all_devices);
json profile = profilemanager_settings["open_profile"];
if(profile.contains("enabled"))
{
bool is_enabled = profile["enabled"].get<bool>();
ui->CheckboxSetOnOpen->setChecked(is_enabled);
ui->ComboBoxOpenProfile->setEnabled(is_enabled);
}
if(profile.contains("name"))
{
/*---------------------------------------------*\
| Set the profile name from settings and check |
| the profile combobox for a match |
\*---------------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ComboBoxOpenProfile->findText(QString::fromStdString(profile_name));
if(profile_index > -1)
{
ui->ComboBoxOpenProfile->setCurrentIndex(profile_index);
}
}
}
if(server_settings.contains("legacy_workaround"))
if(profilemanager_settings.contains("resume_profile"))
{
bool legacy_workaround = server_settings["legacy_workaround"];
ui->CheckboxLegacyWorkaround->setChecked(legacy_workaround);
json profile = profilemanager_settings["resume_profile"];
if(profile.contains("enabled"))
{
bool is_enabled = profile["enabled"].get<bool>();
ui->CheckboxSetOnResume->setChecked(is_enabled);
ui->ComboBoxResumeProfile->setEnabled(is_enabled);
}
if(profile.contains("name"))
{
/*---------------------------------------------*\
| Set the profile name from settings and check |
| the profile combobox for a match |
\*---------------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ComboBoxResumeProfile->findText(QString::fromStdString(profile_name));
if(profile_index > -1)
{
ui->ComboBoxResumeProfile->setCurrentIndex(profile_index);
}
}
}
if(profilemanager_settings.contains("suspend_profile"))
{
json profile = profilemanager_settings["suspend_profile"];
if(profile.contains("enabled"))
{
bool is_enabled = profile["enabled"].get<bool>();
ui->CheckboxSetOnSuspend->setChecked(is_enabled);
ui->ComboBoxSuspendProfile->setEnabled(is_enabled);
}
if(profile.contains("name"))
{
/*---------------------------------------------*\
| Set the profile name from settings and check |
| the profile combobox for a match |
\*---------------------------------------------*/
std::string profile_name = profile["name"].get<std::string>();
int profile_index = ui->ComboBoxSuspendProfile->findText(QString::fromStdString(profile_name));
if(profile_index > -1)
{
ui->ComboBoxSuspendProfile->setCurrentIndex(profile_index);
}
}
}
}
@@ -586,10 +612,10 @@ void OpenRGBSettingsPage::on_CheckboxRunZoneChecks_clicked()
void OpenRGBSettingsPage::on_CheckboxSetOnExit_clicked(bool checked)
{
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
ui_settings["autoload_profiles"]["exit_profile"]["enabled"] = checked;
ui_settings["autoload_profiles"]["exit_profile"]["name"] = ui->ComboBoxExitProfile->currentText().toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["exit_profile"]["enabled"] = checked;
profilemanager_settings["exit_profile"]["name"] = ui->ComboBoxExitProfile->currentText().toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
ui->ComboBoxExitProfile->setEnabled(checked);
@@ -597,18 +623,37 @@ void OpenRGBSettingsPage::on_CheckboxSetOnExit_clicked(bool checked)
void OpenRGBSettingsPage::on_ComboBoxExitProfile_currentTextChanged(const QString exit_profile_name)
{
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
ui_settings["autoload_profiles"]["exit_profile"]["name"] = exit_profile_name.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["exit_profile"]["name"] = exit_profile_name.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
}
void OpenRGBSettingsPage::on_CheckboxSetOnOpen_clicked(bool checked)
{
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["open_profile"]["enabled"] = checked;
profilemanager_settings["open_profile"]["name"] = ui->ComboBoxOpenProfile->currentText().toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
ui->ComboBoxOpenProfile->setEnabled(checked);
}
void OpenRGBSettingsPage::on_ComboBoxOpenProfile_currentTextChanged(const QString open_profile_name)
{
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["open_profile"]["name"] = open_profile_name.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
}
void OpenRGBSettingsPage::on_CheckboxSetOnResume_clicked(bool checked)
{
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
ui_settings["autoload_profiles"]["resume_profile"]["enabled"] = checked;
ui_settings["autoload_profiles"]["resume_profile"]["name"] = ui->ComboBoxResumeProfile->currentText().toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["resume_profile"]["enabled"] = checked;
profilemanager_settings["resume_profile"]["name"] = ui->ComboBoxResumeProfile->currentText().toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
ui->ComboBoxResumeProfile->setEnabled(checked);
@@ -616,18 +661,18 @@ void OpenRGBSettingsPage::on_CheckboxSetOnResume_clicked(bool checked)
void OpenRGBSettingsPage::on_ComboBoxResumeProfile_currentTextChanged(const QString resume_profile_name)
{
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
ui_settings["autoload_profiles"]["resume_profile"]["name"] = resume_profile_name.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["resume_profile"]["name"] = resume_profile_name.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
}
void OpenRGBSettingsPage::on_CheckboxSetOnSuspend_clicked(bool checked)
{
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
ui_settings["autoload_profiles"]["suspend_profile"]["enabled"] = checked;
ui_settings["autoload_profiles"]["suspend_profile"]["name"] = ui->ComboBoxSuspendProfile->currentText().toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["suspend_profile"]["enabled"] = checked;
profilemanager_settings["suspend_profile"]["name"] = ui->ComboBoxSuspendProfile->currentText().toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
ui->ComboBoxSuspendProfile->setEnabled(checked);
@@ -635,9 +680,9 @@ void OpenRGBSettingsPage::on_CheckboxSetOnSuspend_clicked(bool checked)
void OpenRGBSettingsPage::on_ComboBoxSuspendProfile_currentTextChanged(const QString suspend_profile_name)
{
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
ui_settings["autoload_profiles"]["suspend_profile"]["name"] = suspend_profile_name.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
json profilemanager_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("ProfileManager");
profilemanager_settings["suspend_profile"]["name"] = suspend_profile_name.toStdString();
ResourceManager::get()->GetSettingsManager()->SetSettings("ProfileManager", profilemanager_settings);
SaveSettings();
}

View File

@@ -85,6 +85,8 @@ private slots:
void on_CheckboxSetOnExit_clicked(bool checked);
void on_ComboBoxExitProfile_currentTextChanged(const QString exit_profile_name);
void on_CheckboxSetOnOpen_clicked(bool checked);
void on_ComboBoxOpenProfile_currentTextChanged(const QString open_profile_name);
void on_CheckboxSetOnResume_clicked(bool checked);
void on_ComboBoxResumeProfile_currentTextChanged(const QString resume_profile_name);
void on_CheckboxSetOnSuspend_clicked(bool checked);

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>475</width>
<height>500</height>
<width>500</width>
<height>475</height>
</rect>
</property>
<property name="windowTitle">
@@ -30,129 +30,29 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-328</y>
<y>-211</y>
<width>508</width>
<height>1105</height>
<height>1161</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="15" column="0">
<widget class="QCheckBox" name="CheckboxLogConsole">
<item row="27" column="0">
<widget class="QCheckBox" name="CheckboxSetOnResume">
<property name="text">
<string>Enable Log Console (restart required)</string>
<string>Set Profile on Resume</string>
</property>
</widget>
</item>
<item row="36" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
<property name="text">
<string>Load Profile</string>
<item row="40" column="1">
<widget class="QSpinBox" name="TextServerPort">
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="CheckboxDisableKeyExpansion">
<property name="text">
<string>Disable Key Expansion in Device View</string>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QCheckBox" name="CheckboxSharedSMBusAccess">
<property name="text">
<string>Shared SMBus Access (restart required)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="ComboBoxLanguage"/>
</item>
<item row="40" column="0">
<widget class="QLabel" name="AutoStartStatusLabel">
<property name="text">
<string>Start at Login Status</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="CheckboxLoadGeometry">
<property name="text">
<string>Load Window Geometry</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="HexFormatLabel">
<property name="text">
<string>Hex Format</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QCheckBox" name="CheckboxShowLEDView">
<property name="text">
<string>Show LED View by Default</string>
</property>
</widget>
</item>
<item row="24" column="0">
<widget class="QCheckBox" name="CheckboxLegacyWorkaround">
<property name="text">
<string>Legacy Workaround</string>
</property>
</widget>
</item>
<item row="38" column="1">
<widget class="QComboBox" name="ComboBoxResumeProfile"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ThemeLabel">
<property name="text">
<string>Theme (restart required)</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="ComboBoxHexFormat"/>
</item>
<item row="16" column="0">
<widget class="QLabel" name="DetectionSettingsLabel">
<property name="text">
<string>Detection Settings:</string>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QCheckBox" name="CheckboxAllDevices">
<property name="text">
<string>Serve All Devices (Including those from client connections)</string>
</property>
</widget>
</item>
<item row="32" column="1">
<widget class="QLineEdit" name="TextServerHost"/>
</item>
<item row="20" column="0">
<widget class="QCheckBox" name="CheckboxAMDSMBusReduceCPU">
<property name="text">
<string>AMD SMBus: Reduce CPU Usage (restart required)</string>
</property>
</widget>
</item>
<item row="37" column="1">
<widget class="QComboBox" name="ComboBoxSuspendProfile"/>
</item>
<item row="25" column="0">
<widget class="QLabel" name="AutoStartLabel">
<property name="text">
<string>Start at Login Settings:</string>
</property>
</widget>
</item>
<item row="32" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerHost">
<property name="text">
<string>Set Server Host</string>
<property name="value">
<number>6742</number>
</property>
</widget>
</item>
@@ -163,29 +63,13 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="ComboBoxTheme"/>
</item>
<item row="30" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
<item row="40" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerPort">
<property name="text">
<string>Start Minimized</string>
<string>Set Server Port</string>
</property>
</widget>
</item>
<item row="36" column="1">
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
</item>
<item row="26" column="0">
<widget class="QCheckBox" name="CheckboxAutoStart">
<property name="text">
<string>Start at Login</string>
</property>
</widget>
</item>
<item row="39" column="1">
<widget class="QComboBox" name="ComboBoxExitProfile"/>
</item>
<item row="17" column="0">
<widget class="QCheckBox" name="CheckboxHIDSafeMode">
<property name="text">
@@ -193,10 +77,116 @@
</property>
</widget>
</item>
<item row="34" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartClient">
<item row="3" column="1">
<widget class="QComboBox" name="ComboBoxLanguage"/>
</item>
<item row="39" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerHost">
<property name="text">
<string>Start Client</string>
<string>Set Server Host</string>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="DetectionSettingsLabel">
<property name="text">
<string>Detection Settings:</string>
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QLabel" name="ProfileSettingsLabel">
<property name="text">
<string>Profile Settings:</string>
</property>
</widget>
</item>
<item row="47" column="0">
<widget class="QLabel" name="AutoStartStatusLabel">
<property name="text">
<string>Start at Login Status</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="CheckboxRunZoneChecks">
<property name="text">
<string>Run Zone Checks on Rescan</string>
</property>
</widget>
</item>
<item row="30" column="0">
<widget class="QCheckBox" name="CheckboxAllDevices">
<property name="text">
<string>Serve All Devices (Including those from client connections)</string>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QCheckBox" name="CheckboxSetOnExit">
<property name="text">
<string>Set Profile on Exit</string>
</property>
</widget>
</item>
<item row="27" column="1">
<widget class="QComboBox" name="ComboBoxResumeProfile"/>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="CheckboxSaveGeometry">
<property name="text">
<string>Save Geometry on Close</string>
</property>
</widget>
</item>
<item row="23" column="1">
<widget class="QComboBox" name="ComboBoxExitProfile"/>
</item>
<item row="21" column="0">
<widget class="QCheckBox" name="CheckboxSharedSMBusAccess">
<property name="text">
<string>Shared SMBus Access (restart required)</string>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="DriversSettingsLabel">
<property name="text">
<string>Drivers Settings:</string>
</property>
</widget>
</item>
<item row="24" column="1">
<widget class="QComboBox" name="ComboBoxOpenProfile"/>
</item>
<item row="20" column="0">
<widget class="QCheckBox" name="CheckboxAMDSMBusReduceCPU">
<property name="text">
<string>AMD SMBus: Reduce CPU Usage (restart required)</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QCheckBox" name="CheckboxShowLEDView">
<property name="text">
<string>Show LED View by Default</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="ComboBoxTheme"/>
</item>
<item row="31" column="0">
<widget class="QCheckBox" name="CheckboxLegacyWorkaround">
<property name="text">
<string>Legacy Workaround</string>
</property>
</widget>
</item>
<item row="32" column="0">
<widget class="QLabel" name="AutoStartLabel">
<property name="text">
<string>Start at Login Settings:</string>
</property>
</widget>
</item>
@@ -207,7 +197,103 @@
</property>
</widget>
</item>
<item row="41" column="0">
<item row="29" column="0">
<widget class="QLabel" name="ServerSettingsLabel">
<property name="text">
<string>Server Settings:</string>
</property>
</widget>
</item>
<item row="26" column="1">
<widget class="QComboBox" name="ComboBoxSuspendProfile"/>
</item>
<item row="38" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartServer">
<property name="text">
<string>Start Server</string>
</property>
</widget>
</item>
<item row="26" column="0">
<widget class="QCheckBox" name="CheckboxSetOnSuspend">
<property name="text">
<string>Set Profile on Suspend</string>
</property>
</widget>
</item>
<item row="43" column="1">
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
</item>
<item row="14" column="0">
<widget class="QCheckBox" name="CheckboxLogFile">
<property name="text">
<string>Enable Log File (restart required)</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="HexFormatLabel">
<property name="text">
<string>Hex Format</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="LabelLanguage">
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="ComboBoxHexFormat"/>
</item>
<item row="42" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
<property name="text">
<string>Custom Arguments</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="CheckboxLoadGeometry">
<property name="text">
<string>Load Window Geometry</string>
</property>
</widget>
</item>
<item row="37" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
<property name="text">
<string>Start Minimized</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="CheckboxDisableKeyExpansion">
<property name="text">
<string>Disable Key Expansion in Device View</string>
</property>
</widget>
</item>
<item row="33" column="0">
<widget class="QCheckBox" name="CheckboxAutoStart">
<property name="text">
<string>Start at Login</string>
</property>
</widget>
</item>
<item row="41" column="1">
<widget class="QLineEdit" name="TextClientHost"/>
</item>
<item row="43" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item row="48" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
@@ -223,9 +309,6 @@
</property>
</spacer>
</item>
<item row="35" column="1">
<widget class="QLineEdit" name="TextCustomArgs"/>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
<property name="text">
@@ -233,48 +316,6 @@
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QLabel" name="ServerSettingsLabel">
<property name="text">
<string>Server Settings:</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="CheckboxSaveGeometry">
<property name="text">
<string>Save Geometry on Close</string>
</property>
</widget>
</item>
<item row="31" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartServer">
<property name="text">
<string>Start Server</string>
</property>
</widget>
</item>
<item row="33" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartSetServerPort">
<property name="text">
<string>Set Server Port</string>
</property>
</widget>
</item>
<item row="37" column="0">
<widget class="QCheckBox" name="CheckboxSetOnSuspend">
<property name="text">
<string>Set Profile on Suspend</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="CheckboxRunZoneChecks">
<property name="text">
<string>Run Zone Checks on Rescan</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="LogManagerSettingsLabel">
<property name="text">
@@ -282,61 +323,37 @@
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QCheckBox" name="CheckboxLogFile">
<item row="39" column="1">
<widget class="QLineEdit" name="TextServerHost"/>
</item>
<item row="15" column="0">
<widget class="QCheckBox" name="CheckboxLogConsole">
<property name="text">
<string>Enable Log File (restart required)</string>
<string>Enable Log Console (restart required)</string>
</property>
</widget>
</item>
<item row="33" column="1">
<widget class="QSpinBox" name="TextServerPort">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>6742</number>
<item row="4" column="0">
<widget class="QLabel" name="ThemeLabel">
<property name="text">
<string>Theme (restart required)</string>
</property>
</widget>
</item>
<item row="38" column="0">
<widget class="QCheckBox" name="CheckboxSetOnResume">
<item row="42" column="1">
<widget class="QLineEdit" name="TextCustomArgs"/>
</item>
<item row="24" column="0">
<widget class="QCheckBox" name="CheckboxSetOnOpen">
<property name="text">
<string>Set Profile on Resume</string>
<string>Set Profile on Open</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="LabelLanguage">
<item row="41" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartClient">
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="DriversSettingsLabel">
<property name="text">
<string>Drivers Settings:</string>
</property>
</widget>
</item>
<item row="35" column="0">
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
<property name="text">
<string>Custom Arguments</string>
</property>
</widget>
</item>
<item row="34" column="1">
<widget class="QLineEdit" name="TextClientHost"/>
</item>
<item row="39" column="0">
<widget class="QCheckBox" name="CheckboxSetOnExit">
<property name="text">
<string>Set Profile on Exit</string>
<string>Start Client</string>
</property>
</widget>
</item>

View File

@@ -196,7 +196,7 @@ void OpenRGBZonesBulkResizer::on_save_button_clicked()
/*-----------------------------------------------------*\
| Save the profile |
\*-----------------------------------------------------*/
profile_manager->SaveProfile("sizes", true);
profile_manager->SaveSizes();
}
/*---------------------------------------------------------*\