2020-04-08 00:19:00 -07:00
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System ;
2020-10-21 12:32:53 -07:00
using System.IO ;
2020-11-02 18:33:43 +01:00
using System.IO.Abstractions ;
2020-03-24 19:55:02 -07:00
using System.Text.Json ;
2024-10-17 05:14:57 -04:00
2023-03-21 10:27:29 +01:00
using ManagedCommon ;
2020-10-22 09:45:48 -07:00
using Microsoft.PowerToys.Settings.UI.Library.Interfaces ;
2020-03-24 19:55:02 -07:00
2020-10-22 09:45:48 -07:00
namespace Microsoft.PowerToys.Settings.UI.Library
2020-03-24 19:55:02 -07:00
{
2020-09-21 10:14:44 -07:00
public class SettingsUtils : ISettingsUtils
2020-03-24 19:55:02 -07:00
{
2024-11-28 17:36:32 +00:00
public const string DefaultFileName = "settings.json" ;
2020-04-20 06:03:26 -07:00
private const string DefaultModuleName = "" ;
2020-11-02 18:33:43 +01:00
private readonly IFile _file ;
private readonly ISettingsPath _settingsPath ;
2020-04-17 15:25:08 -07:00
2023-12-28 13:37:13 +03:00
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
{
MaxDepth = 0 ,
IncludeFields = true ,
} ;
2020-11-02 18:33:43 +01:00
public SettingsUtils ( )
: this ( new FileSystem ( ) )
2020-09-08 10:04:17 -07:00
{
}
2020-11-02 18:33:43 +01:00
public SettingsUtils ( IFileSystem fileSystem )
: this ( fileSystem ? . File , new SettingPath ( fileSystem ? . Directory , fileSystem ? . Path ) )
2020-04-03 19:02:38 -07:00
{
}
2020-11-02 18:33:43 +01:00
public SettingsUtils ( IFile file , ISettingsPath settingPath )
2020-04-03 19:02:38 -07:00
{
2020-11-02 18:33:43 +01:00
_file = file ? ? throw new ArgumentNullException ( nameof ( file ) ) ;
_settingsPath = settingPath ;
2020-09-21 10:14:44 -07:00
}
2020-11-02 18:33:43 +01:00
public bool SettingsExists ( string powertoy = DefaultModuleName , string fileName = DefaultFileName )
2020-09-21 10:14:44 -07:00
{
2020-11-02 18:33:43 +01:00
var settingsPath = _settingsPath . GetSettingsPath ( powertoy , fileName ) ;
return _file . Exists ( settingsPath ) ;
2020-04-03 19:02:38 -07:00
}
2020-11-02 18:33:43 +01:00
public void DeleteSettings ( string powertoy = "" )
2020-04-03 19:02:38 -07:00
{
2020-11-02 18:33:43 +01:00
_settingsPath . DeleteSettings ( powertoy ) ;
2020-04-03 19:02:38 -07:00
}
2021-01-14 14:14:29 +02:00
public T GetSettings < T > ( string powertoy = DefaultModuleName , string fileName = DefaultFileName )
where T : ISettingsConfig , new ( )
{
if ( ! SettingsExists ( powertoy , fileName ) )
{
throw new FileNotFoundException ( ) ;
}
2021-03-10 13:16:46 +01:00
// Given the file already exists, to deserialize the file and read its content.
2021-01-14 14:14:29 +02:00
T deserializedSettings = GetFile < T > ( powertoy , fileName ) ;
// If the file needs to be modified, to save the new configurations accordingly.
if ( deserializedSettings . UpgradeSettingsConfiguration ( ) )
{
SaveSettings ( deserializedSettings . ToJsonString ( ) , powertoy , fileName ) ;
}
return deserializedSettings ;
}
2020-04-03 19:02:38 -07:00
/// <summary>
/// Get a Deserialized object of the json settings string.
2020-09-23 13:20:32 -07:00
/// This function creates a file in the powertoy folder if it does not exist and returns an object with default properties.
2020-04-03 19:02:38 -07:00
/// </summary>
/// <returns>Deserialized json settings object.</returns>
2021-01-14 14:14:29 +02:00
public T GetSettingsOrDefault < T > ( string powertoy = DefaultModuleName , string fileName = DefaultFileName )
2020-09-23 13:20:32 -07:00
where T : ISettingsConfig , new ( )
{
2021-01-14 14:14:29 +02:00
try
2020-09-23 13:20:32 -07:00
{
2021-01-14 14:14:29 +02:00
return GetSettings < T > ( powertoy , fileName ) ;
}
2020-09-23 13:20:32 -07:00
2021-01-14 14:14:29 +02:00
// Catch json deserialization exceptions when the file is corrupt and has an invalid json.
// If there are any deserialization issues like in https://github.com/microsoft/PowerToys/issues/7500, log the error and create a new settings.json file.
// This is different from the case where we have trailing zeros following a valid json file, which we have handled by trimming the trailing zeros.
catch ( JsonException ex )
{
Logger . LogError ( $"Exception encountered while loading {powertoy} settings." , ex ) ;
}
catch ( FileNotFoundException )
{
Logger . LogInfo ( $"Settings file {fileName} for {powertoy} was not found." ) ;
[ColorPicker]Custom color formats (#22141)
* [ColorPicker] Development: custom color formats, first steps
* ColorPicker development of custom format handling.
* Custom color format developmnet.
Added common helper class for format string
Fixed settings loading
Added numbering if default name exists (My format (1))
* Custom color format implementation.
Extended the colorPicker settings with the format string
Updated the color to string conversion
* Custom color format in color picker, development.
Adding edit, delete buttons. Implement functionality
Re-arranging settings panel (newly created formats at the top)
Implementing details (valid parameters, more format elements, more types)
* Minor commit
* Development color picker custom formats. "Last" steps.
Replacing hard coded english strings with resources, polishing.
* Adding help to the format edit dialog.
* Undoing changes unwillingly commited in Host module
* Fixing bug unable to delete a custom format after renaming it - use the colorformat object as reference (and not the name)
Modifying the default custom formula
Removing unnecessary using directives
* Udating the default user defined color format
* Removing unnecessary using directive
* ColorPicker Implementing custom color formats: adding custom formats to the default format selection (dropdown box).
* Fix binding of name and example
* Custom color formats, implemented steps:
vorwarts compatibility loading settings.
Fixed UI as requested (removed one settings panel, added button to the first panel)
* Minor change in the UI: description modified
* ColorPicker Custom Color Formats develepoment.
Added conversion from old predefined formats to customizable formats.
Extended default settings (in case settings file is deleted/corrupted).
Minor fixes.
* Fixing color format parameters.
Implementing 3 different Saturation calculations, 2 Hue calculations and 2 Lightness calculations (depending color format)
* Color Picker: New/Edit Color format. Fixing bug when cancelling addition/edit
* ColorPicker. Updating help section, available parameters
* Fix spellchecker
* Remove the MinWidth so that scrollviewers can be drawn
* ColorPicker bugfix: Not allowing to delete the last color format.
2022-12-02 17:44:53 +01:00
}
// If the settings file does not exist or if the file is corrupt, to create a new object with default parameters and save it to a newly created settings file.
T newSettingsItem = new T ( ) ;
SaveSettings ( newSettingsItem . ToJsonString ( ) , powertoy , fileName ) ;
return newSettingsItem ;
}
/// <summary>
/// Get a Deserialized object of the json settings string.
/// This function creates a file in the powertoy folder if it does not exist and returns an object with default properties.
/// </summary>
/// <returns>Deserialized json settings object.</returns>
public T GetSettingsOrDefault < T , T2 > ( string powertoy = DefaultModuleName , string fileName = DefaultFileName , Func < object , object > settingsUpgrader = null )
where T : ISettingsConfig , new ( )
where T2 : ISettingsConfig , new ( )
{
try
{
return GetSettings < T > ( powertoy , fileName ) ;
}
// Catch json deserialization exceptions when the file is corrupt and has an invalid json.
// If there are any deserialization issues like in https://github.com/microsoft/PowerToys/issues/7500, log the error and create a new settings.json file.
// This is different from the case where we have trailing zeros following a valid json file, which we have handled by trimming the trailing zeros.
catch ( JsonException ex )
{
2022-12-05 19:52:43 +01:00
Logger . LogInfo ( $"Settings file {fileName} for {powertoy} was unrecognized. Possibly containing an older version. Trying to read again." ) ;
[ColorPicker]Custom color formats (#22141)
* [ColorPicker] Development: custom color formats, first steps
* ColorPicker development of custom format handling.
* Custom color format developmnet.
Added common helper class for format string
Fixed settings loading
Added numbering if default name exists (My format (1))
* Custom color format implementation.
Extended the colorPicker settings with the format string
Updated the color to string conversion
* Custom color format in color picker, development.
Adding edit, delete buttons. Implement functionality
Re-arranging settings panel (newly created formats at the top)
Implementing details (valid parameters, more format elements, more types)
* Minor commit
* Development color picker custom formats. "Last" steps.
Replacing hard coded english strings with resources, polishing.
* Adding help to the format edit dialog.
* Undoing changes unwillingly commited in Host module
* Fixing bug unable to delete a custom format after renaming it - use the colorformat object as reference (and not the name)
Modifying the default custom formula
Removing unnecessary using directives
* Udating the default user defined color format
* Removing unnecessary using directive
* ColorPicker Implementing custom color formats: adding custom formats to the default format selection (dropdown box).
* Fix binding of name and example
* Custom color formats, implemented steps:
vorwarts compatibility loading settings.
Fixed UI as requested (removed one settings panel, added button to the first panel)
* Minor change in the UI: description modified
* ColorPicker Custom Color Formats develepoment.
Added conversion from old predefined formats to customizable formats.
Extended default settings (in case settings file is deleted/corrupted).
Minor fixes.
* Fixing color format parameters.
Implementing 3 different Saturation calculations, 2 Hue calculations and 2 Lightness calculations (depending color format)
* Color Picker: New/Edit Color format. Fixing bug when cancelling addition/edit
* ColorPicker. Updating help section, available parameters
* Fix spellchecker
* Remove the MinWidth so that scrollviewers can be drawn
* ColorPicker bugfix: Not allowing to delete the last color format.
2022-12-02 17:44:53 +01:00
// try to deserialize to the old format, which is presented in T2
try
{
T2 oldSettings = GetSettings < T2 > ( powertoy , fileName ) ;
T newSettings = ( T ) settingsUpgrader ( oldSettings ) ;
2022-12-05 19:52:43 +01:00
Logger . LogInfo ( $"Settings file {fileName} for {powertoy} was read successfully in the old format." ) ;
[ColorPicker]Custom color formats (#22141)
* [ColorPicker] Development: custom color formats, first steps
* ColorPicker development of custom format handling.
* Custom color format developmnet.
Added common helper class for format string
Fixed settings loading
Added numbering if default name exists (My format (1))
* Custom color format implementation.
Extended the colorPicker settings with the format string
Updated the color to string conversion
* Custom color format in color picker, development.
Adding edit, delete buttons. Implement functionality
Re-arranging settings panel (newly created formats at the top)
Implementing details (valid parameters, more format elements, more types)
* Minor commit
* Development color picker custom formats. "Last" steps.
Replacing hard coded english strings with resources, polishing.
* Adding help to the format edit dialog.
* Undoing changes unwillingly commited in Host module
* Fixing bug unable to delete a custom format after renaming it - use the colorformat object as reference (and not the name)
Modifying the default custom formula
Removing unnecessary using directives
* Udating the default user defined color format
* Removing unnecessary using directive
* ColorPicker Implementing custom color formats: adding custom formats to the default format selection (dropdown box).
* Fix binding of name and example
* Custom color formats, implemented steps:
vorwarts compatibility loading settings.
Fixed UI as requested (removed one settings panel, added button to the first panel)
* Minor change in the UI: description modified
* ColorPicker Custom Color Formats develepoment.
Added conversion from old predefined formats to customizable formats.
Extended default settings (in case settings file is deleted/corrupted).
Minor fixes.
* Fixing color format parameters.
Implementing 3 different Saturation calculations, 2 Hue calculations and 2 Lightness calculations (depending color format)
* Color Picker: New/Edit Color format. Fixing bug when cancelling addition/edit
* ColorPicker. Updating help section, available parameters
* Fix spellchecker
* Remove the MinWidth so that scrollviewers can be drawn
* ColorPicker bugfix: Not allowing to delete the last color format.
2022-12-02 17:44:53 +01:00
return newSettings ;
}
catch ( Exception )
{
// do nothing, the problem wasn't that the settings was stored in the previous format, continue with the default settings
2022-12-05 19:52:43 +01:00
Logger . LogError ( $"{powertoy} settings are corrupt or the format is not supported any longer. Using default settings instead." , ex ) ;
[ColorPicker]Custom color formats (#22141)
* [ColorPicker] Development: custom color formats, first steps
* ColorPicker development of custom format handling.
* Custom color format developmnet.
Added common helper class for format string
Fixed settings loading
Added numbering if default name exists (My format (1))
* Custom color format implementation.
Extended the colorPicker settings with the format string
Updated the color to string conversion
* Custom color format in color picker, development.
Adding edit, delete buttons. Implement functionality
Re-arranging settings panel (newly created formats at the top)
Implementing details (valid parameters, more format elements, more types)
* Minor commit
* Development color picker custom formats. "Last" steps.
Replacing hard coded english strings with resources, polishing.
* Adding help to the format edit dialog.
* Undoing changes unwillingly commited in Host module
* Fixing bug unable to delete a custom format after renaming it - use the colorformat object as reference (and not the name)
Modifying the default custom formula
Removing unnecessary using directives
* Udating the default user defined color format
* Removing unnecessary using directive
* ColorPicker Implementing custom color formats: adding custom formats to the default format selection (dropdown box).
* Fix binding of name and example
* Custom color formats, implemented steps:
vorwarts compatibility loading settings.
Fixed UI as requested (removed one settings panel, added button to the first panel)
* Minor change in the UI: description modified
* ColorPicker Custom Color Formats develepoment.
Added conversion from old predefined formats to customizable formats.
Extended default settings (in case settings file is deleted/corrupted).
Minor fixes.
* Fixing color format parameters.
Implementing 3 different Saturation calculations, 2 Hue calculations and 2 Lightness calculations (depending color format)
* Color Picker: New/Edit Color format. Fixing bug when cancelling addition/edit
* ColorPicker. Updating help section, available parameters
* Fix spellchecker
* Remove the MinWidth so that scrollviewers can be drawn
* ColorPicker bugfix: Not allowing to delete the last color format.
2022-12-02 17:44:53 +01:00
}
}
catch ( FileNotFoundException )
{
Logger . LogInfo ( $"Settings file {fileName} for {powertoy} was not found." ) ;
2020-09-23 13:20:32 -07:00
}
2020-10-26 11:13:53 -07:00
// If the settings file does not exist or if the file is corrupt, to create a new object with default parameters and save it to a newly created settings file.
T newSettingsItem = new T ( ) ;
SaveSettings ( newSettingsItem . ToJsonString ( ) , powertoy , fileName ) ;
return newSettingsItem ;
2020-09-23 13:20:32 -07:00
}
// Given the powerToy folder name and filename to be accessed, this function deserializes and returns the file.
private T GetFile < T > ( string powertoyFolderName = DefaultModuleName , string fileName = DefaultFileName )
2020-03-24 19:55:02 -07:00
{
2020-09-11 16:15:18 -07:00
// Adding Trim('\0') to overcome possible NTFS file corruption.
// Look at issue https://github.com/microsoft/PowerToys/issues/6413 you'll see the file has a large sum of \0 to fill up a 4096 byte buffer for writing to disk
// This, while not totally ideal, does work around the problem by trimming the end.
// The file itself did write the content correctly but something is off with the actual end of the file, hence the 0x00 bug
2020-11-02 18:33:43 +01:00
var jsonSettingsString = _file . ReadAllText ( _settingsPath . GetSettingsPath ( powertoyFolderName , fileName ) ) . Trim ( '\0' ) ;
2023-05-15 23:32:26 +01:00
2023-12-28 13:37:13 +03:00
var options = _serializerOptions ;
2023-05-15 23:32:26 +01:00
return JsonSerializer . Deserialize < T > ( jsonSettingsString , options ) ;
2020-03-24 19:55:02 -07:00
}
2020-04-07 10:19:14 -07:00
// Save settings to a json file.
2020-09-21 10:14:44 -07:00
public void SaveSettings ( string jsonSettings , string powertoy = DefaultModuleName , string fileName = DefaultFileName )
2020-03-24 19:55:02 -07:00
{
2020-04-17 15:25:08 -07:00
try
2020-04-03 19:02:38 -07:00
{
2020-04-17 15:25:08 -07:00
if ( jsonSettings ! = null )
2020-04-03 19:02:38 -07:00
{
2020-11-02 18:33:43 +01:00
if ( ! _settingsPath . SettingsFolderExists ( powertoy ) )
2020-04-17 15:25:08 -07:00
{
2020-11-02 18:33:43 +01:00
_settingsPath . CreateSettingsFolder ( powertoy ) ;
2020-04-17 15:25:08 -07:00
}
2020-04-08 00:19:00 -07:00
2020-11-02 18:33:43 +01:00
_file . WriteAllText ( _settingsPath . GetSettingsPath ( powertoy , fileName ) , jsonSettings ) ;
2020-04-17 15:25:08 -07:00
}
}
2020-10-21 12:32:53 -07:00
catch ( Exception e )
2020-04-17 15:25:08 -07:00
{
2020-10-21 12:32:53 -07:00
Logger . LogError ( $"Exception encountered while saving {powertoy} settings." , e ) ;
#if DEBUG
if ( e is ArgumentException | | e is ArgumentNullException | | e is PathTooLongException )
{
2020-10-22 09:45:48 -07:00
throw ;
2020-10-21 12:32:53 -07:00
}
#endif
2020-04-03 19:02:38 -07:00
}
2020-03-24 19:55:02 -07:00
}
Espresso (#11303)
* Update README.md
* Espresso (#11245)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Update Product.wxs
* Update Shortcut.cpp
* Update with more logging (#11332)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Fix minor issue in the module branch (#11340)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
* Fix log location coming from the runner
* More chatty logging for console allocation
* Installer config to add the missing assets
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Update Product.wxs
* Update Program.cs
* fixing typo
* removing a unneeded removal
* [Espresso] More minor tweaks to logging (#11341)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
* Fix log location coming from the runner
* More chatty logging for console allocation
* Installer config to add the missing assets
* Remove unused handle codes
* Update log file name for the Espresso C++ code.
* Update the project configuration to fix build issue
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Update patterns.txt
* Fix binding issues (#11368)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
* Fix log location coming from the runner
* More chatty logging for console allocation
* Installer config to add the missing assets
* Remove unused handle codes
* Update log file name for the Espresso C++ code.
* Update the project configuration to fix build issue
* Fix binding issue with the time settings
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Introduce the off mode and fix binding issues (#11385)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
* Fix log location coming from the runner
* More chatty logging for console allocation
* Installer config to add the missing assets
* Remove unused handle codes
* Update log file name for the Espresso C++ code.
* Update the project configuration to fix build issue
* Fix binding issue with the time settings
* Proper Espresso behavior for binding
* Fix settings UI
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Update with missing strings. (#11386)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
* Fix log location coming from the runner
* More chatty logging for console allocation
* Installer config to add the missing assets
* Remove unused handle codes
* Update log file name for the Espresso C++ code.
* Update the project configuration to fix build issue
* Fix binding issue with the time settings
* Proper Espresso behavior for binding
* Fix settings UI
* Re-add missing strings
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Fix whitespace issue (#11387)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
* Fix log location coming from the runner
* More chatty logging for console allocation
* Installer config to add the missing assets
* Remove unused handle codes
* Update log file name for the Espresso C++ code.
* Update the project configuration to fix build issue
* Fix binding issue with the time settings
* Proper Espresso behavior for binding
* Fix settings UI
* Re-add missing strings
* Fix whitespace issue
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Fix default (#11388)
* Revert "Merge branch 'microsoft:master' into master"
This reverts commit b080908712557fce0e93a98e8d3bcb58fbd111fc, reversing
changes made to 8463c95a43a737532ae21dfa9aee1894a3a37dde.
* Fix conversion of settings in the UX
* Update terminology
* Updating logging configuration
* Set up how tray and setting configuration works
* Adding hero images
* Fix how binding works
* Update OOBE string
* Fix spelling error
* fixing dep to include espresso, adding in yml
* Update API components and fix display keep-awake bug
* Adding words that the spell check is yelling about
* tweak wsx
* Change default setting for Espresso
* Adding some extra logging
* Update Shortcut.cpp
* Fix log location coming from the runner
* More chatty logging for console allocation
* Installer config to add the missing assets
* Remove unused handle codes
* Update log file name for the Espresso C++ code.
* Update the project configuration to fix build issue
* Fix binding issue with the time settings
* Proper Espresso behavior for binding
* Fix settings UI
* Re-add missing strings
* Fix whitespace issue
* Fix the default mode of operation
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
* Update Microsoft.PowerToys.Settings.UI.csproj
* Localization improvements
* Replaced a computer with your pc
* Updated Espresso imagery
* Fixed inconsistent string
* Margin fix and updated images
* Removed unused code
Co-authored-by: Den Delimarsky <1389609+dend@users.noreply.github.com>
Co-authored-by: Niels Laute <niels9001@hotmail.com>
Co-authored-by: crutkas <crutkas@microsoft.com>
Co-authored-by: Enrico Giordani <enrico.giordani@gmail.com>
2021-05-25 10:13:04 -07:00
// Returns the file path to the settings file, that is exposed from the local ISettingsPath instance.
public string GetSettingsFilePath ( string powertoy = "" , string fileName = "settings.json" )
{
return _settingsPath . GetSettingsPath ( powertoy , fileName ) ;
}
2022-10-13 03:41:21 -04:00
/// <summary>
/// Method <c>BackupSettings</c> Mostly a wrapper for SettingsBackupAndRestoreUtils.BackupSettings
/// </summary>
2023-06-14 12:56:56 +03:00
public static ( bool Success , string Message , string Severity , bool LastBackupExists , string OptionalMessage ) BackupSettings ( )
2022-10-13 03:41:21 -04:00
{
var settingsBackupAndRestoreUtilsX = SettingsBackupAndRestoreUtils . Instance ;
var settingsUtils = new SettingsUtils ( ) ;
var appBasePath = Path . GetDirectoryName ( settingsUtils . _settingsPath . GetSettingsPath ( string . Empty , string . Empty ) ) ;
string settingsBackupAndRestoreDir = settingsBackupAndRestoreUtilsX . GetSettingsBackupAndRestoreDir ( ) ;
return settingsBackupAndRestoreUtilsX . BackupSettings ( appBasePath , settingsBackupAndRestoreDir , false ) ;
}
/// <summary>
/// Method <c>RestoreSettings</c> Mostly a wrapper for SettingsBackupAndRestoreUtils.RestoreSettings
/// </summary>
2022-12-18 14:27:14 +01:00
public static ( bool Success , string Message , string Severity ) RestoreSettings ( )
2022-10-13 03:41:21 -04:00
{
var settingsBackupAndRestoreUtilsX = SettingsBackupAndRestoreUtils . Instance ;
var settingsUtils = new SettingsUtils ( ) ;
var appBasePath = Path . GetDirectoryName ( settingsUtils . _settingsPath . GetSettingsPath ( string . Empty , string . Empty ) ) ;
string settingsBackupAndRestoreDir = settingsBackupAndRestoreUtilsX . GetSettingsBackupAndRestoreDir ( ) ;
return settingsBackupAndRestoreUtilsX . RestoreSettings ( appBasePath , settingsBackupAndRestoreDir ) ;
}
2020-03-24 19:55:02 -07:00
}
2020-05-05 14:28:44 -07:00
}