mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Adjusting settings to leverage base class (#5127)
* renaming / deleting file * adding in base class Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
This commit is contained in:
@@ -3,16 +3,19 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public abstract class BasePTModuleSettings
|
||||
{
|
||||
// Gets or sets name of the powertoy module.
|
||||
public string name { get; set; }
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
// Gets or sets the powertoys version.
|
||||
public string version { get; set; }
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
// converts the current to a json string.
|
||||
public virtual string ToJsonString()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
@@ -10,18 +11,14 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public const string ModuleName = "ColorPicker";
|
||||
|
||||
public ColorPickerProperties properties { get; set; }
|
||||
[JsonPropertyName("properties")]
|
||||
public ColorPickerProperties Properties { get; set; }
|
||||
|
||||
public ColorPickerSettings()
|
||||
{
|
||||
properties = new ColorPickerProperties();
|
||||
version = "1";
|
||||
name = ModuleName;
|
||||
}
|
||||
|
||||
public override string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
Properties = new ColorPickerProperties();
|
||||
Version = "1";
|
||||
Name = ModuleName;
|
||||
}
|
||||
|
||||
public virtual void Save()
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
this.FancyzonesShowOnAllMonitors = new BoolProperty();
|
||||
this.FancyzonesZoneHighlightColor = new StringProperty(ConfigDefaults.DefaultFancyZonesZoneHighlightColor);
|
||||
this.FancyzonesHighlightOpacity = new IntProperty(50);
|
||||
this.FancyzonesEditorHotkey = new KeyBoardKeysProperty(
|
||||
this.FancyzonesEditorHotkey = new KeyboardKeysProperty(
|
||||
new HotkeySettings()
|
||||
{
|
||||
Win = true,
|
||||
@@ -82,7 +82,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
public IntProperty FancyzonesHighlightOpacity { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_editor_hotkey")]
|
||||
public KeyBoardKeysProperty FancyzonesEditorHotkey { get; set; }
|
||||
public KeyboardKeysProperty FancyzonesEditorHotkey { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_excluded_apps")]
|
||||
public StringProperty FancyzonesExcludedApps { get; set; }
|
||||
|
||||
@@ -2,35 +2,20 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class FancyZonesSettings
|
||||
public class FancyZonesSettings : BasePTModuleSettings
|
||||
{
|
||||
public FancyZonesSettings()
|
||||
{
|
||||
this.Version = string.Empty;
|
||||
this.Name = string.Empty;
|
||||
this.Properties = new FZConfigProperties();
|
||||
Version = string.Empty;
|
||||
Name = string.Empty;
|
||||
Properties = new FZConfigProperties();
|
||||
}
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("properties")]
|
||||
public FZConfigProperties Properties { get; set; }
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public interface IPowerToySettings
|
||||
{
|
||||
string name { get; set; }
|
||||
|
||||
string version { get; set; }
|
||||
|
||||
string ToJsonString();
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
ImageresizerTiffCompressOption = new IntProperty();
|
||||
ImageresizerFileName = new StringProperty("%1 (%2)");
|
||||
|
||||
ImageresizerSizes = new ImageresizerSizes(new ObservableCollection<ImageSize>()
|
||||
ImageresizerSizes = new ImageResizerSizes(new ObservableCollection<ImageSize>()
|
||||
{
|
||||
new ImageSize(0, "Small", ResizeFit.Fit, 854, 480, ResizeUnit.Pixel),
|
||||
new ImageSize(1, "Medium", ResizeFit.Fit, 1366, 768, ResizeUnit.Pixel),
|
||||
@@ -32,7 +32,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
|
||||
ImageresizerKeepDateModified = new BoolProperty();
|
||||
ImageresizerFallbackEncoder = new StringProperty(new System.Guid("19e4a5aa-5662-4fc5-a0c0-1758028e1057").ToString());
|
||||
ImageresizerCustomSize = new ImageresizerCustomSizeProperty(new ImageSize(4, "custom", ResizeFit.Fit, 1024, 640, ResizeUnit.Pixel));
|
||||
ImageresizerCustomSize = new ImageResizerCustomSizeProperty(new ImageSize(4, "custom", ResizeFit.Fit, 1024, 640, ResizeUnit.Pixel));
|
||||
}
|
||||
|
||||
[JsonPropertyName("imageresizer_selectedSizeIndex")]
|
||||
@@ -60,7 +60,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
public StringProperty ImageresizerFileName { get; set; }
|
||||
|
||||
[JsonPropertyName("imageresizer_sizes")]
|
||||
public ImageresizerSizes ImageresizerSizes { get; set; }
|
||||
public ImageResizerSizes ImageresizerSizes { get; set; }
|
||||
|
||||
[JsonPropertyName("imageresizer_keepDateModified")]
|
||||
public BoolProperty ImageresizerKeepDateModified { get; set; }
|
||||
@@ -69,7 +69,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
public StringProperty ImageresizerFallbackEncoder { get; set; }
|
||||
|
||||
[JsonPropertyName("imageresizer_customSize")]
|
||||
public ImageresizerCustomSizeProperty ImageresizerCustomSize { get; set; }
|
||||
public ImageResizerCustomSizeProperty ImageresizerCustomSize { get; set; }
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
|
||||
@@ -2,33 +2,26 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class ImageResizerSettings
|
||||
public class ImageResizerSettings : BasePTModuleSettings
|
||||
{
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
public const string ModuleName = "Image Resizer";
|
||||
|
||||
[JsonPropertyName("properties")]
|
||||
public ImageResizerProperties Properties { get; set; }
|
||||
|
||||
public ImageResizerSettings()
|
||||
{
|
||||
this.Version = "1";
|
||||
this.Name = "Image Resizer";
|
||||
this.Properties = new ImageResizerProperties();
|
||||
Version = "1";
|
||||
Name = ModuleName;
|
||||
Properties = new ImageResizerProperties();
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
public override string ToJsonString()
|
||||
{
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// 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.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class ImagerResizerKeepDateModified
|
||||
{
|
||||
[JsonPropertyName("value")]
|
||||
public bool Value { get; set; }
|
||||
|
||||
public ImagerResizerKeepDateModified()
|
||||
{
|
||||
Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
// 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.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
|
||||
public class ImageresizerCustomSizeProperty
|
||||
public class ImageResizerCustomSizeProperty
|
||||
{
|
||||
[JsonPropertyName("value")]
|
||||
public ImageSize Value { get; set; }
|
||||
|
||||
public ImageresizerCustomSizeProperty()
|
||||
public ImageResizerCustomSizeProperty()
|
||||
{
|
||||
this.Value = new ImageSize();
|
||||
Value = new ImageSize();
|
||||
}
|
||||
|
||||
public ImageresizerCustomSizeProperty(ImageSize value)
|
||||
public ImageResizerCustomSizeProperty(ImageSize value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
// 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.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
|
||||
public class ImageresizerFallbackEncoder
|
||||
public class ImageResizerFallbackEncoder
|
||||
{
|
||||
[JsonPropertyName("value")]
|
||||
public string Value { get; set; }
|
||||
|
||||
public ImageresizerFallbackEncoder()
|
||||
public ImageResizerFallbackEncoder()
|
||||
{
|
||||
this.Value = string.Empty;
|
||||
Value = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
|
||||
public class ImageresizerKeepDateModified
|
||||
{
|
||||
[JsonPropertyName("value")]
|
||||
public bool Value { get; set; }
|
||||
|
||||
public ImageresizerKeepDateModified()
|
||||
{
|
||||
this.Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,23 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
|
||||
public class ImageresizerSizes
|
||||
public class ImageResizerSizes
|
||||
{
|
||||
[JsonPropertyName("value")]
|
||||
public ObservableCollection<ImageSize> Value { get; set; }
|
||||
|
||||
public ImageresizerSizes()
|
||||
public ImageResizerSizes()
|
||||
{
|
||||
this.Value = new ObservableCollection<ImageSize>();
|
||||
Value = new ObservableCollection<ImageSize>();
|
||||
}
|
||||
|
||||
public ImageresizerSizes(ObservableCollection<ImageSize> value)
|
||||
public ImageResizerSizes(ObservableCollection<ImageSize> value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
@@ -2,23 +2,20 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class KeyBoardKeysProperty
|
||||
public class KeyboardKeysProperty
|
||||
{
|
||||
public KeyBoardKeysProperty()
|
||||
public KeyboardKeysProperty()
|
||||
{
|
||||
this.Value = new HotkeySettings();
|
||||
Value = new HotkeySettings();
|
||||
}
|
||||
|
||||
public KeyBoardKeysProperty(HotkeySettings hkSettings)
|
||||
public KeyboardKeysProperty(HotkeySettings hkSettings)
|
||||
{
|
||||
this.Value = hkSettings;
|
||||
Value = hkSettings;
|
||||
}
|
||||
|
||||
[JsonPropertyName("value")]
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
@@ -18,21 +14,15 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
public KeyboardManagerSettings()
|
||||
{
|
||||
Properties = new KeyboardManagerProperties();
|
||||
version = "1";
|
||||
name = "_unset_";
|
||||
Version = "1";
|
||||
Name = "_unset_";
|
||||
}
|
||||
|
||||
public KeyboardManagerSettings(string ptName)
|
||||
{
|
||||
Properties = new KeyboardManagerProperties();
|
||||
version = "1";
|
||||
name = ptName;
|
||||
}
|
||||
|
||||
// converts the current to a json string.
|
||||
public override string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
Version = "1";
|
||||
Name = ptName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,22 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class PowerLauncherSettings : BasePTModuleSettings
|
||||
{
|
||||
public const string POWERTOYNAME = "PowerToys Run";
|
||||
public const string ModuleName = "PowerToys Run";
|
||||
|
||||
public PowerLauncherProperties properties { get; set; }
|
||||
[JsonPropertyName("properties")]
|
||||
public PowerLauncherProperties Properties { get; set; }
|
||||
|
||||
public PowerLauncherSettings()
|
||||
{
|
||||
properties = new PowerLauncherProperties();
|
||||
version = "1";
|
||||
name = POWERTOYNAME;
|
||||
Properties = new PowerLauncherProperties();
|
||||
Version = "1";
|
||||
Name = ModuleName;
|
||||
}
|
||||
|
||||
public virtual void Save()
|
||||
@@ -27,7 +29,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
WriteIndented = true,
|
||||
};
|
||||
|
||||
SettingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), POWERTOYNAME);
|
||||
SettingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), ModuleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
public PowerPreviewSettings()
|
||||
{
|
||||
properties = new PowerPreviewProperties();
|
||||
version = "1";
|
||||
name = "File Explorer";
|
||||
Version = "1";
|
||||
Name = "File Explorer";
|
||||
}
|
||||
|
||||
public PowerPreviewSettings(string ptName)
|
||||
{
|
||||
properties = new PowerPreviewProperties();
|
||||
version = "1";
|
||||
name = ptName;
|
||||
Version = "1";
|
||||
Name = ptName;
|
||||
}
|
||||
|
||||
public override string ToJsonString()
|
||||
|
||||
@@ -2,45 +2,42 @@
|
||||
// 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.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class PowerRenameSettings : BasePTModuleSettings
|
||||
{
|
||||
public PowerRenameProperties properties { get; set; }
|
||||
public const string ModuleName = "PowerRename";
|
||||
|
||||
[JsonPropertyName("properties")]
|
||||
public PowerRenameProperties Properties { get; set; }
|
||||
|
||||
public PowerRenameSettings()
|
||||
{
|
||||
properties = new PowerRenameProperties();
|
||||
version = "1";
|
||||
name = "PowerRename";
|
||||
Properties = new PowerRenameProperties();
|
||||
Version = "1";
|
||||
Name = ModuleName;
|
||||
}
|
||||
|
||||
public PowerRenameSettings(PowerRenameLocalProperties localProperties)
|
||||
{
|
||||
properties = new PowerRenameProperties();
|
||||
properties.PersistState.Value = localProperties.PersistState;
|
||||
properties.MRUEnabled.Value = localProperties.MRUEnabled;
|
||||
properties.MaxMRUSize.Value = localProperties.MaxMRUSize;
|
||||
properties.ShowIcon.Value = localProperties.ShowIcon;
|
||||
properties.ExtendedContextMenuOnly.Value = localProperties.ExtendedContextMenuOnly;
|
||||
Properties = new PowerRenameProperties();
|
||||
Properties.PersistState.Value = localProperties.PersistState;
|
||||
Properties.MRUEnabled.Value = localProperties.MRUEnabled;
|
||||
Properties.MaxMRUSize.Value = localProperties.MaxMRUSize;
|
||||
Properties.ShowIcon.Value = localProperties.ShowIcon;
|
||||
Properties.ExtendedContextMenuOnly.Value = localProperties.ExtendedContextMenuOnly;
|
||||
|
||||
version = "1";
|
||||
name = "PowerRename";
|
||||
Version = "1";
|
||||
Name = ModuleName;
|
||||
}
|
||||
|
||||
public PowerRenameSettings(string ptName)
|
||||
{
|
||||
properties = new PowerRenameProperties();
|
||||
version = "1";
|
||||
name = ptName;
|
||||
}
|
||||
|
||||
public override string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
Properties = new PowerRenameProperties();
|
||||
Version = "1";
|
||||
Name = ptName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,35 +2,22 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class ShortcutGuideSettings
|
||||
public class ShortcutGuideSettings : BasePTModuleSettings
|
||||
{
|
||||
public ShortcutGuideSettings()
|
||||
{
|
||||
Name = "Shortcut Guide";
|
||||
Properties = new ShortcutGuideProperties();
|
||||
Version = "1.0";
|
||||
}
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
public const string ModuleName = "Shortcut Guide";
|
||||
|
||||
[JsonPropertyName("properties")]
|
||||
public ShortcutGuideProperties Properties { get; set; }
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
public string ToJsonString()
|
||||
public ShortcutGuideSettings()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
Name = ModuleName;
|
||||
Properties = new ShortcutGuideProperties();
|
||||
Version = "1.0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,14 +62,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return _colorPickerSettings.properties.ChangeCursor;
|
||||
return _colorPickerSettings.Properties.ChangeCursor;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_colorPickerSettings.properties.ChangeCursor != value)
|
||||
if (_colorPickerSettings.Properties.ChangeCursor != value)
|
||||
{
|
||||
_colorPickerSettings.properties.ChangeCursor = value;
|
||||
_colorPickerSettings.Properties.ChangeCursor = value;
|
||||
OnPropertyChanged(nameof(ChangeCursor));
|
||||
NotifySettingsChanged();
|
||||
}
|
||||
@@ -80,14 +80,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return _colorPickerSettings.properties.ActivationShortcut;
|
||||
return _colorPickerSettings.Properties.ActivationShortcut;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_colorPickerSettings.properties.ActivationShortcut != value)
|
||||
if (_colorPickerSettings.Properties.ActivationShortcut != value)
|
||||
{
|
||||
_colorPickerSettings.properties.ActivationShortcut = value;
|
||||
_colorPickerSettings.Properties.ActivationShortcut = value;
|
||||
OnPropertyChanged(nameof(ActivationShortcut));
|
||||
NotifySettingsChanged();
|
||||
}
|
||||
@@ -98,14 +98,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)_colorPickerSettings.properties.CopiedColorRepresentation;
|
||||
return (int)_colorPickerSettings.Properties.CopiedColorRepresentation;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_colorPickerSettings.properties.CopiedColorRepresentation != (ColorRepresentationType)value)
|
||||
if (_colorPickerSettings.Properties.CopiedColorRepresentation != (ColorRepresentationType)value)
|
||||
{
|
||||
_colorPickerSettings.properties.CopiedColorRepresentation = (ColorRepresentationType)value;
|
||||
_colorPickerSettings.Properties.CopiedColorRepresentation = (ColorRepresentationType)value;
|
||||
OnPropertyChanged(nameof(CopiedColorRepresentationIndex));
|
||||
NotifySettingsChanged();
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
SettingsUtils.SaveSettings(Settings.Properties.ImageresizerSizes.ToJsonString(), ModuleName, "sizes.json");
|
||||
_advancedSizes = value;
|
||||
Settings.Properties.ImageresizerSizes = new ImageresizerSizes(value);
|
||||
Settings.Properties.ImageresizerSizes = new ImageResizerSizes(value);
|
||||
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
OnPropertyChanged("Sizes");
|
||||
}
|
||||
|
||||
@@ -25,18 +25,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
// Propagate changes to Power Launcher through IPC
|
||||
ShellPage.DefaultSndMSGCallback(
|
||||
string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.POWERTOYNAME, JsonSerializer.Serialize(settings)));
|
||||
string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.ModuleName, JsonSerializer.Serialize(settings)));
|
||||
};
|
||||
if (SettingsUtils.SettingsExists(PowerLauncherSettings.POWERTOYNAME))
|
||||
if (SettingsUtils.SettingsExists(PowerLauncherSettings.ModuleName))
|
||||
{
|
||||
settings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.POWERTOYNAME);
|
||||
settings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings = new PowerLauncherSettings();
|
||||
settings.properties.open_powerlauncher.Alt = true;
|
||||
settings.properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space;
|
||||
settings.properties.maximum_number_of_results = 4;
|
||||
settings.Properties.open_powerlauncher.Alt = true;
|
||||
settings.Properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space;
|
||||
settings.Properties.maximum_number_of_results = 4;
|
||||
callback(settings);
|
||||
}
|
||||
|
||||
@@ -87,14 +87,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.search_result_preference;
|
||||
return settings.Properties.search_result_preference;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.search_result_preference != value)
|
||||
if (settings.Properties.search_result_preference != value)
|
||||
{
|
||||
settings.properties.search_result_preference = value;
|
||||
settings.Properties.search_result_preference = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -104,14 +104,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.search_type_preference;
|
||||
return settings.Properties.search_type_preference;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.search_type_preference != value)
|
||||
if (settings.Properties.search_type_preference != value)
|
||||
{
|
||||
settings.properties.search_type_preference = value;
|
||||
settings.Properties.search_type_preference = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -121,14 +121,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.maximum_number_of_results;
|
||||
return settings.Properties.maximum_number_of_results;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.maximum_number_of_results != value)
|
||||
if (settings.Properties.maximum_number_of_results != value)
|
||||
{
|
||||
settings.properties.maximum_number_of_results = value;
|
||||
settings.Properties.maximum_number_of_results = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -138,14 +138,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.open_powerlauncher;
|
||||
return settings.Properties.open_powerlauncher;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.open_powerlauncher != value)
|
||||
if (settings.Properties.open_powerlauncher != value)
|
||||
{
|
||||
settings.properties.open_powerlauncher = value;
|
||||
settings.Properties.open_powerlauncher = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -155,14 +155,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.open_file_location;
|
||||
return settings.Properties.open_file_location;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.open_file_location != value)
|
||||
if (settings.Properties.open_file_location != value)
|
||||
{
|
||||
settings.properties.open_file_location = value;
|
||||
settings.Properties.open_file_location = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -172,14 +172,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.copy_path_location;
|
||||
return settings.Properties.copy_path_location;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.copy_path_location != value)
|
||||
if (settings.Properties.copy_path_location != value)
|
||||
{
|
||||
settings.properties.copy_path_location = value;
|
||||
settings.Properties.copy_path_location = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -189,14 +189,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.override_win_r_key;
|
||||
return settings.Properties.override_win_r_key;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.override_win_r_key != value)
|
||||
if (settings.Properties.override_win_r_key != value)
|
||||
{
|
||||
settings.properties.override_win_r_key = value;
|
||||
settings.Properties.override_win_r_key = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -206,14 +206,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.override_win_s_key;
|
||||
return settings.Properties.override_win_s_key;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.override_win_s_key != value)
|
||||
if (settings.Properties.override_win_s_key != value)
|
||||
{
|
||||
settings.properties.override_win_s_key = value;
|
||||
settings.Properties.override_win_s_key = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -223,14 +223,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.ignore_hotkeys_in_fullscreen;
|
||||
return settings.Properties.ignore_hotkeys_in_fullscreen;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.ignore_hotkeys_in_fullscreen != value)
|
||||
if (settings.Properties.ignore_hotkeys_in_fullscreen != value)
|
||||
{
|
||||
settings.properties.ignore_hotkeys_in_fullscreen = value;
|
||||
settings.Properties.ignore_hotkeys_in_fullscreen = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -240,14 +240,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.clear_input_on_launch;
|
||||
return settings.Properties.clear_input_on_launch;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.clear_input_on_launch != value)
|
||||
if (settings.Properties.clear_input_on_launch != value)
|
||||
{
|
||||
settings.properties.clear_input_on_launch = value;
|
||||
settings.Properties.clear_input_on_launch = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
@@ -257,14 +257,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.properties.disable_drive_detection_warning;
|
||||
return settings.Properties.disable_drive_detection_warning;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (settings.properties.disable_drive_detection_warning != value)
|
||||
if (settings.Properties.disable_drive_detection_warning != value)
|
||||
{
|
||||
settings.properties.disable_drive_detection_warning = value;
|
||||
settings.Properties.disable_drive_detection_warning = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
SettingsUtils.SaveSettings(localSettings.ToJsonString(), ModuleName, "power-rename-settings.json");
|
||||
}
|
||||
|
||||
_powerRenameEnabledOnContextMenu = Settings.properties.ShowIcon.Value;
|
||||
_powerRenameEnabledOnContextExtendedMenu = Settings.properties.ExtendedContextMenuOnly.Value;
|
||||
_powerRenameRestoreFlagsOnLaunch = Settings.properties.PersistState.Value;
|
||||
_powerRenameMaxDispListNumValue = Settings.properties.MaxMRUSize.Value;
|
||||
_autoComplete = Settings.properties.MRUEnabled.Value;
|
||||
_powerRenameEnabledOnContextMenu = Settings.Properties.ShowIcon.Value;
|
||||
_powerRenameEnabledOnContextExtendedMenu = Settings.Properties.ExtendedContextMenuOnly.Value;
|
||||
_powerRenameRestoreFlagsOnLaunch = Settings.Properties.PersistState.Value;
|
||||
_powerRenameMaxDispListNumValue = Settings.Properties.MaxMRUSize.Value;
|
||||
_autoComplete = Settings.Properties.MRUEnabled.Value;
|
||||
|
||||
GeneralSettings generalSettings;
|
||||
try
|
||||
@@ -94,7 +94,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (value != _autoComplete)
|
||||
{
|
||||
_autoComplete = value;
|
||||
Settings.properties.MRUEnabled.Value = value;
|
||||
Settings.Properties.MRUEnabled.Value = value;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged("GlobalAndMruEnabled");
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (value != _powerRenameEnabledOnContextMenu)
|
||||
{
|
||||
_powerRenameEnabledOnContextMenu = value;
|
||||
Settings.properties.ShowIcon.Value = value;
|
||||
Settings.Properties.ShowIcon.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (value != _powerRenameEnabledOnContextExtendedMenu)
|
||||
{
|
||||
_powerRenameEnabledOnContextExtendedMenu = value;
|
||||
Settings.properties.ExtendedContextMenuOnly.Value = value;
|
||||
Settings.Properties.ExtendedContextMenuOnly.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (value != _powerRenameRestoreFlagsOnLaunch)
|
||||
{
|
||||
_powerRenameRestoreFlagsOnLaunch = value;
|
||||
Settings.properties.PersistState.Value = value;
|
||||
Settings.Properties.PersistState.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (value != _powerRenameMaxDispListNumValue)
|
||||
{
|
||||
_powerRenameMaxDispListNumValue = value;
|
||||
Settings.properties.MaxMRUSize.Value = value;
|
||||
Settings.Properties.MaxMRUSize.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Microsoft.PowerToys.Settings.UnitTest
|
||||
{
|
||||
public BasePTSettingsTest()
|
||||
{
|
||||
this.name = string.Empty;
|
||||
this.version = string.Empty;
|
||||
Name = string.Empty;
|
||||
Version = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace ViewModelTests
|
||||
var colorPickerSettings = new ColorPickerSettings();
|
||||
|
||||
SettingsUtils.SaveSettings(generalSettings.ToJsonString());
|
||||
SettingsUtils.SaveSettings(colorPickerSettings.ToJsonString(), colorPickerSettings.name, ModuleName + ".json");
|
||||
SettingsUtils.SaveSettings(colorPickerSettings.ToJsonString(), colorPickerSettings.Name, ModuleName + ".json");
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace ViewModelTests
|
||||
viewModel.SearchTypePreference = "SearchOptionsAreNotValidated";
|
||||
|
||||
Assert.AreEqual(sendCallbackMock.TimesSent, 2);
|
||||
Assert.IsTrue(mockSettings.properties.search_result_preference == "SearchOptionsAreNotValidated");
|
||||
Assert.IsTrue(mockSettings.properties.search_type_preference == "SearchOptionsAreNotValidated");
|
||||
Assert.IsTrue(mockSettings.Properties.search_result_preference == "SearchOptionsAreNotValidated");
|
||||
Assert.IsTrue(mockSettings.Properties.search_type_preference == "SearchOptionsAreNotValidated");
|
||||
}
|
||||
|
||||
public void AssertHotkeySettings(HotkeySettings setting, bool win, bool ctrl, bool alt, bool shift, int code)
|
||||
@@ -85,7 +85,7 @@ namespace ViewModelTests
|
||||
Assert.AreEqual(4, sendCallbackMock.TimesSent);
|
||||
|
||||
AssertHotkeySettings(
|
||||
mockSettings.properties.open_powerlauncher,
|
||||
mockSettings.Properties.open_powerlauncher,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
@@ -93,7 +93,7 @@ namespace ViewModelTests
|
||||
(int)Windows.System.VirtualKey.S
|
||||
);
|
||||
AssertHotkeySettings(
|
||||
mockSettings.properties.open_file_location,
|
||||
mockSettings.Properties.open_file_location,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@@ -101,7 +101,7 @@ namespace ViewModelTests
|
||||
(int)Windows.System.VirtualKey.A
|
||||
);
|
||||
AssertHotkeySettings(
|
||||
mockSettings.properties.open_console,
|
||||
mockSettings.Properties.open_console,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
@@ -109,7 +109,7 @@ namespace ViewModelTests
|
||||
(int)Windows.System.VirtualKey.D
|
||||
);
|
||||
AssertHotkeySettings(
|
||||
mockSettings.properties.copy_path_location,
|
||||
mockSettings.Properties.copy_path_location,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
@@ -127,8 +127,8 @@ namespace ViewModelTests
|
||||
|
||||
Assert.AreEqual(1, sendCallbackMock.TimesSent);
|
||||
|
||||
Assert.IsTrue(mockSettings.properties.override_win_r_key);
|
||||
Assert.IsFalse(mockSettings.properties.override_win_s_key);
|
||||
Assert.IsTrue(mockSettings.Properties.override_win_r_key);
|
||||
Assert.IsFalse(mockSettings.Properties.override_win_s_key);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -139,7 +139,7 @@ namespace ViewModelTests
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, sendCallbackMock.TimesSent);
|
||||
Assert.IsTrue(mockSettings.properties.disable_drive_detection_warning);
|
||||
Assert.IsTrue(mockSettings.Properties.disable_drive_detection_warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ViewModelTests
|
||||
PowerPreviewSettings powerpreview = new PowerPreviewSettings();
|
||||
|
||||
SettingsUtils.SaveSettings(generalSettings.ToJsonString());
|
||||
SettingsUtils.SaveSettings(powerpreview.ToJsonString(), powerpreview.name);
|
||||
SettingsUtils.SaveSettings(powerpreview.ToJsonString(), powerpreview.Name);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ViewModelTests
|
||||
PowerRenameSettings powerRename = new PowerRenameSettings();
|
||||
|
||||
SettingsUtils.SaveSettings(generalSettings.ToJsonString());
|
||||
SettingsUtils.SaveSettings(powerRename.ToJsonString(), powerRename.name, "power-rename-settings.json");
|
||||
SettingsUtils.SaveSettings(powerRename.ToJsonString(), powerRename.Name, "power-rename-settings.json");
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
@@ -73,7 +73,7 @@ namespace ViewModelTests
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.properties.MRUEnabled.Value);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.MRUEnabled.Value);
|
||||
};
|
||||
|
||||
// act
|
||||
@@ -139,7 +139,7 @@ namespace ViewModelTests
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.properties.ShowIcon.Value);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.ShowIcon.Value);
|
||||
};
|
||||
|
||||
// act
|
||||
@@ -156,7 +156,7 @@ namespace ViewModelTests
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.properties.ShowIcon.Value);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.ShowIcon.Value);
|
||||
};
|
||||
|
||||
// act
|
||||
@@ -173,7 +173,7 @@ namespace ViewModelTests
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.properties.PersistState.Value);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.PersistState.Value);
|
||||
};
|
||||
|
||||
// act
|
||||
@@ -190,7 +190,7 @@ namespace ViewModelTests
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.AreEqual(20, snd.Powertoys.PowerRename.properties.MaxMRUSize.Value);
|
||||
Assert.AreEqual(20, snd.Powertoys.PowerRename.Properties.MaxMRUSize.Value);
|
||||
};
|
||||
|
||||
// act
|
||||
|
||||
Reference in New Issue
Block a user