diff --git a/ProfileManager.cpp b/ProfileManager.cpp index 50e52212..e8a6c822 100644 --- a/ProfileManager.cpp +++ b/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 ProfileManager::LoadProfileToList ( - std::string profile_name + std::string profile_name, + bool sizes ) { std::vector temp_controllers; @@ -108,8 +121,21 @@ std::vector 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 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 | diff --git a/ProfileManager.h b/ProfileManager.h index a7d5e80b..e72b7f1b 100644 --- a/ProfileManager.h +++ b/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 LoadProfileToList (std::string profile_name) = 0; + virtual std::vector 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 LoadProfileToList ( - std::string profile_name + std::string profile_name, + bool sizes = false ); void SetConfigurationDirectory(std::string directory); diff --git a/ResourceManager.cpp b/ResourceManager.cpp index 8efa2c23..84c37bf7 100644 --- a/ResourceManager.cpp +++ b/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() diff --git a/cli.cpp b/cli.cpp index 7ef140f5..0dbc04f2 100644 --- a/cli.cpp +++ b/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; } diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index e9124d23..de7f9914 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -902,7 +902,7 @@ void OpenRGBDialog2::on_SaveSizeProfile() /*---------------------------------------------------------*\ | Save the profile | \*---------------------------------------------------------*/ - profile_manager->SaveProfile("sizes.ors"); + profile_manager->SaveProfile("sizes", true); } }