mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[Settings] Shortcut edit dialog: Fix bugs (#25060)
* custom error badge * fix theme bug * fix focus bug (#25051) * use Infobar control * add comments
This commit is contained in:
@@ -79,6 +79,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool GetDisposedState() => disposedValue;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(disposing: true);
|
Dispose(disposing: true);
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
|
|||||||
hook = new HotkeySettingsControlHook(Hotkey_KeyDown, Hotkey_KeyUp, Hotkey_IsActive, FilterAccessibleKeyboardEvents);
|
hook = new HotkeySettingsControlHook(Hotkey_KeyDown, Hotkey_KeyUp, Hotkey_IsActive, FilterAccessibleKeyboardEvents);
|
||||||
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
|
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
|
||||||
|
|
||||||
|
App.GetSettingsWindow().Activated += ShortcutDialog_SettingsWindow_Activated;
|
||||||
|
|
||||||
// We create the Dialog in C# because doing it in XAML is giving WinUI/XAML Island bugs when using dark theme.
|
// We create the Dialog in C# because doing it in XAML is giving WinUI/XAML Island bugs when using dark theme.
|
||||||
shortcutDialog = new ContentDialog
|
shortcutDialog = new ContentDialog
|
||||||
{
|
{
|
||||||
@@ -111,6 +113,8 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
|
|||||||
shortcutDialog.Opened -= ShortcutDialog_Opened;
|
shortcutDialog.Opened -= ShortcutDialog_Opened;
|
||||||
shortcutDialog.Closing -= ShortcutDialog_Closing;
|
shortcutDialog.Closing -= ShortcutDialog_Closing;
|
||||||
|
|
||||||
|
App.GetSettingsWindow().Activated -= ShortcutDialog_SettingsWindow_Activated;
|
||||||
|
|
||||||
// Dispose the HotkeySettingsControlHook object to terminate the hook threads when the textbox is unloaded
|
// Dispose the HotkeySettingsControlHook object to terminate the hook threads when the textbox is unloaded
|
||||||
hook.Dispose();
|
hook.Dispose();
|
||||||
}
|
}
|
||||||
@@ -336,6 +340,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
|
|||||||
c.Keys = HotkeySettings.GetKeysList();
|
c.Keys = HotkeySettings.GetKeysList();
|
||||||
|
|
||||||
shortcutDialog.XamlRoot = this.XamlRoot;
|
shortcutDialog.XamlRoot = this.XamlRoot;
|
||||||
|
shortcutDialog.RequestedTheme = this.ActualTheme;
|
||||||
await shortcutDialog.ShowAsync();
|
await shortcutDialog.ShowAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +368,21 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShortcutDialog_SettingsWindow_Activated(object sender, WindowActivatedEventArgs args)
|
||||||
|
{
|
||||||
|
args.Handled = true;
|
||||||
|
if (args.WindowActivationState != WindowActivationState.Deactivated && hook.GetDisposedState() == true)
|
||||||
|
{
|
||||||
|
// If the PT settings window gets focussed/activated again, we enable the keyboard hook to catch the keyboard input.
|
||||||
|
hook = new HotkeySettingsControlHook(Hotkey_KeyDown, Hotkey_KeyUp, Hotkey_IsActive, FilterAccessibleKeyboardEvents);
|
||||||
|
}
|
||||||
|
else if (args.WindowActivationState == WindowActivationState.Deactivated && hook.GetDisposedState() == false)
|
||||||
|
{
|
||||||
|
// If the PT settings window lost focus/activation, we disable the keyboard hook to allow keyboard input on other windows.
|
||||||
|
hook.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ShortcutDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
|
private void ShortcutDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
|
||||||
{
|
{
|
||||||
_isActive = false;
|
_isActive = false;
|
||||||
|
|||||||
@@ -56,39 +56,14 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
Spacing="8">
|
Spacing="8">
|
||||||
<Grid Height="36">
|
<Grid Height="62">
|
||||||
|
|
||||||
<Border
|
<InfoBar x:Uid="InvalidShortcut"
|
||||||
x:Name="WarningBanner"
|
IsClosable="False"
|
||||||
Margin="-2,0,0,0"
|
IsOpen="{Binding ElementName=ShortcutContentControl, Path=IsError, Mode=OneWay}"
|
||||||
Padding="8"
|
IsTabStop="{Binding ElementName=ShortcutContentControl, Path=IsError, Mode=OneWay}"
|
||||||
Background="{ThemeResource InfoBarErrorSeverityBackgroundBrush}"
|
Severity="Error" />
|
||||||
BorderBrush="{ThemeResource InfoBarBorderBrush}"
|
|
||||||
BorderThickness="{ThemeResource InfoBarBorderThickness}"
|
|
||||||
CornerRadius="{ThemeResource ControlCornerRadius}"
|
|
||||||
Visibility="{Binding ElementName=ShortcutContentControl, Path=IsError, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<!--TODO(stefan) InfoBadge not available
|
|
||||||
<InfoBadge AutomationProperties.AccessibilityView="Raw"
|
|
||||||
Margin="2,0,12,0"
|
|
||||||
Style="{StaticResource CriticalIconInfoBadgeStyle}" />
|
|
||||||
-->
|
|
||||||
|
|
||||||
<TextBlock
|
|
||||||
x:Name="InvalidShortcutWarningLabel"
|
|
||||||
x:Uid="InvalidShortcut"
|
|
||||||
Grid.Column="1"
|
|
||||||
Margin="0,-1,0,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
FontWeight="{ThemeResource InfoBarTitleFontWeight}"
|
|
||||||
Foreground="{ThemeResource InfoBarTitleForeground}" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<toolkitcontrols:MarkdownTextBlock
|
<toolkitcontrols:MarkdownTextBlock
|
||||||
x:Uid="InvalidShortcutWarningLabel"
|
x:Uid="InvalidShortcutWarningLabel"
|
||||||
|
|||||||
@@ -2119,11 +2119,12 @@ From there, simply click on one of the supported files in the File Explorer and
|
|||||||
<data name="Activation_Shortcut_Title" xml:space="preserve">
|
<data name="Activation_Shortcut_Title" xml:space="preserve">
|
||||||
<value>Activation shortcut</value>
|
<value>Activation shortcut</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InvalidShortcut.Text" xml:space="preserve">
|
<data name="InvalidShortcut.Title" xml:space="preserve">
|
||||||
<value>Invalid shortcut</value>
|
<value>Invalid shortcut</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InvalidShortcutWarningLabel.Text" xml:space="preserve">
|
<data name="InvalidShortcutWarningLabel.Text" xml:space="preserve">
|
||||||
<value>Only shortcuts that start with **Windows key**, **Ctrl**, **Alt** or **Shift** are valid.</value>
|
<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>
|
||||||
<data name="FancyZones_SpanZonesAcrossMonitors.Description" xml:space="preserve">
|
<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>
|
<value>All monitors must have the same DPI scaling and will be treated as one large combined rectangle which contains all monitors</value>
|
||||||
@@ -3115,4 +3116,4 @@ Activate by holding the key for the character you want to add an accent to, then
|
|||||||
<data name="RegistryPreview_LaunchButtonControl.Header" xml:space="preserve">
|
<data name="RegistryPreview_LaunchButtonControl.Header" xml:space="preserve">
|
||||||
<value>Launch Registry Preview</value>
|
<value>Launch Registry Preview</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user