[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 коммит произвёл GitHub
Родитель 106f90dc01
Коммит bde9243d72
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -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();

Просмотреть файл

@ -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"

Просмотреть файл

@ -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));
}
}

Просмотреть файл

@ -2535,6 +2535,14 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
<value>Only shortcuts that start with **Windows key**, **Ctrl**, **Alt** or **Shift** are valid.</value>
<comment>The ** sequences are used for text formatting of the key names. Don't remove them on translation.</comment>
</data>
<data name="WarningShortcutAltGr.Title" xml:space="preserve">
<value>Possible shortcut interference with Alt Gr</value>
<comment>Alt Gr refers to the right alt key on some international keyboards</comment>
</data>
<data name="WarningShortcutAltGr.ToolTipService.ToolTip" xml:space="preserve">
<value>Shortcuts with **Ctrl** and **Alt** may remove functionality from some international keyboards, because **Ctrl** + **Alt** = **Alt Gr** in those keyboards.</value>
<comment>The ** sequences are used for text formatting of the key names. Don't remove them on translation.</comment>
</data>
<data name="FancyZones_SpanZonesAcrossMonitors.Description" xml:space="preserve">
<value>All monitors must have the same DPI scaling and will be treated as one large combined rectangle which contains all monitors</value>
</data>