mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into localize-missing-python-js-dialog
This commit is contained in:
commit
8ccce077d0
11 changed files with 219 additions and 83 deletions
|
|
@ -54,8 +54,8 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Droplex" Version="1.7.0" />
|
<PackageReference Include="Droplex" Version="1.7.0" />
|
||||||
<PackageReference Include="FSharp.Core" Version="7.0.401" />
|
<PackageReference Include="FSharp.Core" Version="8.0.300" />
|
||||||
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.2.1" />
|
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.4.0" />
|
||||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
|
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
|
||||||
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
|
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
|
||||||
<PackageReference Include="StreamJsonRpc" Version="2.17.11" />
|
<PackageReference Include="StreamJsonRpc" Version="2.17.11" />
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
|
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
|
||||||
<PackageReference Include="BitFaster.Caching" Version="2.5.0" />
|
<PackageReference Include="BitFaster.Caching" Version="2.5.1" />
|
||||||
<PackageReference Include="Fody" Version="6.5.5">
|
<PackageReference Include="Fody" Version="6.5.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|
|
||||||
46
Flow.Launcher.Infrastructure/UserSettings/Point2D.cs
Normal file
46
Flow.Launcher.Infrastructure/UserSettings/Point2D.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Flow.Launcher.Infrastructure.UserSettings;
|
||||||
|
|
||||||
|
public record struct Point2D(double X, double Y)
|
||||||
|
{
|
||||||
|
public static implicit operator Point2D((double X, double Y) point)
|
||||||
|
{
|
||||||
|
return new Point2D(point.X, point.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point2D operator +(Point2D point1, Point2D point2)
|
||||||
|
{
|
||||||
|
return new Point2D(point1.X + point2.X, point1.Y + point2.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point2D operator -(Point2D point1, Point2D point2)
|
||||||
|
{
|
||||||
|
return new Point2D(point1.X - point2.X, point1.Y - point2.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point2D operator *(Point2D point, double scalar)
|
||||||
|
{
|
||||||
|
return new Point2D(point.X * scalar, point.Y * scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point2D operator /(Point2D point, double scalar)
|
||||||
|
{
|
||||||
|
return new Point2D(point.X / scalar, point.Y / scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point2D operator /(Point2D point1, Point2D point2)
|
||||||
|
{
|
||||||
|
return new Point2D(point1.X / point2.X, point1.Y / point2.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point2D operator *(Point2D point1, Point2D point2)
|
||||||
|
{
|
||||||
|
return new Point2D(point1.X * point2.X, point1.Y * point2.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D Clamp(Point2D min, Point2D max)
|
||||||
|
{
|
||||||
|
return new Point2D(Math.Clamp(X, min.X, max.X), Math.Clamp(Y, min.Y, max.Y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -205,8 +205,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
||||||
|
|
||||||
public bool AutoUpdates { get; set; } = false;
|
public bool AutoUpdates { get; set; } = false;
|
||||||
|
|
||||||
public double WindowLeft { get; set; }
|
|
||||||
public double WindowTop { get; set; }
|
public Point2D WindowPosition { get; set; }
|
||||||
|
public Point2D PreviousScreen { get; set; }
|
||||||
|
public Point2D PreviousDpi { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Custom left position on selected monitor
|
/// Custom left position on selected monitor
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,31 +1,34 @@
|
||||||
using Flow.Launcher.Core.Resource;
|
using Flow.Launcher.Core.Resource;
|
||||||
using Flow.Launcher.ViewModel;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using Flow.Launcher.SettingPages.ViewModels;
|
||||||
|
|
||||||
namespace Flow.Launcher
|
namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
public partial class CustomShortcutSetting : Window
|
public partial class CustomShortcutSetting : Window
|
||||||
{
|
{
|
||||||
|
private readonly SettingsPaneHotkeyViewModel _hotkeyVm;
|
||||||
public string Key { get; set; } = String.Empty;
|
public string Key { get; set; } = String.Empty;
|
||||||
public string Value { get; set; } = String.Empty;
|
public string Value { get; set; } = String.Empty;
|
||||||
private string originalKey { get; init; } = null;
|
private string originalKey { get; } = null;
|
||||||
private string originalValue { get; init; } = null;
|
private string originalValue { get; } = null;
|
||||||
private bool update { get; init; } = false;
|
private bool update { get; } = false;
|
||||||
|
|
||||||
public CustomShortcutSetting(SettingWindowViewModel vm)
|
public CustomShortcutSetting(SettingsPaneHotkeyViewModel vm)
|
||||||
{
|
{
|
||||||
|
_hotkeyVm = vm;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomShortcutSetting(string key, string value)
|
public CustomShortcutSetting(string key, string value, SettingsPaneHotkeyViewModel vm)
|
||||||
{
|
{
|
||||||
Key = key;
|
Key = key;
|
||||||
Value = value;
|
Value = value;
|
||||||
originalKey = key;
|
originalKey = key;
|
||||||
originalValue = value;
|
originalValue = value;
|
||||||
update = true;
|
update = true;
|
||||||
|
_hotkeyVm = vm;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +46,7 @@ namespace Flow.Launcher
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check if key is modified or adding a new one
|
// Check if key is modified or adding a new one
|
||||||
if ((update && originalKey != Key) || !update)
|
if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key))
|
||||||
{
|
{
|
||||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,7 @@ namespace Flow.Launcher
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatcherTimer timer = new DispatcherTimer
|
DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500), IsEnabled = false };
|
||||||
{
|
|
||||||
Interval = new TimeSpan(0, 0, 0, 0, 500),
|
|
||||||
IsEnabled = false
|
|
||||||
};
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
|
@ -87,6 +83,7 @@ namespace Flow.Launcher
|
||||||
private const int WM_EXITSIZEMOVE = 0x0232;
|
private const int WM_EXITSIZEMOVE = 0x0232;
|
||||||
private int _initialWidth;
|
private int _initialWidth;
|
||||||
private int _initialHeight;
|
private int _initialHeight;
|
||||||
|
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
{
|
{
|
||||||
if (msg == WM_ENTERSIZEMOVE)
|
if (msg == WM_ENTERSIZEMOVE)
|
||||||
|
|
@ -95,18 +92,22 @@ namespace Flow.Launcher
|
||||||
_initialHeight = (int)Height;
|
_initialHeight = (int)Height;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg == WM_EXITSIZEMOVE)
|
if (msg == WM_EXITSIZEMOVE)
|
||||||
{
|
{
|
||||||
if ( _initialHeight != (int)Height)
|
if (_initialHeight != (int)Height)
|
||||||
{
|
{
|
||||||
OnResizeEnd();
|
OnResizeEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_initialWidth != (int)Width)
|
if (_initialWidth != (int)Width)
|
||||||
{
|
{
|
||||||
FlowMainWindow.SizeToContent = SizeToContent.Height;
|
FlowMainWindow.SizeToContent = SizeToContent.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,6 +132,7 @@ namespace Flow.Launcher
|
||||||
_settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount));
|
_settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlowMainWindow.SizeToContent = SizeToContent.Height;
|
FlowMainWindow.SizeToContent = SizeToContent.Height;
|
||||||
_viewModel.MainWindowWidth = Width;
|
_viewModel.MainWindowWidth = Width;
|
||||||
}
|
}
|
||||||
|
|
@ -175,6 +177,7 @@ namespace Flow.Launcher
|
||||||
private void OnInitialized(object sender, EventArgs e)
|
private void OnInitialized(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoaded(object sender, RoutedEventArgs _)
|
private void OnLoaded(object sender, RoutedEventArgs _)
|
||||||
{
|
{
|
||||||
// MouseEventHandler
|
// MouseEventHandler
|
||||||
|
|
@ -206,6 +209,7 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
SoundPlay();
|
SoundPlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
PreviewReset();
|
PreviewReset();
|
||||||
Activate();
|
Activate();
|
||||||
|
|
@ -217,7 +221,8 @@ namespace Flow.Launcher
|
||||||
_viewModel.LastQuerySelected = true;
|
_viewModel.LastQuerySelected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_viewModel.ProgressBarVisibility == Visibility.Visible && isProgressBarStoryboardPaused)
|
if (_viewModel.ProgressBarVisibility == Visibility.Visible &&
|
||||||
|
isProgressBarStoryboardPaused)
|
||||||
{
|
{
|
||||||
_progressBarStoryboard.Begin(ProgressBar, true);
|
_progressBarStoryboard.Begin(ProgressBar, true);
|
||||||
isProgressBarStoryboardPaused = false;
|
isProgressBarStoryboardPaused = false;
|
||||||
|
|
@ -258,9 +263,12 @@ namespace Flow.Launcher
|
||||||
MoveQueryTextToEnd();
|
MoveQueryTextToEnd();
|
||||||
_viewModel.QueryTextCursorMovedToEnd = false;
|
_viewModel.QueryTextCursorMovedToEnd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case nameof(MainViewModel.GameModeStatus):
|
case nameof(MainViewModel.GameModeStatus):
|
||||||
_notifyIcon.Icon = _viewModel.GameModeStatus ? Properties.Resources.gamemode : Properties.Resources.app;
|
_notifyIcon.Icon = _viewModel.GameModeStatus
|
||||||
|
? Properties.Resources.gamemode
|
||||||
|
: Properties.Resources.app;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -278,11 +286,8 @@ namespace Flow.Launcher
|
||||||
case nameof(Settings.Hotkey):
|
case nameof(Settings.Hotkey):
|
||||||
UpdateNotifyIconText();
|
UpdateNotifyIconText();
|
||||||
break;
|
break;
|
||||||
case nameof(Settings.WindowLeft):
|
case nameof(Settings.WindowPosition):
|
||||||
Left = _settings.WindowLeft;
|
(Left, Top) = _settings.WindowPosition;
|
||||||
break;
|
|
||||||
case nameof(Settings.WindowTop):
|
|
||||||
Top = _settings.WindowTop;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -292,8 +297,24 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
|
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
|
||||||
{
|
{
|
||||||
Top = _settings.WindowTop;
|
var previousScreen = _settings.PreviousScreen;
|
||||||
Left = _settings.WindowLeft;
|
|
||||||
|
var previousDpi = _settings.PreviousDpi;
|
||||||
|
|
||||||
|
_settings.PreviousScreen = (SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
|
||||||
|
|
||||||
|
var currentDpi = GetDpi();
|
||||||
|
|
||||||
|
if (previousScreen == default ||
|
||||||
|
previousDpi == default ||
|
||||||
|
(previousScreen != (SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight) ||
|
||||||
|
previousDpi != currentDpi))
|
||||||
|
{
|
||||||
|
AdjustPositionForResolutionChange();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(Left, Top) = _settings.WindowPosition;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -306,34 +327,72 @@ namespace Flow.Launcher
|
||||||
break;
|
break;
|
||||||
case SearchWindowAligns.CenterTop:
|
case SearchWindowAligns.CenterTop:
|
||||||
Left = HorizonCenter(screen);
|
Left = HorizonCenter(screen);
|
||||||
Top = 10;
|
Top = VerticalTop(screen);
|
||||||
break;
|
break;
|
||||||
case SearchWindowAligns.LeftTop:
|
case SearchWindowAligns.LeftTop:
|
||||||
Left = HorizonLeft(screen);
|
Left = HorizonLeft(screen);
|
||||||
Top = 10;
|
Top = VerticalTop(screen);
|
||||||
break;
|
break;
|
||||||
case SearchWindowAligns.RightTop:
|
case SearchWindowAligns.RightTop:
|
||||||
Left = HorizonRight(screen);
|
Left = HorizonRight(screen);
|
||||||
Top = 10;
|
Top = VerticalTop(screen);
|
||||||
break;
|
break;
|
||||||
case SearchWindowAligns.Custom:
|
case SearchWindowAligns.Custom:
|
||||||
Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X;
|
var customLeft = WindowsInteropHelper.TransformPixelsToDIP(this,
|
||||||
Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y;
|
screen.WorkingArea.X + _settings.CustomWindowLeft, 0);
|
||||||
|
var customTop = WindowsInteropHelper.TransformPixelsToDIP(this, 0,
|
||||||
|
screen.WorkingArea.Y + _settings.CustomWindowTop);
|
||||||
|
Left = customLeft.X;
|
||||||
|
Top = customTop.Y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AdjustPositionForResolutionChange()
|
||||||
|
{
|
||||||
|
Point2D screenBound = (SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
|
||||||
|
|
||||||
|
var currentDpi = GetDpi();
|
||||||
|
|
||||||
|
var previousPosition = _settings.WindowPosition;
|
||||||
|
|
||||||
|
var ratio = screenBound / _settings.PreviousScreen;
|
||||||
|
|
||||||
|
var dpiRatio = currentDpi / _settings.PreviousDpi;
|
||||||
|
|
||||||
|
var newPosition = previousPosition * ratio * dpiRatio;
|
||||||
|
|
||||||
|
Point2D minPosition = (SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop);
|
||||||
|
|
||||||
|
var maxPosition = minPosition + screenBound - (ActualWidth, ActualHeight);
|
||||||
|
|
||||||
|
(Left, Top) = newPosition.Clamp(minPosition, maxPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point2D GetDpi()
|
||||||
|
{
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
Point2D point = (96, 96);
|
||||||
|
if (source is { CompositionTarget: not null })
|
||||||
|
{
|
||||||
|
Matrix m = source.CompositionTarget.TransformToDevice;
|
||||||
|
point.X = 96 * m.M11;
|
||||||
|
point.Y = 96 * m.M22;
|
||||||
|
}
|
||||||
|
|
||||||
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeNotifyIcon()
|
private void InitializeNotifyIcon()
|
||||||
|
|
@ -345,50 +404,34 @@ namespace Flow.Launcher
|
||||||
Visible = !_settings.HideNotifyIcon
|
Visible = !_settings.HideNotifyIcon
|
||||||
};
|
};
|
||||||
|
|
||||||
var openIcon = new FontIcon
|
var openIcon = new FontIcon { Glyph = "\ue71e" };
|
||||||
{
|
|
||||||
Glyph = "\ue71e"
|
|
||||||
};
|
|
||||||
var open = new MenuItem
|
var open = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")",
|
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" +
|
||||||
|
_settings.Hotkey + ")",
|
||||||
Icon = openIcon
|
Icon = openIcon
|
||||||
};
|
};
|
||||||
var gamemodeIcon = new FontIcon
|
var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" };
|
||||||
{
|
|
||||||
Glyph = "\ue7fc"
|
|
||||||
};
|
|
||||||
var gamemode = new MenuItem
|
var gamemode = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("GameMode"),
|
Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon
|
||||||
Icon = gamemodeIcon
|
|
||||||
};
|
|
||||||
var positionresetIcon = new FontIcon
|
|
||||||
{
|
|
||||||
Glyph = "\ue73f"
|
|
||||||
};
|
};
|
||||||
|
var positionresetIcon = new FontIcon { Glyph = "\ue73f" };
|
||||||
var positionreset = new MenuItem
|
var positionreset = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("PositionReset"),
|
Header = InternationalizationManager.Instance.GetTranslation("PositionReset"),
|
||||||
Icon = positionresetIcon
|
Icon = positionresetIcon
|
||||||
};
|
};
|
||||||
var settingsIcon = new FontIcon
|
var settingsIcon = new FontIcon { Glyph = "\ue713" };
|
||||||
{
|
|
||||||
Glyph = "\ue713"
|
|
||||||
};
|
|
||||||
var settings = new MenuItem
|
var settings = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"),
|
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"),
|
||||||
Icon = settingsIcon
|
Icon = settingsIcon
|
||||||
};
|
};
|
||||||
var exitIcon = new FontIcon
|
var exitIcon = new FontIcon { Glyph = "\ue7e8" };
|
||||||
{
|
|
||||||
Glyph = "\ue7e8"
|
|
||||||
};
|
|
||||||
var exit = new MenuItem
|
var exit = new MenuItem
|
||||||
{
|
{
|
||||||
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"),
|
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon
|
||||||
Icon = exitIcon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
|
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
|
||||||
|
|
@ -421,6 +464,7 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
_ = SetForegroundWindow(hwndSource.Handle);
|
_ = SetForegroundWindow(hwndSource.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMenu.Focus();
|
contextMenu.Focus();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -454,8 +498,10 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private void InitProgressbarAnimation()
|
private void InitProgressbarAnimation()
|
||||||
{
|
{
|
||||||
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
|
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100,
|
||||||
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 0, 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 + 0,
|
||||||
|
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)"));
|
||||||
_progressBarStoryboard.Children.Add(da);
|
_progressBarStoryboard.Children.Add(da);
|
||||||
|
|
@ -557,14 +603,14 @@ namespace Flow.Launcher
|
||||||
iconsb.Children.Add(IconOpacity);
|
iconsb.Children.Add(IconOpacity);
|
||||||
|
|
||||||
windowsb.Completed += (_, _) => _animating = false;
|
windowsb.Completed += (_, _) => _animating = false;
|
||||||
_settings.WindowLeft = Left;
|
_settings.WindowPosition = (Left, Top);
|
||||||
_settings.WindowTop = Top;
|
|
||||||
isArrowKeyPressed = false;
|
isArrowKeyPressed = false;
|
||||||
|
|
||||||
if (QueryTextBox.Text.Length == 0)
|
if (QueryTextBox.Text.Length == 0)
|
||||||
{
|
{
|
||||||
clocksb.Begin(ClockPanel);
|
clocksb.Begin(ClockPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
iconsb.Begin(SearchIcon);
|
iconsb.Begin(SearchIcon);
|
||||||
windowsb.Begin(FlowMainWindow);
|
windowsb.Begin(FlowMainWindow);
|
||||||
}
|
}
|
||||||
|
|
@ -618,8 +664,7 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private async void OnDeactivated(object sender, EventArgs e)
|
private async void OnDeactivated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_settings.WindowLeft = Left;
|
_settings.WindowPosition = (Left, Top);
|
||||||
_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)
|
||||||
|
|
@ -650,8 +695,7 @@ namespace Flow.Launcher
|
||||||
return;
|
return;
|
||||||
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
|
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
|
||||||
{
|
{
|
||||||
_settings.WindowLeft = Left;
|
_settings.WindowPosition = (Left, Top);
|
||||||
_settings.WindowTop = Top;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -671,7 +715,7 @@ namespace Flow.Launcher
|
||||||
public Screen SelectedScreen()
|
public Screen SelectedScreen()
|
||||||
{
|
{
|
||||||
Screen screen = null;
|
Screen screen = null;
|
||||||
switch(_settings.SearchWindowScreen)
|
switch (_settings.SearchWindowScreen)
|
||||||
{
|
{
|
||||||
case SearchWindowScreens.Cursor:
|
case SearchWindowScreens.Cursor:
|
||||||
screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||||
|
|
@ -693,6 +737,7 @@ namespace Flow.Launcher
|
||||||
screen = Screen.AllScreens[0];
|
screen = Screen.AllScreens[0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return screen ?? Screen.AllScreens[0];
|
return screen ?? Screen.AllScreens[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -727,6 +772,13 @@ namespace Flow.Launcher
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double VerticalTop(Screen screen)
|
||||||
|
{
|
||||||
|
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||||
|
var top = dip1.Y + 10;
|
||||||
|
return top;
|
||||||
|
}
|
||||||
|
|
||||||
/// <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 ?
|
||||||
|
|
@ -762,6 +814,7 @@ namespace Flow.Launcher
|
||||||
_viewModel.LoadContextMenuCommand.Execute(null);
|
_viewModel.LoadContextMenuCommand.Execute(null);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Key.Left:
|
case Key.Left:
|
||||||
if (!_viewModel.SelectedIsFromQueryResults() && QueryTextBox.CaretIndex == 0)
|
if (!_viewModel.SelectedIsFromQueryResults() && QueryTextBox.CaretIndex == 0)
|
||||||
|
|
@ -769,6 +822,7 @@ namespace Flow.Launcher
|
||||||
_viewModel.EscCommand.Execute(null);
|
_viewModel.EscCommand.Execute(null);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Key.Back:
|
case Key.Back:
|
||||||
if (specialKeyState.CtrlPressed)
|
if (specialKeyState.CtrlPressed)
|
||||||
|
|
@ -787,12 +841,13 @@ namespace Flow.Launcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnKeyUp(object sender, KeyEventArgs e)
|
private void OnKeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Up || e.Key == Key.Down)
|
if (e.Key == Key.Up || e.Key == Key.Down)
|
||||||
|
|
@ -808,6 +863,7 @@ namespace Flow.Launcher
|
||||||
e.Handled = true; // Ignore Mouse Hover when press Arrowkeys
|
e.Handled = true; // Ignore Mouse Hover when press Arrowkeys
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreviewReset()
|
public void PreviewReset()
|
||||||
{
|
{
|
||||||
_viewModel.ResetPreview();
|
_viewModel.ResetPreview();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Windows;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Flow.Launcher.Core.Resource;
|
using Flow.Launcher.Core.Resource;
|
||||||
using Flow.Launcher.Helper;
|
using Flow.Launcher.Helper;
|
||||||
|
|
@ -114,7 +115,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var window = new CustomShortcutSetting(item.Key, item.Value);
|
var window = new CustomShortcutSetting(item.Key, item.Value, this);
|
||||||
if (window.ShowDialog() is not true) return;
|
if (window.ShowDialog() is not true) return;
|
||||||
|
|
||||||
var index = Settings.CustomShortcuts.IndexOf(item);
|
var index = Settings.CustomShortcuts.IndexOf(item);
|
||||||
|
|
@ -124,11 +125,17 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void CustomShortcutAdd()
|
private void CustomShortcutAdd()
|
||||||
{
|
{
|
||||||
var window = new CustomShortcutSetting(null);
|
var window = new CustomShortcutSetting(this);
|
||||||
if (window.ShowDialog() is true)
|
if (window.ShowDialog() is true)
|
||||||
{
|
{
|
||||||
var shortcut = new CustomShortcutModel(window.Key, window.Value);
|
var shortcut = new CustomShortcutModel(window.Key, window.Value);
|
||||||
Settings.CustomShortcuts.Add(shortcut);
|
Settings.CustomShortcuts.Add(shortcut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal bool DoesShortcutExist(string key)
|
||||||
|
{
|
||||||
|
return Settings.CustomShortcuts.Any(v => v.Key == key) ||
|
||||||
|
Settings.BuiltinShortcuts.Any(v => v.Key == key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,23 +112,45 @@ public partial class SettingWindow
|
||||||
{
|
{
|
||||||
if (_settings.SettingWindowTop == null || _settings.SettingWindowLeft == null)
|
if (_settings.SettingWindowTop == null || _settings.SettingWindowLeft == null)
|
||||||
{
|
{
|
||||||
Top = WindowTop();
|
SetWindowPosition(WindowTop(), WindowLeft());
|
||||||
Left = WindowLeft();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Top = _settings.SettingWindowTop.Value;
|
double left = _settings.SettingWindowLeft.Value;
|
||||||
Left = _settings.SettingWindowLeft.Value;
|
double top = _settings.SettingWindowTop.Value;
|
||||||
|
AdjustWindowPosition(ref top, ref left);
|
||||||
|
SetWindowPosition(top, left);
|
||||||
}
|
}
|
||||||
WindowState = _settings.SettingWindowState;
|
WindowState = _settings.SettingWindowState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetWindowPosition(double top, double left)
|
||||||
|
{
|
||||||
|
// Ensure window does not exceed screen boundaries
|
||||||
|
top = Math.Max(top, SystemParameters.VirtualScreenTop);
|
||||||
|
left = Math.Max(left, SystemParameters.VirtualScreenLeft);
|
||||||
|
top = Math.Min(top, SystemParameters.VirtualScreenHeight - ActualHeight);
|
||||||
|
left = Math.Min(left, SystemParameters.VirtualScreenWidth - ActualWidth);
|
||||||
|
|
||||||
|
Top = top;
|
||||||
|
Left = left;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AdjustWindowPosition(ref double top, ref double left)
|
||||||
|
{
|
||||||
|
// Adjust window position if it exceeds screen boundaries
|
||||||
|
top = Math.Max(top, SystemParameters.VirtualScreenTop);
|
||||||
|
left = Math.Max(left, SystemParameters.VirtualScreenLeft);
|
||||||
|
top = Math.Min(top, SystemParameters.VirtualScreenHeight - ActualHeight);
|
||||||
|
left = Math.Min(left, SystemParameters.VirtualScreenWidth - ActualWidth);
|
||||||
|
}
|
||||||
|
|
||||||
private double WindowLeft()
|
private double WindowLeft()
|
||||||
{
|
{
|
||||||
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);
|
||||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||||
var left = (dip2.X - this.ActualWidth) / 2 + dip1.X;
|
var left = (dip2.X - ActualWidth) / 2 + dip1.X;
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,7 +159,7 @@ public partial class SettingWindow
|
||||||
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);
|
||||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
||||||
var top = (dip2.Y - this.ActualHeight) / 2 + dip1.Y - 20;
|
var top = (dip2.Y - ActualHeight) / 2 + dip1.Y;
|
||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -547,20 +547,20 @@ namespace Flow.Launcher.ViewModel
|
||||||
private void IncreaseWidth()
|
private void IncreaseWidth()
|
||||||
{
|
{
|
||||||
Settings.WindowSize += 100;
|
Settings.WindowSize += 100;
|
||||||
Settings.WindowLeft -= 50;
|
Settings.WindowPosition -= (50, 0);
|
||||||
OnPropertyChanged(nameof(MainWindowWidth));
|
OnPropertyChanged(nameof(MainWindowWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void DecreaseWidth()
|
private void DecreaseWidth()
|
||||||
{
|
{
|
||||||
if (MainWindowWidth - 100 < 400 || Settings.WindowSize == 400)
|
if (MainWindowWidth - 100 < 400 || Math.Abs(Settings.WindowSize - 400) < 0.01)
|
||||||
{
|
{
|
||||||
Settings.WindowSize = 400;
|
Settings.WindowSize = 400;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Settings.WindowLeft += 50;
|
Settings.WindowPosition += (50, 0);
|
||||||
Settings.WindowSize -= 100;
|
Settings.WindowSize -= 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.3" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue