Browse Source

Fixing profile loading #1135

merge-requests/373/merge
jath03 11 months ago
committed by Adam Honse
parent
commit
84861ef989
  1. 34
      ProfileManager.cpp
  2. 21
      ProfileManager.h
  3. 4
      ResourceManager.cpp
  4. 2
      cli.cpp
  5. 2
      qt/OpenRGBDialog2.cpp

34
ProfileManager.cpp

@ -20,7 +20,7 @@ ProfileManager::~ProfileManager()
}
bool ProfileManager::SaveProfile(std::string profile_name)
bool ProfileManager::SaveProfile(std::string profile_name, bool sizes)
{
/*---------------------------------------------------------*\
| Get the list of controllers from the resource manager |
@ -35,7 +35,19 @@ bool ProfileManager::SaveProfile(std::string profile_name)
/*---------------------------------------------------------*\
| Extension .orp - OpenRgb Profile |
\*---------------------------------------------------------*/
std::string filename = profile_name + ".orp";
std::string filename = profile_name;
/*---------------------------------------------------------*\
| Determine file extension |
\*---------------------------------------------------------*/
if(sizes)
{
filename += ".ors";
}
else
{
filename += ".orp";
}
/*---------------------------------------------------------*\
| Open an output file in binary mode |
@ -100,7 +112,8 @@ bool ProfileManager::LoadSizeFromProfile(std::string profile_name)
std::vector<RGBController*> ProfileManager::LoadProfileToList
(
std::string profile_name
std::string profile_name,
bool sizes
)
{
std::vector<RGBController*> temp_controllers;
@ -108,8 +121,21 @@ std::vector<RGBController*> ProfileManager::LoadProfileToList
unsigned int controller_offset = 0;
bool ret_val = false;
std::string filename = configuration_directory + profile_name;
/*---------------------------------------------------------*\
| Determine file extension |
\*---------------------------------------------------------*/
if(sizes)
{
filename += ".ors";
}
else
{
filename += ".orp";
}
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
@ -292,7 +318,7 @@ bool ProfileManager::LoadProfileWithOptions
std::vector<bool> temp_controller_used;
bool ret_val = false;
std::string filename = configuration_directory + profile_name;
std::string filename = configuration_directory + profile_name + ".orp";
/*---------------------------------------------------------*\
| Get the list of controllers from the resource manager |

21
ProfileManager.h

@ -5,7 +5,11 @@
class ProfileManagerInterface
{
public:
virtual bool SaveProfile(std::string profile_name) = 0;
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;
@ -22,7 +26,11 @@ public:
bool load_settings
) = 0;
virtual std::vector<RGBController*> LoadProfileToList (std::string profile_name) = 0;
virtual std::vector<RGBController*> LoadProfileToList
(
std::string profile_name,
bool sizes = false
) = 0;
virtual void SetConfigurationDirectory(std::string directory) = 0;
protected:
@ -35,7 +43,11 @@ public:
ProfileManager(std::string config_dir);
~ProfileManager();
bool SaveProfile(std::string profile_name);
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);
@ -54,7 +66,8 @@ public:
std::vector<RGBController*> LoadProfileToList
(
std::string profile_name
std::string profile_name,
bool sizes = false
);
void SetConfigurationDirectory(std::string directory);

4
ResourceManager.cpp

@ -52,7 +52,7 @@ ResourceManager::ResourceManager()
| Load sizes list from file |
\*-------------------------------------------------------------------------*/
profile_manager = new ProfileManager(GetConfigurationDirectory());
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes.ors");
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes", true);
/*-------------------------------------------------------------------------*\
| Load settings from file |
@ -313,7 +313,7 @@ void ResourceManager::SetConfigurationDirectory(std::string directory)
profile_manager->SetConfigurationDirectory(directory);
rgb_controllers_sizes.clear();
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes.ors");
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes", true);
}
void ResourceManager::Cleanup()

2
cli.cpp

@ -623,7 +623,7 @@ bool OptionSize(int *current_device, int *current_zone, std::string argument, Op
/*---------------------------------------------------------*\
| Save the profile |
\*---------------------------------------------------------*/
ResourceManager::get()->GetProfileManager()->SaveProfile("sizes.ors");
ResourceManager::get()->GetProfileManager()->SaveProfile("sizes", true);
return true;
}

2
qt/OpenRGBDialog2.cpp

@ -902,7 +902,7 @@ void OpenRGBDialog2::on_SaveSizeProfile()
/*---------------------------------------------------------*\
| Save the profile |
\*---------------------------------------------------------*/
profile_manager->SaveProfile("sizes.ors");
profile_manager->SaveProfile("sizes", true);
}
}

Loading…
Cancel
Save