[Mouse Jump] Customisable appearance - borders, margins, colours, etc - final part (#35521)

* [MouseJump] move Mouse Jump settings into separate control (#27511)

* [MouseJump] added Mouse Jump style controls to Settings UI (#27511)

* [MouseJump] added Mouse Jump style controls to Settings UI (#27511)

* [MouseJump] removing unused MouseJumpUI code (#27511)

* [MouseJump] whitespace (#27511)

* [MouseJump] fix spellcheck (#27511)

* [MouseJump] enabled "Copy to custom style" (#27511)

* [MouseJump] fixing build (internal members -> public) (#27511)

* [MouseJump] remove unused "using"s (#27511)

* [MouseJump] use custom styles in preview image (#27511)

* [MouseJump] fixing failing test (#27511)

* [MouseJump] fixing failing test (#27511)

* [MouseJump] fixing failing test (#27511)

* [MouseJump] fixing failing test (#27511)

* [MouseJump] delinting to trigger a build (#27511)

* [MouseJump] updated settings preview image ("browser" header) (#27511)

* [MouseJump] upgrade default "custom" style settings in config (#27511)

* [MouseJump] fixed a glitch in settings upgrade (#27511)

* [MouseJump] fixed spell checker (#27511)

* [MouseJump] typo in resource strings (image -> images) (#27511)

* Remove unused include
This commit is contained in:
Michael Clayton
2024-11-26 15:37:59 +00:00
committed by GitHub
parent 7c9876582c
commit 53212188b7
39 changed files with 1710 additions and 992 deletions

View File

@@ -14,7 +14,7 @@ using Microsoft.PowerToys.Settings.Utilities;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class MouseUtilsViewModel : Observable
public partial class MouseUtilsViewModel : Observable
{
private ISettingsUtils SettingsUtils { get; set; }
@@ -24,8 +24,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private MouseHighlighterSettings MouseHighlighterSettingsConfig { get; set; }
private MouseJumpSettings MouseJumpSettingsConfig { get; set; }
private MousePointerCrosshairsSettings MousePointerCrosshairsSettingsConfig { get; set; }
public MouseUtilsViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<FindMyMouseSettings> findMyMouseSettingsRepository, ISettingsRepository<MouseHighlighterSettings> mouseHighlighterSettingsRepository, ISettingsRepository<MouseJumpSettings> mouseJumpSettingsRepository, ISettingsRepository<MousePointerCrosshairsSettings> mousePointerCrosshairsSettingsRepository, Func<string, int> ipcMSGCallBackFunc)
@@ -80,10 +78,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_highlightFadeDurationMs = MouseHighlighterSettingsConfig.Properties.HighlightFadeDurationMs.Value;
_highlighterAutoActivate = MouseHighlighterSettingsConfig.Properties.AutoActivate.Value;
ArgumentNullException.ThrowIfNull(mouseJumpSettingsRepository);
MouseJumpSettingsConfig = mouseJumpSettingsRepository.SettingsConfig;
MouseJumpSettingsConfig.Properties.ThumbnailSize.PropertyChanged += MouseJumpThumbnailSizePropertyChanged;
this.InitializeMouseJumpSettings(mouseJumpSettingsRepository);
ArgumentNullException.ThrowIfNull(mousePointerCrosshairsSettingsRepository);
@@ -138,17 +133,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_isMouseHighlighterEnabled = GeneralSettingsConfig.Enabled.MouseHighlighter;
}
_jumpEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredMouseJumpEnabledValue();
if (_jumpEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _jumpEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled)
{
// Get the enabled state from GPO.
_jumpEnabledStateIsGPOConfigured = true;
_isMouseJumpEnabled = _jumpEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled;
}
else
{
_isMouseJumpEnabled = GeneralSettingsConfig.Enabled.MouseJump;
}
this.InitializeMouseJumpEnabledValues();
_mousePointerCrosshairsEnabledGpoRuleConfiguration = GPOWrapper.GetConfiguredMousePointerCrosshairsEnabledValue();
if (_mousePointerCrosshairsEnabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _mousePointerCrosshairsEnabledGpoRuleConfiguration == GpoRuleConfigured.Enabled)
@@ -657,87 +642,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SettingsUtils.SaveSettings(MouseHighlighterSettingsConfig.ToJsonString(), MouseHighlighterSettings.ModuleName);
}
public bool IsMouseJumpEnabled
{
get => _isMouseJumpEnabled;
set
{
if (_jumpEnabledStateIsGPOConfigured)
{
// If it's GPO configured, shouldn't be able to change this state.
return;
}
if (_isMouseJumpEnabled != value)
{
_isMouseJumpEnabled = value;
GeneralSettingsConfig.Enabled.MouseJump = value;
OnPropertyChanged(nameof(_isMouseJumpEnabled));
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
SendConfigMSG(outgoing.ToString());
NotifyMouseJumpPropertyChanged();
}
}
}
public bool IsJumpEnabledGpoConfigured
{
get => _jumpEnabledStateIsGPOConfigured;
}
public HotkeySettings MouseJumpActivationShortcut
{
get
{
return MouseJumpSettingsConfig.Properties.ActivationShortcut;
}
set
{
if (MouseJumpSettingsConfig.Properties.ActivationShortcut != value)
{
MouseJumpSettingsConfig.Properties.ActivationShortcut = value ?? MouseJumpSettingsConfig.Properties.DefaultActivationShortcut;
NotifyMouseJumpPropertyChanged();
}
}
}
public MouseJumpThumbnailSize MouseJumpThumbnailSize
{
get
{
return MouseJumpSettingsConfig.Properties.ThumbnailSize;
}
set
{
if ((MouseJumpSettingsConfig.Properties.ThumbnailSize.Width != value?.Width)
&& (MouseJumpSettingsConfig.Properties.ThumbnailSize.Height != value?.Height))
{
MouseJumpSettingsConfig.Properties.ThumbnailSize = value;
NotifyMouseJumpPropertyChanged();
}
}
}
public void MouseJumpThumbnailSizePropertyChanged(object sender, PropertyChangedEventArgs e)
{
NotifyMouseJumpPropertyChanged(nameof(MouseJumpThumbnailSize));
}
public void NotifyMouseJumpPropertyChanged([CallerMemberName] string propertyName = null)
{
OnPropertyChanged(propertyName);
SndMouseJumpSettings outsettings = new SndMouseJumpSettings(MouseJumpSettingsConfig);
SndModuleSettings<SndMouseJumpSettings> ipcMessage = new SndModuleSettings<SndMouseJumpSettings>(outsettings);
SendConfigMSG(ipcMessage.ToJsonString());
SettingsUtils.SaveSettings(MouseJumpSettingsConfig.ToJsonString(), MouseJumpSettings.ModuleName);
}
public bool IsMousePointerCrosshairsEnabled
{
get => _isMousePointerCrosshairsEnabled;
@@ -1017,10 +921,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private int _highlightFadeDurationMs;
private bool _highlighterAutoActivate;
private GpoRuleConfigured _jumpEnabledGpoRuleConfiguration;
private bool _jumpEnabledStateIsGPOConfigured;
private bool _isMouseJumpEnabled;
private GpoRuleConfigured _mousePointerCrosshairsEnabledGpoRuleConfiguration;
private bool _mousePointerCrosshairsEnabledStateIsGPOConfigured;
private bool _isMousePointerCrosshairsEnabled;