Skip to content

Commit

Permalink
[MouseJump] upgrade default "custom" style settings in config (micros…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeclayton committed Oct 23, 2024
1 parent 5d4b971 commit 5dcde18
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
63 changes: 61 additions & 2 deletions src/settings-ui/Settings.UI.Library/MouseJumpSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
using System.Text.Json.Serialization;

using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using MouseJump.Common.Helpers;
using MouseJump.Common.Models.Settings;
using Windows.UI.Xaml.Printing;

namespace Microsoft.PowerToys.Settings.UI.Library
{
Expand All @@ -26,7 +29,7 @@ public MouseJumpSettings()
{
Name = ModuleName;
Properties = new MouseJumpProperties();
Version = "1.0";
Version = "1.1";
}

public void Save(ISettingsUtils settingsUtils)
Expand All @@ -47,7 +50,63 @@ public string GetModuleName()
// This can be utilized in the future if the settings.json file is to be modified/deleted.
public bool UpgradeSettingsConfiguration()
{
return false;
/*
v1.0 - initial version
* DefaultActivationShortcut
* activation_shortcut
* thumbnail_size
* name
* version
*/
var upgraded = false;

if (this.Version == "1.0")
{
/*
v1.1 - added preview style settings
* preview_type
* background_color_1
* background_color_2
* border_thickness
* border_color
* border_3d_depth
* border_padding
* bezel_thickness
* bezel_color
* bezel_3d_depth
* screen_margin
* screen_color_1
* screen_color_2
*/
this.Version = "1.1";

// set default values for custom preview style
var previewStyle = StyleHelper.BezelledPreviewStyle;
this.Properties.PreviewType = PreviewType.Bezelled.ToString();
this.Properties.BackgroundColor1 = ConfigHelper.SerializeToConfigColorString(
ConfigHelper.ToUnnamedColor(previewStyle.CanvasStyle.BackgroundStyle.Color1));
this.Properties.BackgroundColor2 = ConfigHelper.SerializeToConfigColorString(
ConfigHelper.ToUnnamedColor(previewStyle.CanvasStyle.BackgroundStyle.Color2));
this.Properties.BorderThickness = (int)previewStyle.CanvasStyle.BorderStyle.Top;
this.Properties.BorderColor = ConfigHelper.SerializeToConfigColorString(
ConfigHelper.ToUnnamedColor(previewStyle.CanvasStyle.BorderStyle.Color));
this.Properties.Border3dDepth = (int)previewStyle.CanvasStyle.BorderStyle.Depth;
this.Properties.BorderPadding = (int)previewStyle.CanvasStyle.PaddingStyle.Top;
this.Properties.BezelThickness = (int)previewStyle.ScreenStyle.BorderStyle.Top;
this.Properties.BezelColor = ConfigHelper.SerializeToConfigColorString(
ConfigHelper.ToUnnamedColor(previewStyle.ScreenStyle.BorderStyle.Color));
this.Properties.Bezel3dDepth = (int)previewStyle.ScreenStyle.BorderStyle.Depth;
this.Properties.ScreenMargin = (int)previewStyle.ScreenStyle.MarginStyle.Top;
this.Properties.ScreenColor1 = ConfigHelper.SerializeToConfigColorString(
ConfigHelper.ToUnnamedColor(previewStyle.ScreenStyle.BackgroundStyle.Color1));
this.Properties.ScreenColor2 = ConfigHelper.SerializeToConfigColorString(
ConfigHelper.ToUnnamedColor(previewStyle.ScreenStyle.BackgroundStyle.Color2));
upgraded = true;
}

return upgraded;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ProjectReference Include="..\..\common\interop\PowerToys.Interop.vcxproj" />
<ProjectReference Include="..\..\common\ManagedCommon\ManagedCommon.csproj" />
<ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
<ProjectReference Include="..\..\modules\MouseUtils\MouseJump.Common\MouseJump.Common.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 5dcde18

Please sign in to comment.