diff --git a/src/settings-ui/Settings.UI.Library/MouseJumpProperties.cs b/src/settings-ui/Settings.UI.Library/MouseJumpProperties.cs
index 0c26e8612420..3712d5b1ea56 100644
--- a/src/settings-ui/Settings.UI.Library/MouseJumpProperties.cs
+++ b/src/settings-ui/Settings.UI.Library/MouseJumpProperties.cs
@@ -14,10 +14,18 @@ public class MouseJumpProperties
public HotkeySettings DefaultActivationShortcut => new HotkeySettings(true, false, false, true, 0x44);
[JsonPropertyName("activation_shortcut")]
- public HotkeySettings ActivationShortcut { get; set; }
+ public HotkeySettings ActivationShortcut
+ {
+ get;
+ set;
+ }
[JsonPropertyName("thumbnail_size")]
- public MouseJumpThumbnailSize ThumbnailSize { get; set; }
+ public MouseJumpThumbnailSize ThumbnailSize
+ {
+ get;
+ set;
+ }
public MouseJumpProperties()
{
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml
new file mode 100644
index 000000000000..8830f7ba0bf5
--- /dev/null
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml.cs
new file mode 100644
index 000000000000..7e6890d829ab
--- /dev/null
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml.cs
@@ -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 Microsoft.PowerToys.Settings.UI.ViewModels;
+using Microsoft.UI.Xaml.Controls;
+
+namespace Microsoft.PowerToys.Settings.UI.Panels
+{
+ public sealed partial class MouseJumpPanel : UserControl
+ {
+ internal MouseUtilsViewModel ViewModel { get; set; }
+
+ public MouseJumpPanel()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml
index 779c10d4423a..faf79f1092c0 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml
@@ -6,6 +6,7 @@
xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:panels="using:Microsoft.PowerToys.Settings.UI.Panels"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -245,101 +246,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
settingsRepository, ISettingsRepository findMyMouseSettingsRepository, ISettingsRepository mouseHighlighterSettingsRepository, ISettingsRepository mouseJumpSettingsRepository, ISettingsRepository mousePointerCrosshairsSettingsRepository, Func ipcMSGCallBackFunc)
@@ -80,10 +78,7 @@ public MouseUtilsViewModel(ISettingsUtils settingsUtils, ISettingsRepository _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 ipcMessage = new SndModuleSettings(outsettings);
- SendConfigMSG(ipcMessage.ToJsonString());
- SettingsUtils.SaveSettings(MouseJumpSettingsConfig.ToJsonString(), MouseJumpSettings.ModuleName);
- }
-
public bool IsMousePointerCrosshairsEnabled
{
get => _isMousePointerCrosshairsEnabled;
@@ -1017,10 +921,6 @@ public void RefreshEnabledState()
private int _highlightFadeDurationMs;
private bool _highlighterAutoActivate;
- private GpoRuleConfigured _jumpEnabledGpoRuleConfiguration;
- private bool _jumpEnabledStateIsGPOConfigured;
- private bool _isMouseJumpEnabled;
-
private GpoRuleConfigured _mousePointerCrosshairsEnabledGpoRuleConfiguration;
private bool _mousePointerCrosshairsEnabledStateIsGPOConfigured;
private bool _isMousePointerCrosshairsEnabled;
diff --git a/src/settings-ui/Settings.UI/ViewModels/MouseUtilsViewModel_MouseJump.cs b/src/settings-ui/Settings.UI/ViewModels/MouseUtilsViewModel_MouseJump.cs
new file mode 100644
index 000000000000..971b91e8521e
--- /dev/null
+++ b/src/settings-ui/Settings.UI/ViewModels/MouseUtilsViewModel_MouseJump.cs
@@ -0,0 +1,126 @@
+// 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.ComponentModel;
+using System.Runtime.CompilerServices;
+using global::PowerToys.GPOWrapper;
+using Microsoft.PowerToys.Settings.UI.Library;
+using Microsoft.PowerToys.Settings.UI.Library.Helpers;
+using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
+
+namespace Microsoft.PowerToys.Settings.UI.ViewModels
+{
+ public partial class MouseUtilsViewModel : Observable
+ {
+ private GpoRuleConfigured _jumpEnabledGpoRuleConfiguration;
+ private bool _jumpEnabledStateIsGPOConfigured;
+ private bool _isMouseJumpEnabled;
+
+ internal MouseJumpSettings MouseJumpSettingsConfig { get; set; }
+
+ private void InitializeMouseJumpSettings(ISettingsRepository mouseJumpSettingsRepository)
+ {
+ ArgumentNullException.ThrowIfNull(mouseJumpSettingsRepository);
+ this.MouseJumpSettingsConfig = mouseJumpSettingsRepository.SettingsConfig;
+ this.MouseJumpSettingsConfig.Properties.ThumbnailSize.PropertyChanged += this.MouseJumpThumbnailSizePropertyChanged;
+ }
+
+ private void InitializeMouseJumpEnabledValues()
+ {
+ _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;
+ }
+ }
+
+ 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 ipcMessage = new SndModuleSettings(outsettings);
+ SendConfigMSG(ipcMessage.ToJsonString());
+ SettingsUtils.SaveSettings(MouseJumpSettingsConfig.ToJsonString(), MouseJumpSettings.ModuleName);
+ }
+ }
+}