[Settings]Adding AltGr warning info box to Shortcut edit dialog (#29761)

* [Settings] Adding warning info box to Shortcut edit dialog

* Fixing case opening dialog with shortcut which needs warning

* Add comment

* spell checker
This commit is contained in:
Laszlo Nemeth
2023-11-20 22:27:43 +01:00
committed by GitHub
parent 106f90dc01
commit bde9243d72
4 changed files with 28 additions and 0 deletions

View File

@@ -332,6 +332,8 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
EnableKeys();
}
}
c.IsWarningAltGr = internalSettings.Ctrl && internalSettings.Alt && !internalSettings.Win && (internalSettings.Code > 0);
}
private void EnableKeys()
@@ -408,6 +410,10 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
c.Keys = null;
c.Keys = HotkeySettings.GetKeysList();
// 92 means the Win key. The logic is: warning should be visible if the shortcut contains Alt AND contains Ctrl AND NOT contains Win.
// Additional key must be present, as this is a valid, previously used shortcut shown at dialog open. Check for presence of non-modifier-key is not necessary therefore
c.IsWarningAltGr = c.Keys.Contains("Ctrl") && c.Keys.Contains("Alt") && !c.Keys.Contains(92);
shortcutDialog.XamlRoot = this.XamlRoot;
shortcutDialog.RequestedTheme = this.ActualTheme;
await shortcutDialog.ShowAsync();

View File

@@ -59,6 +59,12 @@
IsTabStop="{Binding ElementName=ShortcutContentControl, Path=IsError, Mode=OneWay}"
Severity="Error" />
<InfoBar
x:Uid="WarningShortcutAltGr"
IsClosable="False"
IsOpen="{Binding ElementName=ShortcutContentControl, Path=IsWarningAltGr, Mode=OneWay}"
IsTabStop="{Binding ElementName=ShortcutContentControl, Path=IsWarningAltGr, Mode=OneWay}"
Severity="Warning" />
</Grid>
<toolkitcontrols:MarkdownTextBlock
x:Uid="InvalidShortcutWarningLabel"

View File

@@ -30,5 +30,13 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
}
public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register("IsError", typeof(bool), typeof(ShortcutDialogContentControl), new PropertyMetadata(false));
public bool IsWarningAltGr
{
get => (bool)GetValue(IsWarningAltGrProperty);
set => SetValue(IsWarningAltGrProperty, value);
}
public static readonly DependencyProperty IsWarningAltGrProperty = DependencyProperty.Register("IsWarningAltGr", typeof(bool), typeof(ShortcutDialogContentControl), new PropertyMetadata(false));
}
}