Skip to content

Commit de5c039

Browse files
committed
Merge Dev
2 parents c733b95 + b80b3ed commit de5c039

File tree

14 files changed

+238
-44
lines changed

14 files changed

+238
-44
lines changed

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ private static BitmapImage LoadFullImage(string path)
252252
image.BeginInit();
253253
image.CacheOption = BitmapCacheOption.OnLoad;
254254
image.UriSource = new Uri(path);
255+
image.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
255256
image.EndInit();
256257
return image;
257258
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public bool HideNotifyIcon
203203
}
204204
public bool LeaveCmdOpen { get; set; }
205205
public bool HideWhenDeactive { get; set; } = true;
206-
public bool RememberLastLaunchLocation { get; set; }
206+
public SearchWindowPositions SearchWindowPosition { get; set; } = SearchWindowPositions.MouseScreenCenter;
207207
public bool IgnoreHotkeysOnFullscreen { get; set; }
208208

209209
public HttpProxy Proxy { get; set; } = new HttpProxy();
@@ -229,4 +229,12 @@ public enum ColorSchemes
229229
Light,
230230
Dark
231231
}
232+
public enum SearchWindowPositions
233+
{
234+
RememberLastLaunchLocation,
235+
MouseScreenCenter,
236+
MouseScreenCenterTop,
237+
MouseScreenLeftTop,
238+
MouseScreenRightTop
239+
}
232240
}

Flow.Launcher.Test/Flow.Launcher.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<ItemGroup>
5151
<PackageReference Include="Moq" Version="4.16.1" />
5252
<PackageReference Include="nunit" Version="3.13.2" />
53-
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0">
53+
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1">
5454
<PrivateAssets>all</PrivateAssets>
5555
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5656
</PackageReference>

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
</ItemGroup>
8484

8585
<ItemGroup>
86+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
8687
<PackageReference Include="Fody" Version="6.5.4">
8788
<PrivateAssets>all</PrivateAssets>
8889
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -114,4 +115,14 @@
114115
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
115116
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
116117
</Target>
118+
119+
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
120+
<!-- Work around https://github.com/dotnet/wpf/issues/6792 -->
121+
122+
<ItemGroup>
123+
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
124+
<Analyzer Remove="@(Analyzer)" />
125+
<Analyzer Include="@(FilteredAnalyzer)" />
126+
</ItemGroup>
127+
</Target>
117128
</Project>
-1.6 KB
Loading

Flow.Launcher/Languages/en.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<system:String x:Key="textTitle">Text</system:String>
2424
<system:String x:Key="GameMode">Game Mode</system:String>
2525
<system:String x:Key="GameModeToolTip">Suspend the use of Hotkeys.</system:String>
26+
<system:String x:Key="PositionReset">Position Reset</system:String>
27+
<system:String x:Key="PositionResetToolTip">Reset search window position</system:String>
2628

2729
<!-- Setting General -->
2830
<system:String x:Key="flowlauncher_settings">Flow Launcher Settings</system:String>
@@ -33,14 +35,21 @@
3335
<system:String x:Key="setAutoStartFailed">Error setting launch on startup</system:String>
3436
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String>
3537
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
38+
<system:String x:Key="SearchWindowPosition">Search Window Position</system:String>
3639
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String>
40+
<system:String x:Key="SearchWindowPositionRememberLastLaunchLocation">Remember Last Location</system:String>
41+
<system:String x:Key="SearchWindowPositionMouseScreenCenter">Mouse Focused Screen - Center</system:String>
42+
<system:String x:Key="SearchWindowPositionMouseScreenCenterTop">Mouse Focused Screen - Center Top</system:String>
43+
<system:String x:Key="SearchWindowPositionMouseScreenLeftTop">Mouse Focused Screen - Left Top</system:String>
44+
<system:String x:Key="SearchWindowPositionMouseScreenRightTop">Mouse Focused Screen - Right Top</system:String>
3745
<system:String x:Key="language">Language</system:String>
3846
<system:String x:Key="lastQueryMode">Last Query Style</system:String>
3947
<system:String x:Key="lastQueryModeToolTip">Show/Hide previous results when Flow Launcher is reactivated.</system:String>
4048
<system:String x:Key="LastQueryPreserved">Preserve Last Query</system:String>
4149
<system:String x:Key="LastQuerySelected">Select last Query</system:String>
4250
<system:String x:Key="LastQueryEmpty">Empty last Query</system:String>
4351
<system:String x:Key="maxShowResults">Maximum results shown</system:String>
52+
<system:String x:Key="maxShowResultsToolTip">You can also quickly adjust this by using CTRL+Plus and CTRL+Minus.</system:String>
4453
<system:String x:Key="ignoreHotkeysOnFullscreen">Ignore hotkeys in fullscreen mode</system:String>
4554
<system:String x:Key="ignoreHotkeysOnFullscreenToolTip">Disable Flow Launcher activation when a full screen application is active (Recommended for games).</system:String>
4655
<system:String x:Key="defaultFileManager">Default File Manager</system:String>
@@ -133,6 +142,7 @@
133142
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
134143
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU. Not recommended if your computer performance is limited.</system:String>
135144
<system:String x:Key="windowWidthSize">Window Width Size</system:String>
145+
<system:String x:Key="windowWidthSizeToolTip">You can also quickly adjust this by using Ctrl+[ and Ctrl+].</system:String>
136146
<system:String x:Key="useGlyphUI">Use Segoe Fluent Icons</system:String>
137147
<system:String x:Key="useGlyphUIEffect">Use Segoe Fluent Icons for query results where supported</system:String>
138148

Flow.Launcher/MainWindow.xaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@
8181
<KeyBinding Key="Left"
8282
Command="{Binding EscCommand}" />
8383
<KeyBinding Key="H"
84+
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
85+
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
86+
<KeyBinding
87+
Key="OemCloseBrackets"
88+
Command="{Binding IncreaseWidthCommand}"
89+
Modifiers="Control" />
90+
<KeyBinding
91+
Key="OemOpenBrackets"
92+
Command="{Binding DecreaseWidthCommand}"
93+
Modifiers="Control" />
94+
<KeyBinding
95+
Key="OemPlus"
96+
Command="{Binding IncreaseMaxResultCommand}"
97+
Modifiers="Control" />
98+
<KeyBinding
99+
Key="OemMinus"
100+
Command="{Binding DecreaseMaxResultCommand}"
101+
Modifiers="Control" />
102+
<KeyBinding
103+
Key="H"
84104
Command="{Binding LoadHistoryCommand}"
85105
Modifiers="Ctrl" />
86106
<KeyBinding Key="Enter"
@@ -161,9 +181,9 @@
161181
AllowDrop="True"
162182
Background="Transparent"
163183
PreviewDragOver="OnPreviewDragOver"
184+
PreviewKeyUp="QueryTextBox_KeyUp"
164185
Style="{DynamicResource QueryBoxStyle}"
165186
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
166-
PreviewKeyUp="QueryTextBox_KeyUp"
167187
Visibility="Visible">
168188
<TextBox.CommandBindings>
169189
<CommandBinding Command="ApplicationCommands.Copy"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
9797
InitializeColorScheme();
9898
WindowsInteropHelper.DisableControlBox(this);
9999
InitProgressbarAnimation();
100+
InitializePosition();
100101
// since the default main window visibility is visible
101102
// so we need set focus during startup
102103
QueryTextBox.Focus();
@@ -114,7 +115,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
114115
animationSound.Position = TimeSpan.Zero;
115116
animationSound.Play();
116117
}
117-
118118
UpdatePosition();
119119
Activate();
120120
QueryTextBox.Focus();
@@ -167,6 +167,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
167167
_viewModel.QueryTextCursorMovedToEnd = false;
168168
}
169169
break;
170+
170171
}
171172
};
172173
_settings.PropertyChanged += (o, e) =>
@@ -182,21 +183,40 @@ private void OnLoaded(object sender, RoutedEventArgs _)
182183
case nameof(Settings.Hotkey):
183184
UpdateNotifyIconText();
184185
break;
186+
case nameof(Settings.WindowLeft):
187+
Left = _settings.WindowLeft;
188+
break;
189+
case nameof(Settings.WindowTop):
190+
Top = _settings.WindowTop;
191+
break;
185192
}
186193
};
187194
}
188195

189196
private void InitializePosition()
190197
{
191-
if (_settings.RememberLastLaunchLocation)
192-
{
193-
Top = _settings.WindowTop;
194-
Left = _settings.WindowLeft;
195-
}
196-
else
198+
switch (_settings.SearchWindowPosition)
197199
{
198-
Left = WindowLeft();
199-
Top = WindowTop();
200+
case SearchWindowPositions.RememberLastLaunchLocation:
201+
Top = _settings.WindowTop;
202+
Left = _settings.WindowLeft;
203+
break;
204+
case SearchWindowPositions.MouseScreenCenter:
205+
Left = HorizonCenter();
206+
Top = VerticalCenter();
207+
break;
208+
case SearchWindowPositions.MouseScreenCenterTop:
209+
Left = HorizonCenter();
210+
Top = 10;
211+
break;
212+
case SearchWindowPositions.MouseScreenLeftTop:
213+
Left = 10;
214+
Top = 10;
215+
break;
216+
case SearchWindowPositions.MouseScreenRightTop:
217+
Left = HorizonRight();
218+
Top = 10;
219+
break;
200220
}
201221
}
202222

@@ -205,8 +225,9 @@ private void UpdateNotifyIconText()
205225
var menu = contextMenu;
206226
((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")";
207227
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
208-
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
209-
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
228+
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset");
229+
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
230+
((MenuItem)menu.Items[5]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
210231
}
211232

212233
private void InitializeNotifyIcon()
@@ -232,6 +253,10 @@ private void InitializeNotifyIcon()
232253
{
233254
Header = InternationalizationManager.Instance.GetTranslation("GameMode")
234255
};
256+
var positionreset = new MenuItem
257+
{
258+
Header = InternationalizationManager.Instance.GetTranslation("PositionReset")
259+
};
235260
var settings = new MenuItem
236261
{
237262
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings")
@@ -243,12 +268,15 @@ private void InitializeNotifyIcon()
243268

244269
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
245270
gamemode.Click += (o, e) => ToggleGameMode();
271+
positionreset.Click += (o, e) => PositionReset();
246272
settings.Click += (o, e) => App.API.OpenSettingDialog();
247273
exit.Click += (o, e) => Close();
248274
contextMenu.Items.Add(header);
249275
contextMenu.Items.Add(open);
250276
gamemode.ToolTip = InternationalizationManager.Instance.GetTranslation("GameModeToolTip");
277+
positionreset.ToolTip = InternationalizationManager.Instance.GetTranslation("PositionResetToolTip");
251278
contextMenu.Items.Add(gamemode);
279+
contextMenu.Items.Add(positionreset);
252280
contextMenu.Items.Add(settings);
253281
contextMenu.Items.Add(exit);
254282

@@ -295,10 +323,17 @@ private void ToggleGameMode()
295323
_viewModel.GameModeStatus = true;
296324
}
297325
}
326+
private async void PositionReset()
327+
{
328+
_viewModel.Show();
329+
await Task.Delay(300); // If don't give a time, Positioning will be weird.
330+
Left = HorizonCenter();
331+
Top = VerticalCenter();
332+
}
298333
private void InitProgressbarAnimation()
299334
{
300335
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150,
301-
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
336+
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
302337
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 50, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
303338
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
304339
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
@@ -402,6 +437,8 @@ private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs
402437

403438
private async void OnDeactivated(object sender, EventArgs e)
404439
{
440+
_settings.WindowLeft = Left;
441+
_settings.WindowTop = Top;
405442
//This condition stops extra hide call when animator is on,
406443
// which causes the toggling to occasional hide instead of show.
407444
if (_viewModel.MainWindowVisibilityStatus)
@@ -423,24 +460,14 @@ private void UpdatePosition()
423460
{
424461
if (_animating)
425462
return;
426-
427-
if (_settings.RememberLastLaunchLocation)
428-
{
429-
Left = _settings.WindowLeft;
430-
Top = _settings.WindowTop;
431-
}
432-
else
433-
{
434-
Left = WindowLeft();
435-
Top = WindowTop();
436-
}
463+
InitializePosition();
437464
}
438465

439466
private void OnLocationChanged(object sender, EventArgs e)
440467
{
441468
if (_animating)
442469
return;
443-
if (_settings.RememberLastLaunchLocation)
470+
if (_settings.SearchWindowPosition == SearchWindowPositions.RememberLastLaunchLocation)
444471
{
445472
_settings.WindowLeft = Left;
446473
_settings.WindowTop = Top;
@@ -459,8 +486,8 @@ public void HideStartup()
459486
_viewModel.Show();
460487
}
461488
}
462-
463-
public double WindowLeft()
489+
490+
public double HorizonCenter()
464491
{
465492
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
466493
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
@@ -469,7 +496,7 @@ public double WindowLeft()
469496
return left;
470497
}
471498

472-
public double WindowTop()
499+
public double VerticalCenter()
473500
{
474501
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
475502
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
@@ -478,12 +505,22 @@ public double WindowTop()
478505
return top;
479506
}
480507

508+
public double HorizonRight()
509+
{
510+
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
511+
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
512+
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
513+
var left = (dip2.X - ActualWidth) - 10;
514+
return left;
515+
}
516+
481517
/// <summary>
482518
/// Register up and down key
483519
/// todo: any way to put this in xaml ?
484520
/// </summary>
485521
private void OnKeyDown(object sender, KeyEventArgs e)
486522
{
523+
var specialKeyState = GlobalHotkey.CheckModifiers();
487524
switch (e.Key)
488525
{
489526
case Key.Down:
@@ -518,8 +555,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
518555
e.Handled = true;
519556
}
520557
break;
558+
case Key.F12:
559+
if (specialKeyState.CtrlPressed)
560+
{
561+
ToggleGameMode();
562+
}
563+
break;
521564
case Key.Back:
522-
var specialKeyState = GlobalHotkey.CheckModifiers();
523565
if (specialKeyState.CtrlPressed)
524566
{
525567
if (_viewModel.SelectedIsFromQueryResults()

0 commit comments

Comments
 (0)