From bde9243d72003a70c256349d70ce263a8d1dad51 Mon Sep 17 00:00:00 2001
From: Laszlo Nemeth <57342539+donlaci@users.noreply.github.com>
Date: Mon, 20 Nov 2023 22:27:43 +0100
Subject: [PATCH] [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
---
.../Controls/ShortcutControl/ShortcutControl.xaml.cs | 6 ++++++
.../ShortcutControl/ShortcutDialogContentControl.xaml | 6 ++++++
.../ShortcutControl/ShortcutDialogContentControl.xaml.cs | 8 ++++++++
src/settings-ui/Settings.UI/Strings/en-us/Resources.resw | 8 ++++++++
4 files changed, 28 insertions(+)
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutControl.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutControl.xaml.cs
index 1f52573a11..7a31408e5f 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutControl.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutControl.xaml.cs
@@ -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();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutDialogContentControl.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutDialogContentControl.xaml
index 899f08f746..e017777d37 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutDialogContentControl.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Controls/ShortcutControl/ShortcutDialogContentControl.xaml
@@ -59,6 +59,12 @@
IsTabStop="{Binding ElementName=ShortcutContentControl, Path=IsError, Mode=OneWay}"
Severity="Error" />
+
(bool)GetValue(IsWarningAltGrProperty);
+ set => SetValue(IsWarningAltGrProperty, value);
+ }
+
+ public static readonly DependencyProperty IsWarningAltGrProperty = DependencyProperty.Register("IsWarningAltGr", typeof(bool), typeof(ShortcutDialogContentControl), new PropertyMetadata(false));
}
}
diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
index edd59e13e7..6df133fbf0 100644
--- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
+++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
@@ -2535,6 +2535,14 @@ Right-click to remove the key combination, thereby deactivating the shortcut.Only shortcuts that start with **Windows key**, **Ctrl**, **Alt** or **Shift** are valid.
The ** sequences are used for text formatting of the key names. Don't remove them on translation.
+
+ Possible shortcut interference with Alt Gr
+ Alt Gr refers to the right alt key on some international keyboards
+
+
+ Shortcuts with **Ctrl** and **Alt** may remove functionality from some international keyboards, because **Ctrl** + **Alt** = **Alt Gr** in those keyboards.
+ The ** sequences are used for text formatting of the key names. Don't remove them on translation.
+
All monitors must have the same DPI scaling and will be treated as one large combined rectangle which contains all monitors