mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
- Fix Keyboard Navigation Control for Tray Menu
- Add Focus Style for toggle
This commit is contained in:
parent
a9b4187969
commit
d2818db6bf
3 changed files with 59 additions and 31 deletions
|
|
@ -7,6 +7,7 @@ namespace Flow.Launcher.Infrastructure
|
||||||
public static class Constant
|
public static class Constant
|
||||||
{
|
{
|
||||||
public const string FlowLauncher = "Flow.Launcher";
|
public const string FlowLauncher = "Flow.Launcher";
|
||||||
|
public const string FlowLauncherFullName = "Flow Launcher";
|
||||||
public const string Plugins = "Plugins";
|
public const string Plugins = "Plugins";
|
||||||
public const string PluginMetadataFileName = "plugin.json";
|
public const string PluginMetadataFileName = "plugin.json";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ using System.Media;
|
||||||
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
|
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
|
||||||
using DataObject = System.Windows.DataObject;
|
using DataObject = System.Windows.DataObject;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Flow.Launcher
|
namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
|
|
@ -34,11 +36,14 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
public static extern IntPtr SetForegroundWindow(IntPtr hwnd);
|
||||||
|
|
||||||
private readonly Storyboard _progressBarStoryboard = new Storyboard();
|
private readonly Storyboard _progressBarStoryboard = new Storyboard();
|
||||||
private bool isProgressBarStoryboardPaused;
|
private bool isProgressBarStoryboardPaused;
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
private NotifyIcon _notifyIcon;
|
private NotifyIcon _notifyIcon;
|
||||||
private ContextMenu contextMenu;
|
private ContextMenuStrip contextMenu;
|
||||||
private MainViewModel _viewModel;
|
private MainViewModel _viewModel;
|
||||||
private bool _animating;
|
private bool _animating;
|
||||||
MediaPlayer animationSound = new MediaPlayer();
|
MediaPlayer animationSound = new MediaPlayer();
|
||||||
|
|
@ -258,11 +263,11 @@ namespace Flow.Launcher
|
||||||
private void UpdateNotifyIconText()
|
private void UpdateNotifyIconText()
|
||||||
{
|
{
|
||||||
var menu = contextMenu;
|
var menu = contextMenu;
|
||||||
((MenuItem)menu.Items[0]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")";
|
//((MenuItem)menu.Items[0]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")";
|
||||||
((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
|
//((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
|
||||||
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset");
|
//((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset");
|
||||||
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
|
//((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
|
||||||
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
|
//((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,12 +275,12 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
_notifyIcon = new NotifyIcon
|
_notifyIcon = new NotifyIcon
|
||||||
{
|
{
|
||||||
Text = Infrastructure.Constant.FlowLauncher,
|
Text = Infrastructure.Constant.FlowLauncherFullName,
|
||||||
Icon = Properties.Resources.app,
|
Icon = Properties.Resources.app,
|
||||||
Visible = !_settings.HideNotifyIcon
|
Visible = !_settings.HideNotifyIcon
|
||||||
};
|
};
|
||||||
|
|
||||||
contextMenu = new ContextMenu();
|
var contextMenu = new ContextMenu();
|
||||||
|
|
||||||
var openIcon = new FontIcon
|
var openIcon = new FontIcon
|
||||||
{
|
{
|
||||||
|
|
@ -283,7 +288,8 @@ namespace Flow.Launcher
|
||||||
};
|
};
|
||||||
var open = new MenuItem
|
var open = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")", Icon = openIcon
|
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")",
|
||||||
|
Icon = openIcon
|
||||||
};
|
};
|
||||||
var gamemodeIcon = new FontIcon
|
var gamemodeIcon = new FontIcon
|
||||||
{
|
{
|
||||||
|
|
@ -291,7 +297,8 @@ namespace Flow.Launcher
|
||||||
};
|
};
|
||||||
var gamemode = new MenuItem
|
var gamemode = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon
|
Header = InternationalizationManager.Instance.GetTranslation("GameMode"),
|
||||||
|
Icon = gamemodeIcon
|
||||||
};
|
};
|
||||||
var positionresetIcon = new FontIcon
|
var positionresetIcon = new FontIcon
|
||||||
{
|
{
|
||||||
|
|
@ -299,7 +306,8 @@ namespace Flow.Launcher
|
||||||
};
|
};
|
||||||
var positionreset = new MenuItem
|
var positionreset = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), Icon = positionresetIcon
|
Header = InternationalizationManager.Instance.GetTranslation("PositionReset"),
|
||||||
|
Icon = positionresetIcon
|
||||||
};
|
};
|
||||||
var settingsIcon = new FontIcon
|
var settingsIcon = new FontIcon
|
||||||
{
|
{
|
||||||
|
|
@ -307,7 +315,8 @@ namespace Flow.Launcher
|
||||||
};
|
};
|
||||||
var settings = new MenuItem
|
var settings = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"), Icon = settingsIcon
|
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"),
|
||||||
|
Icon = settingsIcon
|
||||||
};
|
};
|
||||||
var exitIcon = new FontIcon
|
var exitIcon = new FontIcon
|
||||||
{
|
{
|
||||||
|
|
@ -315,7 +324,8 @@ namespace Flow.Launcher
|
||||||
};
|
};
|
||||||
var exit = new MenuItem
|
var exit = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon
|
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"),
|
||||||
|
Icon = exitIcon
|
||||||
};
|
};
|
||||||
|
|
||||||
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
|
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
|
||||||
|
|
@ -333,7 +343,6 @@ namespace Flow.Launcher
|
||||||
contextMenu.Items.Add(settings);
|
contextMenu.Items.Add(settings);
|
||||||
contextMenu.Items.Add(exit);
|
contextMenu.Items.Add(exit);
|
||||||
|
|
||||||
_notifyIcon.ContextMenuStrip = new ContextMenuStrip(); // it need for close the context menu. if not, context menu can't close.
|
|
||||||
_notifyIcon.MouseClick += (o, e) =>
|
_notifyIcon.MouseClick += (o, e) =>
|
||||||
{
|
{
|
||||||
switch (e.Button)
|
switch (e.Button)
|
||||||
|
|
@ -341,9 +350,15 @@ namespace Flow.Launcher
|
||||||
case MouseButtons.Left:
|
case MouseButtons.Left:
|
||||||
_viewModel.ToggleFlowLauncher();
|
_viewModel.ToggleFlowLauncher();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseButtons.Right:
|
case MouseButtons.Right:
|
||||||
|
|
||||||
contextMenu.IsOpen = true;
|
contextMenu.IsOpen = true;
|
||||||
|
// Get context menu handle and bring it to the foreground
|
||||||
|
if (PresentationSource.FromVisual(contextMenu) is HwndSource hwndSource)
|
||||||
|
{
|
||||||
|
_ = SetForegroundWindow(hwndSource.Handle);
|
||||||
|
}
|
||||||
|
contextMenu.Focus();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,20 @@
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style x:Key="SwitchFocusVisualStyleKey">
|
||||||
|
<Setter Property="Control.Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate>
|
||||||
|
<Rectangle
|
||||||
|
Margin="-8,-4,-8,-4"
|
||||||
|
RadiusX="5"
|
||||||
|
RadiusY="5"
|
||||||
|
Stroke="{DynamicResource Color05B}"
|
||||||
|
StrokeThickness="2" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
<Style x:Key="SettingGrid" TargetType="ItemsControl">
|
<Style x:Key="SettingGrid" TargetType="ItemsControl">
|
||||||
<Setter Property="Focusable" Value="False" />
|
<Setter Property="Focusable" Value="False" />
|
||||||
<Setter Property="Margin" Value="0" />
|
<Setter Property="Margin" Value="0" />
|
||||||
|
|
@ -137,6 +151,7 @@
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
<Setter Property="Grid.Column" Value="2" />
|
||||||
<Setter Property="FocusVisualMargin" Value="5" />
|
<Setter Property="FocusVisualMargin" Value="5" />
|
||||||
<Setter Property="Width" Value="Auto" />
|
<Setter Property="Width" Value="Auto" />
|
||||||
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource SwitchFocusVisualStyleKey}" />
|
||||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Right" />
|
<Setter Property="HorizontalContentAlignment" Value="Right" />
|
||||||
<Setter Property="OffContent" Value="{DynamicResource disable}" />
|
<Setter Property="OffContent" Value="{DynamicResource disable}" />
|
||||||
|
|
@ -447,7 +462,10 @@
|
||||||
IsItemsHost="true"
|
IsItemsHost="true"
|
||||||
LastChildFill="False" />
|
LastChildFill="False" />
|
||||||
<Border Grid.Column="1">
|
<Border Grid.Column="1">
|
||||||
<ContentPresenter Grid.Column="1" ContentSource="SelectedContent" />
|
<ContentPresenter
|
||||||
|
x:Name="PART_SelectedContentHost"
|
||||||
|
Grid.Column="1"
|
||||||
|
ContentSource="SelectedContent" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|
@ -693,7 +711,7 @@
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Border
|
<Border
|
||||||
Margin="0,30,0,0"
|
Margin="0,30,0,0"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
Style="{DynamicResource SettingGroupBox}">
|
Style="{DynamicResource SettingGroupBox}">
|
||||||
|
|
@ -720,7 +738,7 @@
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="SelectScreen"
|
x:Name="SelectScreen"
|
||||||
MinWidth="160"
|
MinWidth="160"
|
||||||
Margin="0,0,18,0"
|
Margin="0,0,18,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
ItemsSource="{Binding ScreenNumbers}"
|
ItemsSource="{Binding ScreenNumbers}"
|
||||||
|
|
@ -738,14 +756,12 @@
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBlock Style="{StaticResource Glyph}">
|
<TextBlock Style="{StaticResource Glyph}">
|
||||||

|

|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Separator
|
<Separator Width="Auto" BorderThickness="1">
|
||||||
Width="Auto"
|
|
||||||
BorderThickness="1">
|
|
||||||
<Separator.Style>
|
<Separator.Style>
|
||||||
<Style BasedOn="{StaticResource SettingSeparatorStyle}" TargetType="Separator">
|
<Style BasedOn="{StaticResource SettingSeparatorStyle}" TargetType="Separator">
|
||||||
<Setter Property="Visibility" Value="Visible" />
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
|
@ -758,9 +774,7 @@
|
||||||
</Separator.Style>
|
</Separator.Style>
|
||||||
</Separator>
|
</Separator>
|
||||||
|
|
||||||
<Border
|
<Border Margin="0" BorderThickness="0">
|
||||||
Margin="0"
|
|
||||||
BorderThickness="0">
|
|
||||||
<Border.Style>
|
<Border.Style>
|
||||||
<Style BasedOn="{StaticResource SettingGroupBox}" TargetType="Border">
|
<Style BasedOn="{StaticResource SettingGroupBox}" TargetType="Border">
|
||||||
<Setter Property="Visibility" Value="Visible" />
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
|
@ -786,8 +800,7 @@
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
ItemsSource="{Binding SearchWindowAligns}"
|
ItemsSource="{Binding SearchWindowAligns}"
|
||||||
SelectedValue="{Binding Settings.SearchWindowAlign}"
|
SelectedValue="{Binding Settings.SearchWindowAlign}"
|
||||||
SelectedValuePath="Value">
|
SelectedValuePath="Value" />
|
||||||
</ComboBox>
|
|
||||||
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
|
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
|
||||||
<StackPanel.Style>
|
<StackPanel.Style>
|
||||||
<Style TargetType="StackPanel">
|
<Style TargetType="StackPanel">
|
||||||
|
|
@ -817,7 +830,7 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBlock Style="{StaticResource Glyph}">
|
<TextBlock Style="{StaticResource Glyph}">
|
||||||

|

|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
@ -2446,8 +2459,7 @@
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
ItemsSource="{Binding AnimationSpeeds}"
|
ItemsSource="{Binding AnimationSpeeds}"
|
||||||
SelectedValue="{Binding Settings.AnimationSpeed}"
|
SelectedValue="{Binding Settings.AnimationSpeed}"
|
||||||
SelectedValuePath="Value">
|
SelectedValuePath="Value" />
|
||||||
</ComboBox>
|
|
||||||
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
|
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
|
||||||
<StackPanel.Style>
|
<StackPanel.Style>
|
||||||
<Style TargetType="StackPanel">
|
<Style TargetType="StackPanel">
|
||||||
|
|
@ -2543,7 +2555,7 @@
|
||||||
TickFrequency="1"
|
TickFrequency="1"
|
||||||
Value="{Binding SoundEffectVolume, Mode=TwoWay}" />
|
Value="{Binding SoundEffectVolume, Mode=TwoWay}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBlock Style="{StaticResource Glyph}">
|
<TextBlock Style="{StaticResource Glyph}">
|
||||||

|

|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue