Merge branch 'dev' into FixProgramIcons

This commit is contained in:
VictoriousRaptor 2022-10-21 01:11:45 +08:00 committed by GitHub
commit 9d40053ae0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 140 additions and 64 deletions

View file

@ -199,7 +199,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
} }
public bool LeaveCmdOpen { get; set; } public bool LeaveCmdOpen { get; set; }
public bool HideWhenDeactive { get; set; } = true; public bool HideWhenDeactive { get; set; } = true;
public bool RememberLastLaunchLocation { get; set; } public SearchWindowPositions SearchWindowPosition { get; set; } = SearchWindowPositions.MouseScreenCenter;
public bool IgnoreHotkeysOnFullscreen { get; set; } public bool IgnoreHotkeysOnFullscreen { get; set; }
public HttpProxy Proxy { get; set; } = new HttpProxy(); public HttpProxy Proxy { get; set; } = new HttpProxy();
@ -225,4 +225,12 @@ namespace Flow.Launcher.Infrastructure.UserSettings
Light, Light,
Dark Dark
} }
public enum SearchWindowPositions
{
RememberLastLaunchLocation,
MouseScreenCenter,
MouseScreenCenterTop,
MouseScreenLeftTop,
MouseScreenRightTop
}
} }

View file

@ -23,6 +23,8 @@
<system:String x:Key="textTitle">Text</system:String> <system:String x:Key="textTitle">Text</system:String>
<system:String x:Key="GameMode">Game Mode</system:String> <system:String x:Key="GameMode">Game Mode</system:String>
<system:String x:Key="GameModeToolTip">Suspend the use of Hotkeys.</system:String> <system:String x:Key="GameModeToolTip">Suspend the use of Hotkeys.</system:String>
<system:String x:Key="PositionReset">Position Reset</system:String>
<system:String x:Key="PositionResetToolTip">Reset search window position</system:String>
<!-- Setting General --> <!-- Setting General -->
<system:String x:Key="flowlauncher_settings">Flow Launcher Settings</system:String> <system:String x:Key="flowlauncher_settings">Flow Launcher Settings</system:String>
@ -33,7 +35,13 @@
<system:String x:Key="setAutoStartFailed">Error setting launch on startup</system:String> <system:String x:Key="setAutoStartFailed">Error setting launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String> <system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String>
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String> <system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
<system:String x:Key="SearchWindowPosition">Search Window Position</system:String>
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String> <system:String x:Key="rememberLastLocation">Remember last launch location</system:String>
<system:String x:Key="SearchWindowPositionRememberLastLaunchLocation">Remember Last Location</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenCenter">Mouse Focused Screen - Center</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenCenterTop">Mouse Focused Screen - Center Top</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenLeftTop">Mouse Focused Screen - Left Top</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenRightTop">Mouse Focused Screen - Right Top</system:String>
<system:String x:Key="language">Language</system:String> <system:String x:Key="language">Language</system:String>
<system:String x:Key="lastQueryMode">Last Query Style</system:String> <system:String x:Key="lastQueryMode">Last Query Style</system:String>
<system:String x:Key="lastQueryModeToolTip">Show/Hide previous results when Flow Launcher is reactivated.</system:String> <system:String x:Key="lastQueryModeToolTip">Show/Hide previous results when Flow Launcher is reactivated.</system:String>

View file

@ -32,9 +32,7 @@
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
WindowStartupLocation="Manual" WindowStartupLocation="Manual"
WindowStyle="None" WindowStyle="None"
mc:Ignorable="d" mc:Ignorable="d">
Left="{Binding Left, Mode=TwoWay}"
Top="{Binding Top, Mode=TwoWay}">
<Window.Resources> <Window.Resources>
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" /> <converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
<converters:BorderClipConverter x:Key="BorderClipConverter" /> <converters:BorderClipConverter x:Key="BorderClipConverter" />
@ -88,20 +86,20 @@
<KeyBinding Key="Left" Command="{Binding EscCommand}" /> <KeyBinding Key="Left" Command="{Binding EscCommand}" />
<KeyBinding <KeyBinding
Key="OemCloseBrackets" Key="OemCloseBrackets"
Modifiers="Control" Command="{Binding IncreaseWidthCommand}"
Command="{Binding IncreaseWidthCommand}"/> Modifiers="Control" />
<KeyBinding <KeyBinding
Key="OemOpenBrackets" Key="OemOpenBrackets"
Modifiers="Control" Command="{Binding DecreaseWidthCommand}"
Command="{Binding DecreaseWidthCommand}"/> Modifiers="Control" />
<KeyBinding <KeyBinding
Key="OemPlus" Key="OemPlus"
Modifiers="Control" Command="{Binding IncreaseMaxResultCommand}"
Command="{Binding IncreaseMaxResultCommand}"/> Modifiers="Control" />
<KeyBinding <KeyBinding
Key="OemMinus" Key="OemMinus"
Modifiers="Control" Command="{Binding DecreaseMaxResultCommand}"
Command="{Binding DecreaseMaxResultCommand}"/> Modifiers="Control" />
<KeyBinding <KeyBinding
Key="H" Key="H"
Command="{Binding LoadHistoryCommand}" Command="{Binding LoadHistoryCommand}"
@ -195,9 +193,9 @@
AllowDrop="True" AllowDrop="True"
Background="Transparent" Background="Transparent"
PreviewDragOver="OnPreviewDragOver" PreviewDragOver="OnPreviewDragOver"
PreviewKeyUp="QueryTextBox_KeyUp"
Style="{DynamicResource QueryBoxStyle}" Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
PreviewKeyUp="QueryTextBox_KeyUp"
Visibility="Visible"> Visibility="Visible">
<TextBox.CommandBindings> <TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" /> <CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />

View file

@ -46,6 +46,7 @@ namespace Flow.Launcher
_viewModel = mainVM; _viewModel = mainVM;
_settings = settings; _settings = settings;
InitializeComponent(); InitializeComponent();
InitializePosition();
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
} }
@ -108,7 +109,6 @@ namespace Flow.Launcher
animationSound.Position = TimeSpan.Zero; animationSound.Position = TimeSpan.Zero;
animationSound.Play(); animationSound.Play();
} }
UpdatePosition(); UpdatePosition();
Activate(); Activate();
QueryTextBox.Focus(); QueryTextBox.Focus();
@ -161,6 +161,7 @@ namespace Flow.Launcher
_viewModel.QueryTextCursorMovedToEnd = false; _viewModel.QueryTextCursorMovedToEnd = false;
} }
break; break;
} }
}; };
_settings.PropertyChanged += (o, e) => _settings.PropertyChanged += (o, e) =>
@ -176,17 +177,51 @@ namespace Flow.Launcher
case nameof(Settings.Hotkey): case nameof(Settings.Hotkey):
UpdateNotifyIconText(); UpdateNotifyIconText();
break; break;
case nameof(Settings.WindowLeft):
Left = _settings.WindowLeft;
break;
case nameof(Settings.WindowTop):
Top = _settings.WindowTop;
break;
} }
}; };
} }
private void InitializePosition()
{
switch (_settings.SearchWindowPosition)
{
case SearchWindowPositions.RememberLastLaunchLocation:
Top = _settings.WindowTop;
Left = _settings.WindowLeft;
break;
case SearchWindowPositions.MouseScreenCenter:
Left = HorizonCenter();
Top = VerticalCenter();
break;
case SearchWindowPositions.MouseScreenCenterTop:
Left = HorizonCenter();
Top = 10;
break;
case SearchWindowPositions.MouseScreenLeftTop:
Left = 10;
Top = 10;
break;
case SearchWindowPositions.MouseScreenRightTop:
Left = HorizonRight();
Top = 10;
break;
}
}
private void UpdateNotifyIconText() private void UpdateNotifyIconText()
{ {
var menu = contextMenu; var menu = contextMenu;
((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")"; ((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")";
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("GameMode"); ((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"); ((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset");
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"); ((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
((MenuItem)menu.Items[5]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
} }
private void InitializeNotifyIcon() private void InitializeNotifyIcon()
@ -212,6 +247,10 @@ namespace Flow.Launcher
{ {
Header = InternationalizationManager.Instance.GetTranslation("GameMode") Header = InternationalizationManager.Instance.GetTranslation("GameMode")
}; };
var positionreset = new MenuItem
{
Header = InternationalizationManager.Instance.GetTranslation("PositionReset")
};
var settings = new MenuItem var settings = new MenuItem
{ {
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings") Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings")
@ -223,12 +262,15 @@ namespace Flow.Launcher
open.Click += (o, e) => _viewModel.ToggleFlowLauncher(); open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
gamemode.Click += (o, e) => ToggleGameMode(); gamemode.Click += (o, e) => ToggleGameMode();
positionreset.Click += (o, e) => PositionReset();
settings.Click += (o, e) => App.API.OpenSettingDialog(); settings.Click += (o, e) => App.API.OpenSettingDialog();
exit.Click += (o, e) => Close(); exit.Click += (o, e) => Close();
contextMenu.Items.Add(header); contextMenu.Items.Add(header);
contextMenu.Items.Add(open); contextMenu.Items.Add(open);
gamemode.ToolTip = InternationalizationManager.Instance.GetTranslation("GameModeToolTip"); gamemode.ToolTip = InternationalizationManager.Instance.GetTranslation("GameModeToolTip");
positionreset.ToolTip = InternationalizationManager.Instance.GetTranslation("PositionResetToolTip");
contextMenu.Items.Add(gamemode); contextMenu.Items.Add(gamemode);
contextMenu.Items.Add(positionreset);
contextMenu.Items.Add(settings); contextMenu.Items.Add(settings);
contextMenu.Items.Add(exit); contextMenu.Items.Add(exit);
@ -275,10 +317,17 @@ namespace Flow.Launcher
_viewModel.GameModeStatus = true; _viewModel.GameModeStatus = true;
} }
} }
private async void PositionReset()
{
_viewModel.Show();
await Task.Delay(300); // If don't give a time, Positioning will be weird.
Left = HorizonCenter();
Top = VerticalCenter();
}
private void InitProgressbarAnimation() private void InitProgressbarAnimation()
{ {
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150, var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150,
new Duration(new TimeSpan(0, 0, 0, 0, 1600))); new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 50, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 50, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)")); Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)")); Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
@ -382,6 +431,8 @@ namespace Flow.Launcher
private async void OnDeactivated(object sender, EventArgs e) private async void OnDeactivated(object sender, EventArgs e)
{ {
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
//This condition stops extra hide call when animator is on, //This condition stops extra hide call when animator is on,
// which causes the toggling to occasional hide instead of show. // which causes the toggling to occasional hide instead of show.
if (_viewModel.MainWindowVisibilityStatus) if (_viewModel.MainWindowVisibilityStatus)
@ -403,24 +454,14 @@ namespace Flow.Launcher
{ {
if (_animating) if (_animating)
return; return;
InitializePosition();
if (_settings.RememberLastLaunchLocation)
{
Left = _settings.WindowLeft;
Top = _settings.WindowTop;
}
else
{
Left = WindowLeft();
Top = WindowTop();
}
} }
private void OnLocationChanged(object sender, EventArgs e) private void OnLocationChanged(object sender, EventArgs e)
{ {
if (_animating) if (_animating)
return; return;
if (_settings.RememberLastLaunchLocation) if (_settings.SearchWindowPosition == SearchWindowPositions.RememberLastLaunchLocation)
{ {
_settings.WindowLeft = Left; _settings.WindowLeft = Left;
_settings.WindowTop = Top; _settings.WindowTop = Top;
@ -439,17 +480,8 @@ namespace Flow.Launcher
_viewModel.Show(); _viewModel.Show();
} }
} }
private void InitializePosition()
{
if (!_settings.RememberLastLaunchLocation)
{
Left = WindowLeft();
Top = WindowTop();
}
}
public double WindowLeft() public double HorizonCenter()
{ {
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
@ -458,7 +490,7 @@ namespace Flow.Launcher
return left; return left;
} }
public double WindowTop() public double VerticalCenter()
{ {
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
@ -467,6 +499,15 @@ namespace Flow.Launcher
return top; return top;
} }
public double HorizonRight()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
var left = (dip2.X - ActualWidth) - 10;
return left;
}
/// <summary> /// <summary>
/// Register up and down key /// Register up and down key
/// todo: any way to put this in xaml ? /// todo: any way to put this in xaml ?

View file

@ -685,12 +685,25 @@
</ItemsControl> </ItemsControl>
</Border> </Border>
<Border Style="{DynamicResource SettingGroupBox}"> <Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}"> <ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}"> <StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource rememberLastLocation}" /> <TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SearchWindowPosition}" />
</StackPanel> </StackPanel>
<CheckBox IsChecked="{Binding Settings.RememberLastLaunchLocation}" Style="{DynamicResource SideControlCheckBox}" /> <ComboBox
x:Name="SearchWindowPosition"
Grid.Column="2"
MinWidth="220"
Margin="0,0,18,0"
VerticalAlignment="Center"
DisplayMemberPath="Display"
FontSize="14"
ItemsSource="{Binding SearchWindowPositions}"
SelectedValue="{Binding Settings.SearchWindowPosition}"
SelectedValuePath="Value" />
<TextBlock Style="{StaticResource Glyph}">
&#xe7f4;
</TextBlock>
</ItemsControl> </ItemsControl>
</Border> </Border>

View file

@ -341,25 +341,6 @@ namespace Flow.Launcher.ViewModel
} }
public double Top
{
get => _settings.WindowTop;
set
{
_settings.WindowTop = value;
OnPropertyChanged();
}
}
public double Left
{
get => _settings.WindowLeft;
set
{
_settings.WindowLeft = value;
OnPropertyChanged();
}
}
[RelayCommand] [RelayCommand]
private void IncreaseWidth() private void IncreaseWidth()
{ {
@ -370,7 +351,7 @@ namespace Flow.Launcher.ViewModel
else else
{ {
_settings.WindowSize += 100; _settings.WindowSize += 100;
Left -= 50; _settings.WindowLeft -= 50;
} }
OnPropertyChanged(); OnPropertyChanged();
} }
@ -384,7 +365,7 @@ namespace Flow.Launcher.ViewModel
} }
else else
{ {
Left += 50; _settings.WindowLeft += 50;
_settings.WindowSize -= 100; _settings.WindowSize -= 100;
} }
OnPropertyChanged(); OnPropertyChanged();

View file

@ -385,6 +385,33 @@ namespace Flow.Launcher.ViewModel
} }
} }
public class SearchWindowPosition
{
public string Display { get; set; }
public SearchWindowPositions Value { get; set; }
}
public List<SearchWindowPosition> SearchWindowPositions
{
get
{
List<SearchWindowPosition> modes = new List<SearchWindowPosition>();
var enums = (SearchWindowPositions[])Enum.GetValues(typeof(SearchWindowPositions));
foreach (var e in enums)
{
var key = $"SearchWindowPosition{e}";
var display = _translater.GetTranslation(key);
var m = new SearchWindowPosition { Display = display, Value = e, };
modes.Add(m);
}
return modes;
}
}
public double WindowWidthSize public double WindowWidthSize
{ {
get => Settings.WindowSize; get => Settings.WindowSize;