diff --git a/src/modules/imageresizer/dll/ImageResizerConstants.h b/src/modules/imageresizer/dll/ImageResizerConstants.h index 849b8a6d6a..23ef8f7ae6 100644 --- a/src/modules/imageresizer/dll/ImageResizerConstants.h +++ b/src/modules/imageresizer/dll/ImageResizerConstants.h @@ -7,5 +7,6 @@ namespace ImageResizerConstants inline const std::wstring ModuleKey = L"Image Resizer"; // Name of the ImageResizer save folder. - inline const std::wstring ModuleSaveFolderKey = L"ImageResizer"; + inline const std::wstring ModuleOldSaveFolderKey = L"ImageResizer"; + inline const std::wstring ModuleSaveFolderKey = L"Image Resizer"; } diff --git a/src/modules/imageresizer/dll/ImageResizerExt.base.rc b/src/modules/imageresizer/dll/ImageResizerExt.base.rc index 09109a980a..b80444e0eb 100644 --- a/src/modules/imageresizer/dll/ImageResizerExt.base.rc +++ b/src/modules/imageresizer/dll/ImageResizerExt.base.rc @@ -40,7 +40,7 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", COMPANY_NAME - VALUE "FileDescription", "ImageResizer PowerToy" + VALUE "FileDescription", "Image Resizer PowerToy" VALUE "FileVersion", FILE_VERSION_STRING VALUE "InternalName", "ImageResizerExt.dll" VALUE "LegalCopyright", COPYRIGHT_NOTE diff --git a/src/modules/imageresizer/dll/Settings.cpp b/src/modules/imageresizer/dll/Settings.cpp index 6d57db94f1..f59eb5c86b 100644 --- a/src/modules/imageresizer/dll/Settings.cpp +++ b/src/modules/imageresizer/dll/Settings.cpp @@ -45,8 +45,16 @@ namespace CSettings::CSettings() { - std::wstring result = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleSaveFolderKey); - jsonFilePath = result + std::wstring(c_imageResizerDataFilePath); + std::wstring oldSavePath = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleOldSaveFolderKey); + std::wstring savePath = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleSaveFolderKey); + std::error_code ec; + if (std::filesystem::exists(oldSavePath, ec)) + { + std::filesystem::copy(oldSavePath, savePath, std::filesystem::copy_options::recursive, ec); + std::filesystem::remove_all(oldSavePath, ec); + } + + jsonFilePath = savePath + std::wstring(c_imageResizerDataFilePath); Load(); } diff --git a/src/modules/imageresizer/tests/Properties/SettingsTests.cs b/src/modules/imageresizer/tests/Properties/SettingsTests.cs index 52f7cac03a..0952ecc106 100644 --- a/src/modules/imageresizer/tests/Properties/SettingsTests.cs +++ b/src/modules/imageresizer/tests/Properties/SettingsTests.cs @@ -353,7 +353,7 @@ namespace ImageResizer.Properties { // Generated Settings file in 0.72 var defaultInput = - "{\r\n \"properties\": {\r\n \"imageresizer_selectedSizeIndex\": {\r\n \"value\": 1\r\n },\r\n \"imageresizer_shrinkOnly\": {\r\n \"value\": true\r\n },\r\n \"imageresizer_replace\": {\r\n \"value\": true\r\n },\r\n \"imageresizer_ignoreOrientation\": {\r\n \"value\": false\r\n },\r\n \"imageresizer_jpegQualityLevel\": {\r\n \"value\": 91\r\n },\r\n \"imageresizer_pngInterlaceOption\": {\r\n \"value\": 1\r\n },\r\n \"imageresizer_tiffCompressOption\": {\r\n \"value\": 1\r\n },\r\n \"imageresizer_fileName\": {\r\n \"value\": \"%1 %1 (%2)\"\r\n },\r\n \"imageresizer_sizes\": {\r\n \"value\": [\r\n {\r\n \"Id\": 0,\r\n \"ExtraBoxOpacity\": 100,\r\n \"EnableEtraBoxes\": true,\r\n \"name\": \"Small-NotDefault\",\r\n \"fit\": 1,\r\n \"width\": 854,\r\n \"height\": 480,\r\n \"unit\": 3\r\n },\r\n {\r\n \"Id\": 3,\r\n \"ExtraBoxOpacity\": 100,\r\n \"EnableEtraBoxes\": true,\r\n \"name\": \"Phone\",\r\n \"fit\": 1,\r\n \"width\": 320,\r\n \"height\": 568,\r\n \"unit\": 3\r\n }\r\n ]\r\n },\r\n \"imageresizer_keepDateModified\": {\r\n \"value\": false\r\n },\r\n \"imageresizer_fallbackEncoder\": {\r\n \"value\": \"19e4a5aa-5662-4fc5-a0c0-1758028e1057\"\r\n },\r\n \"imageresizer_customSize\": {\r\n \"value\": {\r\n \"Id\": 4,\r\n \"ExtraBoxOpacity\": 100,\r\n \"EnableEtraBoxes\": true,\r\n \"name\": \"custom\",\r\n \"fit\": 1,\r\n \"width\": 1024,\r\n \"height\": 640,\r\n \"unit\": 3\r\n }\r\n }\r\n },\r\n \"name\": \"ImageResizer\",\r\n \"version\": \"1\"\r\n}"; + "{\r\n \"properties\": {\r\n \"imageresizer_selectedSizeIndex\": {\r\n \"value\": 1\r\n },\r\n \"imageresizer_shrinkOnly\": {\r\n \"value\": true\r\n },\r\n \"imageresizer_replace\": {\r\n \"value\": true\r\n },\r\n \"imageresizer_ignoreOrientation\": {\r\n \"value\": false\r\n },\r\n \"imageresizer_jpegQualityLevel\": {\r\n \"value\": 91\r\n },\r\n \"imageresizer_pngInterlaceOption\": {\r\n \"value\": 1\r\n },\r\n \"imageresizer_tiffCompressOption\": {\r\n \"value\": 1\r\n },\r\n \"imageresizer_fileName\": {\r\n \"value\": \"%1 %1 (%2)\"\r\n },\r\n \"imageresizer_sizes\": {\r\n \"value\": [\r\n {\r\n \"Id\": 0,\r\n \"ExtraBoxOpacity\": 100,\r\n \"EnableEtraBoxes\": true,\r\n \"name\": \"Small-NotDefault\",\r\n \"fit\": 1,\r\n \"width\": 854,\r\n \"height\": 480,\r\n \"unit\": 3\r\n },\r\n {\r\n \"Id\": 3,\r\n \"ExtraBoxOpacity\": 100,\r\n \"EnableEtraBoxes\": true,\r\n \"name\": \"Phone\",\r\n \"fit\": 1,\r\n \"width\": 320,\r\n \"height\": 568,\r\n \"unit\": 3\r\n }\r\n ]\r\n },\r\n \"imageresizer_keepDateModified\": {\r\n \"value\": false\r\n },\r\n \"imageresizer_fallbackEncoder\": {\r\n \"value\": \"19e4a5aa-5662-4fc5-a0c0-1758028e1057\"\r\n },\r\n \"imageresizer_customSize\": {\r\n \"value\": {\r\n \"Id\": 4,\r\n \"ExtraBoxOpacity\": 100,\r\n \"EnableEtraBoxes\": true,\r\n \"name\": \"custom\",\r\n \"fit\": 1,\r\n \"width\": 1024,\r\n \"height\": 640,\r\n \"unit\": 3\r\n }\r\n }\r\n },\r\n \"name\": \"Image Resizer\",\r\n \"version\": \"1\"\r\n}"; // Execute readFile/writefile twice and see if serialized string is still correct var resultWrapper = JsonSerializer.Deserialize(defaultInput); @@ -362,7 +362,7 @@ namespace ImageResizer.Properties var serializedInput2 = JsonSerializer.Serialize(resultWrapper2, new JsonSerializerOptions() { WriteIndented = true }); Assert.AreEqual(serializedInput, serializedInput2); - Assert.AreEqual("ImageResizer", resultWrapper2.Name); + Assert.AreEqual("Image Resizer", resultWrapper2.Name); Assert.AreEqual("1", resultWrapper2.Version); Assert.IsNotNull(resultWrapper2.Properties); Assert.IsTrue(resultWrapper2.Properties.ShrinkOnly); diff --git a/src/modules/imageresizer/ui/Properties/Settings.cs b/src/modules/imageresizer/ui/Properties/Settings.cs index 2e36233864..0b6a27e3df 100644 --- a/src/modules/imageresizer/ui/Properties/Settings.cs +++ b/src/modules/imageresizer/ui/Properties/Settings.cs @@ -24,7 +24,7 @@ namespace ImageResizer.Properties // Used to synchronize access to the settings.json file private static Mutex _jsonMutex = new Mutex(); - private static string _settingsPath = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "ImageResizer", "settings.json"); + private static string _settingsPath = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "Image Resizer", "settings.json"); private string _fileNameFormat; private bool _shrinkOnly; private int _selectedSizeIndex; @@ -422,6 +422,14 @@ namespace ImageResizer.Properties public void Reload() { + string oldSettingsDir = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "ImageResizer"); + string settingsDir = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "Image Resizer"); + + if (_fileSystem.Directory.Exists(oldSettingsDir) && !_fileSystem.Directory.Exists(settingsDir)) + { + _fileSystem.Directory.Move(oldSettingsDir, settingsDir); + } + _jsonMutex.WaitOne(); if (!_fileSystem.File.Exists(SettingsPath)) { diff --git a/src/modules/imageresizer/ui/Properties/SettingsWrapper.cs b/src/modules/imageresizer/ui/Properties/SettingsWrapper.cs index 6666562c94..0c40ddf8ef 100644 --- a/src/modules/imageresizer/ui/Properties/SettingsWrapper.cs +++ b/src/modules/imageresizer/ui/Properties/SettingsWrapper.cs @@ -9,7 +9,7 @@ namespace ImageResizer.Properties public class SettingsWrapper { [JsonPropertyName("name")] - public string Name { get; set; } = "ImageResizer"; + public string Name { get; set; } = "Image Resizer"; [JsonPropertyName("version")] public string Version { get; set; } = "1"; diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ImageResizerSettings.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ImageResizerSettings.cs index c90afdf128..1a4c9d857a 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ImageResizerSettings.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ImageResizerSettings.cs @@ -11,7 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library { public class ImageResizerSettings : BasePTModuleSettings, ISettingsConfig { - public const string ModuleName = "ImageResizer"; + public const string ModuleName = "Image Resizer"; [JsonPropertyName("properties")] public ImageResizerProperties Properties { get; set; } diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/ImageResizer/settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/Image Resizer/settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/ImageResizer/settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/Image Resizer/settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/ImageResizer/sizes.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/Image Resizer/sizes.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/ImageResizer/sizes.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/V0.21.1/Microsoft/PowerToys/Image Resizer/sizes.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/ImageResizer/settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/Image Resizer/settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/ImageResizer/settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/Image Resizer/settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/ImageResizer/sizes.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/Image Resizer/sizes.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/ImageResizer/sizes.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/Image Resizer/sizes.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/ImageResizer/settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/Image Resizer/settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/ImageResizer/settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/Image Resizer/settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/ImageResizer/sizes.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/Image Resizer/sizes.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/ImageResizer/sizes.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/Image Resizer/sizes.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/ImageResizer/settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/Image Resizer/settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/ImageResizer/settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/Image Resizer/settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/ImageResizer/sizes.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/Image Resizer/sizes.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/ImageResizer/sizes.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.20.1/Microsoft/PowerToys/Image Resizer/sizes.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/ImageResizer/image-resizer-settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/Image Resizer/image-resizer-settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/ImageResizer/settings.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/Image Resizer/settings.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/ImageResizer/settings.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/Image Resizer/settings.json diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/ImageResizer/sizes.json b/src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/Image Resizer/sizes.json similarity index 100% rename from src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/ImageResizer/sizes.json rename to src/settings-ui/Microsoft.PowerToys.Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.22.0/Microsoft/PowerToys/Image Resizer/sizes.json