Skip to content

Commit

Permalink
[MouseJump] fixed a glitch in settings upgrade (microsoft#27511)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeclayton committed Oct 23, 2024
1 parent 5dcde18 commit 8dce052
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions src/settings-ui/Settings.UI.Library/MouseJumpSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,38 @@ public bool UpgradeSettingsConfiguration()
*/
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));
// note - there's an issue where ITwoWayPipeMessageIPCManagedMethods.Send overwrites
// the settings file version as "1.0" regardless of the actual version. as a result,
// the UpgradeSettingsConfiguration can get triggered even if the config has already
// been upgraded, so we need to do an additional check to make sure values haven't
// already been upgraded before we overwrite them with default values.
if (string.IsNullOrEmpty(this.Properties.PreviewType))
{
// 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));
}

// we still need to flag the settings as "upgraded" so that the new version gets written
// back to the config file, even if we didn't actually change and setting values
upgraded = true;
}

Expand Down

1 comment on commit 8dce052

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (1)

ITwo

Previously acknowledged words that are now absent applayout appsfolder buildtask cswinrt directshow DOPUS GBarm netcore nugets QDir SYSTEMSETTINGS SYSTEMWOW telem TOTALCMD USEPOSITION USESIZE winappdriver xplorer 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:mikeclayton/PowerToys.git repository
on the dev/mikeclayton/mousejump-styles-part-3 branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/mikeclayton/PowerToys/actions/runs/11484503432/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (1933) from .github/actions/spell-check/expect.txt and unrecognized words (1)

Dictionary Entries Covers Uniquely
cspell:r/src/r.txt 543 1 1
cspell:cpp/src/people.txt 23 1
cspell:cpp/src/ecosystem.txt 51 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

      with:
        extra_dictionaries:
          cspell:r/src/r.txt
          cspell:cpp/src/people.txt
          cspell:cpp/src/ecosystem.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

check_extra_dictionaries: ''
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.