From fcbf97275406c9775149be25a8c68c606871f6e3 Mon Sep 17 00:00:00 2001 From: pc223 <10551242+pc223@users.noreply.github.com> Date: Tue, 13 Jul 2021 03:44:28 +0700 Subject: [PATCH 0001/1836] Testing new search order: System.Search.Rank --- .../Search/WindowsIndex/QueryConstructor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs index 20e85bbb5..808f8e7e3 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs @@ -114,7 +114,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex /// public const string QueryWhereRestrictionsForAllFilesAndFoldersSearch = "scope='file:'"; - public const string QueryOrderByFileNameRestriction = " ORDER BY System.FileName"; + public const string QueryOrderByFileNameRestriction = " ORDER BY System.Search.Rank"; /// From 5d3b0ba2c06ceeea0f9f6cae668068bef0e7763a Mon Sep 17 00:00:00 2001 From: pc223 <10551242+pc223@users.noreply.github.com> Date: Tue, 13 Jul 2021 04:12:09 +0700 Subject: [PATCH 0002/1836] Should be DESC --- .../Search/WindowsIndex/QueryConstructor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs index 808f8e7e3..c42a60193 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs @@ -114,7 +114,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex /// public const string QueryWhereRestrictionsForAllFilesAndFoldersSearch = "scope='file:'"; - public const string QueryOrderByFileNameRestriction = " ORDER BY System.Search.Rank"; + public const string QueryOrderByFileNameRestriction = " ORDER BY System.Search.Rank DESC"; /// From bfee170d0fbeba908d9f228771af7a08351e7a10 Mon Sep 17 00:00:00 2001 From: Sparrkle Date: Wed, 5 Oct 2022 16:20:41 +0900 Subject: [PATCH 0003/1836] Changed ProgressBar Storyboard (No Dispatcher) --- Flow.Launcher/MainWindow.xaml | 1 - Flow.Launcher/MainWindow.xaml.cs | 60 +++++++++++--------------------- 2 files changed, 21 insertions(+), 40 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index dc3b3f145..7d8c195f3 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -250,7 +250,6 @@ Height="2" HorizontalAlignment="Right" StrokeThickness="1" - Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" X1="-150" X2="-50" diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 332e0f502..1dd9fe34d 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -28,9 +28,6 @@ namespace Flow.Launcher public partial class MainWindow { #region Private Fields - - private readonly Storyboard _progressBarStoryboard = new Storyboard(); - private bool isProgressBarStoryboardPaused; private Settings _settings; private NotifyIcon _notifyIcon; private ContextMenu contextMenu; @@ -119,39 +116,9 @@ namespace Flow.Launcher _viewModel.LastQuerySelected = true; } - if (_viewModel.ProgressBarVisibility == Visibility.Visible && isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Begin(ProgressBar, true); - isProgressBarStoryboardPaused = false; - } - if(_settings.UseAnimation) WindowAnimator(); } - else if (!isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Stop(ProgressBar); - isProgressBarStoryboardPaused = true; - } - - break; - } - case nameof(MainViewModel.ProgressBarVisibility): - { - Dispatcher.Invoke(() => - { - if (_viewModel.ProgressBarVisibility == Visibility.Hidden && !isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Stop(ProgressBar); - isProgressBarStoryboardPaused = true; - } - else if (_viewModel.MainWindowVisibilityStatus && - isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Begin(ProgressBar, true); - isProgressBarStoryboardPaused = false; - } - }); break; } case nameof(MainViewModel.QueryTextCursorMovedToEnd): @@ -291,17 +258,32 @@ namespace Flow.Launcher } private void InitProgressbarAnimation() { - var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150, - new Duration(new TimeSpan(0, 0, 0, 0, 1600))); + var progressBarStoryBoard = new Storyboard(); + + var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150, 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(da1, new PropertyPath("(Line.X1)")); - _progressBarStoryboard.Children.Add(da); - _progressBarStoryboard.Children.Add(da1); - _progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever; + progressBarStoryBoard.Children.Add(da); + progressBarStoryBoard.Children.Add(da1); + progressBarStoryBoard.RepeatBehavior = RepeatBehavior.Forever; + + da.Freeze(); + da1.Freeze(); + + var beginStoryboard = new BeginStoryboard(); + beginStoryboard.Storyboard = progressBarStoryBoard; + + var trigger = new Trigger { Property = System.Windows.Shapes.Line.VisibilityProperty, Value = Visibility.Visible }; + trigger.EnterActions.Add(beginStoryboard); + + var progressStyle = new Style(typeof(System.Windows.Shapes.Line)); + progressStyle.BasedOn = FindResource("PendingLineStyle") as Style; + progressStyle.Triggers.Add(trigger); + + ProgressBar.Style = progressStyle; _viewModel.ProgressBarVisibility = Visibility.Hidden; - isProgressBarStoryboardPaused = true; } public void WindowAnimator() { From 6f0c2549cea809b0a1e406951f734daf4fb8cc0d Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 24 Nov 2022 14:01:32 -0600 Subject: [PATCH 0004/1836] also pause animation when exit visible --- Flow.Launcher/MainWindow.xaml.cs | 151 ++++++++++++++++++------------- 1 file changed, 89 insertions(+), 62 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 245ab4d05..efa43000b 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -36,6 +36,7 @@ namespace Flow.Launcher public partial class MainWindow { #region Private Fields + private Settings _settings; private NotifyIcon _notifyIcon; private ContextMenu contextMenu; @@ -50,7 +51,7 @@ namespace Flow.Launcher DataContext = mainVM; _viewModel = mainVM; _settings = settings; - + InitializeComponent(); InitializePosition(); animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); @@ -60,7 +61,7 @@ namespace Flow.Launcher { InitializeComponent(); } - + private void OnCopy(object sender, ExecutedRoutedEventArgs e) { if (QueryTextBox.SelectionLength == 0) @@ -108,29 +109,29 @@ namespace Flow.Launcher switch (e.PropertyName) { case nameof(MainViewModel.MainWindowVisibilityStatus): + { + if (_viewModel.MainWindowVisibilityStatus) { - if (_viewModel.MainWindowVisibilityStatus) + if (_settings.UseSound) { - if (_settings.UseSound) - { - animationSound.Position = TimeSpan.Zero; - animationSound.Play(); - } - UpdatePosition(); - Activate(); - QueryTextBox.Focus(); - _settings.ActivateTimes++; - if (!_viewModel.LastQuerySelected) - { - QueryTextBox.SelectAll(); - _viewModel.LastQuerySelected = true; - } - - if(_settings.UseAnimation) - WindowAnimator(); + animationSound.Position = TimeSpan.Zero; + animationSound.Play(); } - break; + UpdatePosition(); + Activate(); + QueryTextBox.Focus(); + _settings.ActivateTimes++; + if (!_viewModel.LastQuerySelected) + { + QueryTextBox.SelectAll(); + _viewModel.LastQuerySelected = true; + } + + if (_settings.UseAnimation) + WindowAnimator(); } + break; + } case nameof(MainViewModel.QueryTextCursorMovedToEnd): if (_viewModel.QueryTextCursorMovedToEnd) { @@ -211,35 +212,45 @@ namespace Flow.Launcher Visible = !_settings.HideNotifyIcon }; contextMenu = new ContextMenu(); - var openIcon = new FontIcon { Glyph = "\ue71e" }; + var openIcon = new FontIcon + { + Glyph = "\ue71e" + }; 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 + { + Glyph = "\ue7fc" }; - var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" }; var gamemode = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("GameMode"), - Icon = gamemodeIcon + Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon + }; + var positionresetIcon = new FontIcon + { + Glyph = "\ue73f" }; - var positionresetIcon = new FontIcon { Glyph = "\ue73f" }; var positionreset = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), - Icon = positionresetIcon + Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), Icon = positionresetIcon + }; + var settingsIcon = new FontIcon + { + Glyph = "\ue713" }; - var settingsIcon = new FontIcon { Glyph = "\ue713" }; var settings = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"), - Icon = settingsIcon + Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"), Icon = settingsIcon + }; + var exitIcon = new FontIcon + { + Glyph = "\ue7e8" }; - var exitIcon = new FontIcon { Glyph = "\ue7e8" }; var exit = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), - Icon = exitIcon + Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon }; open.Click += (o, e) => _viewModel.ToggleFlowLauncher(); @@ -300,10 +311,10 @@ namespace Flow.Launcher } private async void PositionReset() { - _viewModel.Show(); - await Task.Delay(300); // If don't give a time, Positioning will be weird. - Left = HorizonCenter(); - Top = VerticalCenter(); + _viewModel.Show(); + await Task.Delay(300); // If don't give a time, Positioning will be weird. + Left = HorizonCenter(); + Top = VerticalCenter(); } private void InitProgressbarAnimation() { @@ -320,14 +331,30 @@ namespace Flow.Launcher da.Freeze(); da1.Freeze(); - var beginStoryboard = new BeginStoryboard(); - beginStoryboard.Storyboard = progressBarStoryBoard; + const string progressBarAnimationName = "ProgressBarAnimation"; + var beginStoryboard = new BeginStoryboard + { + Name = progressBarAnimationName, Storyboard = progressBarStoryBoard + }; + + var stopStoryboard = new StopStoryboard() + { + BeginStoryboardName = progressBarAnimationName + }; - var trigger = new Trigger { Property = System.Windows.Shapes.Line.VisibilityProperty, Value = Visibility.Visible }; + var trigger = new Trigger + { + Property = VisibilityProperty, Value = Visibility.Visible + }; trigger.EnterActions.Add(beginStoryboard); + trigger.ExitActions.Add(stopStoryboard); - var progressStyle = new Style(typeof(System.Windows.Shapes.Line)); - progressStyle.BasedOn = FindResource("PendingLineStyle") as Style; + + var progressStyle = new Style(typeof(System.Windows.Shapes.Line)) + { + BasedOn = FindResource("PendingLineStyle") as Style + }; + progressStyle.RegisterName(progressBarAnimationName, beginStoryboard); progressStyle.Triggers.Add(trigger); ProgressBar.Style = progressStyle; @@ -343,7 +370,7 @@ namespace Flow.Launcher UpdatePosition(); Storyboard sb = new Storyboard(); Storyboard iconsb = new Storyboard(); - CircleEase easing = new CircleEase(); // or whatever easing class you want + CircleEase easing = new CircleEase(); // or whatever easing class you want easing.EasingMode = EasingMode.EaseInOut; var da = new DoubleAnimation { @@ -360,14 +387,14 @@ namespace Flow.Launcher Duration = TimeSpan.FromSeconds(0.25), FillBehavior = FillBehavior.Stop }; - var da3 = new DoubleAnimation - { - From = 12, - To = 0, - EasingFunction = easing, - Duration = TimeSpan.FromSeconds(0.36), - FillBehavior = FillBehavior.Stop - }; + var da3 = new DoubleAnimation + { + From = 12, + To = 0, + EasingFunction = easing, + Duration = TimeSpan.FromSeconds(0.36), + FillBehavior = FillBehavior.Stop + }; Storyboard.SetTarget(da, this); Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty)); Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty)); @@ -395,10 +422,10 @@ namespace Flow.Launcher private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e) { _viewModel.Hide(); - - if(_settings.UseAnimation) + + if (_settings.UseAnimation) await Task.Delay(100); - + App.API.OpenSettingDialog(); } @@ -416,7 +443,7 @@ namespace Flow.Launcher // and always after Settings window is closed. if (_settings.UseAnimation) await Task.Delay(100); - + if (_settings.HideWhenDeactive) { _viewModel.Hide(); @@ -454,7 +481,7 @@ namespace Flow.Launcher _viewModel.Show(); } } - + public double HorizonCenter() { var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); @@ -536,9 +563,9 @@ namespace Flow.Launcher && QueryTextBox.Text.Length > 0 && QueryTextBox.CaretIndex == QueryTextBox.Text.Length) { - var queryWithoutActionKeyword = + var queryWithoutActionKeyword = QueryBuilder.Build(QueryTextBox.Text.Trim(), PluginManager.NonGlobalPlugins).Search; - + if (FilesFolders.IsLocationPathString(queryWithoutActionKeyword)) { _viewModel.BackspaceCommand.Execute(null); @@ -574,7 +601,7 @@ namespace Flow.Launcher private void QueryTextBox_KeyUp(object sender, KeyEventArgs e) { - if(_viewModel.QueryText != QueryTextBox.Text) + if (_viewModel.QueryText != QueryTextBox.Text) { BindingExpression be = QueryTextBox.GetBindingExpression(System.Windows.Controls.TextBox.TextProperty); be.UpdateSource(); From 1b31e9c9685abd0d1d556d260425fac4b5aff165 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Thu, 30 Nov 2023 14:37:05 +0000 Subject: [PATCH 0005/1836] Create Flow Launcher Theme Selector plugin --- ...w.Launcher.Plugin.FlowThemeSelector.csproj | 37 +++++++ .../Main.cs | 91 ++++++++++++++++++ .../icon.png | Bin 0 -> 6625 bytes .../plugin.json | 12 +++ 4 files changed, 140 insertions(+) create mode 100644 Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj create mode 100644 Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Main.cs create mode 100644 Plugins/Flow.Launcher.Plugin.FlowThemeSelector/icon.png create mode 100644 Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj new file mode 100644 index 000000000..ba0ddd6ab --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj @@ -0,0 +1,37 @@ + + + + + Library + net7.0-windows + true + false + + + + ..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.FlowThemeSelector + + + + ..\..\Output\Release\Plugins\Flow.Launcher.Plugin.FlowThemeSelector + + + + + + + + + + + PreserveNewest + + + + + + PreserveNewest + + + + diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Main.cs b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Main.cs new file mode 100644 index 000000000..6fd6472db --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Main.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Flow.Launcher.Core.Resource; + +namespace Flow.Launcher.Plugin.FlowThemeSelector +{ + public class FlowThemeSelector : IPlugin, IReloadable, IDisposable + { + private PluginInitContext context; + private IEnumerable themes; + + public void Init(PluginInitContext context) + { + this.context = context; + context.API.VisibilityChanged += OnVisibilityChanged; + } + + public List Query(Query query) + { + if (query.IsReQuery) + { + LoadThemes(); + } + + if (string.IsNullOrWhiteSpace(query.Search)) + { + return themes.Select(CreateThemeResult) + .OrderBy(x => x.Title) + .ToList(); + } + + return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(query.Search, theme))) + .Where(x => x.matchResult.IsSearchPrecisionScoreMet()) + .Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData)) + .OrderBy(x => x.Title) + .ToList(); + } + + private void OnVisibilityChanged(object sender, VisibilityChangedEventArgs args) + { + if (args.IsVisible && !context.CurrentPluginMetadata.Disabled) + { + LoadThemes(); + } + } + + public void LoadThemes() => themes = ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension); + + public static Result CreateThemeResult(string theme) => CreateThemeResult(theme, 0, null); + + public static Result CreateThemeResult(string theme, int score, IList highlightData) + { + string title; + if (theme == ThemeManager.Instance.Settings.Theme) + { + title = $"{theme} ★"; + score = 2000; + } + else + { + title = theme; + } + + return new Result + { + Title = title, + TitleHighlightData = highlightData, + Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue790"), + Score = score, + Action = c => + { + ThemeManager.Instance.ChangeTheme(theme); + return true; + } + }; + } + + public void ReloadData() => LoadThemes(); + + public void Dispose() + { + if (context != null && context.API != null) + { + context.API.VisibilityChanged -= OnVisibilityChanged; + } + } + + } +} diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/icon.png b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..704e9474eb29ffa1fcaeff9e24c60ee35155afd5 GIT binary patch literal 6625 zcmV<786M_|P)?L~#_W&dT5+Df~tR%E=9kt)zb>9h)AYqsw`j&HD=X&5T zo_x;9xxe?h&+}kl&}CiLWnI=~UDjn?)@5DRWnK1+nBx`2yKb4XkC_>=6)stFZLT1&5Y;r?b&_2|)x3Z7H-nk27~+~O4{^jFQ6z?V_@jHd8Y)Ztgd zAyMTCRj|KUDX@>PUTc*idEMZjU{-l}$t_2|z%@sHoj|YmPJvGYPzAgAO4!Cpg|=~( zvkidf4E|TmHCH~yHAlgAV>N=;8~pSZ;3sQ`UmpOwI1+?P*v3lIY~n?I4E~qQ?ULNw zEvGJug70wnwavnJY!iGbb?az}+$Kgk!{Avr$18Zzja9eDm8E#l;qdDN&>Z}v7U0L% z!&e5tCPwAa5?Duz_dK&D$u;Z0rtYk|EH_pi9v8l6t`J_Of!JC7CBBv~#whgirZXG4yg=vvTth_=(NKS1&!y!Y3XnCP6rBumjH< zJoN@V@0P3h#XYwU?Sh}J8GvbdsW|e$3ju#E!;$+-;r-_#?5&&M5P+59iC82Yi`iu( zF@zP}Dtw1F!j0o8{&s@M9l^Z(R>RQUyPpxCoY^qE8K; zMjMhMdEK3*h|?85GgF3n>=W3nn1>&JUx0moETpC9JHY_6V; zbKXJ(eqW=4zeG3=^UFuk>>pn|6vNqrF*xr-IK+#!YJI1WDhxjQCx#rqPp|Gi zaxj0Yg!67;V*u9PhQ*4ju<|R?4*x<0EQp5)S9dmhgQ-Dy!HrcHqA&PNqU}?pSSp-> zRpLolEtyQq4Y`s<*Gn`Wi-lt`pFavSN{3@o$%h!l@x+IBJm7w7C>-KN6ns!ztik@-CqO74-zt z2VqdYE1a)Rhkcv~4i}}Gax+c}hhr6R*(U|_=W4kAQUm7CRdCrSq1o^7RVi$@7GdCq z0$6^217=Gv;r)e~=>PQ%ScO&8*L_%qs>2sjHwzMM?==4Ith&_{ewzazZ+(|b0+1}l zh-*HyzRxQsK8ix0Q#JxKONV1BZx|+&e2CE;CH%n!Zg9EHfL;0zu#c;NJqduC+_a4q z!{LW=IDIFC^Ij1cdqr^GBZAX+0yyj{gWZ?KH2dqzPyfX%^qrrMK1(xTbwSVopJsnZ z1uW{}2h#w^tb#hBgUY-tW4N;v_gaEKI=2MJZ)`;2EnC#xcoTJ3-bMk-3CFTFV`NrI z^8v`Hr2%kBW@A$ESWMv#qrk~^GWR12eoWB^7{MNb4+}joINue_+YH!W8wA_feAvfU zz@8`_^<8dM1?+Z|&^k|m*Sq}=9_+Ri!-l|Lmj}yL*Ol4-Nf!FdNkOmKiLg9h-Yk4` zC486#3efLd`NAg(-y=izANSlkUQ6(|T|0r_xo_ZM(erp%@B;q2^)LK&^(8#WeHjn3 zUV$vN8#bk#YPQG2NU4N#f*5WYAsAis0mc-0(o!>uGlVX-9~BOQXMsCB@|a-UV!-}} z6KoRB!7fSwyI7H?)+hQtN(k%CcjzKZN{!Mv^mprx1vK*sd~>hM=(i{vedndYbVeeK zr^Uk}xD1vdLM8l=Ch&s<=uZQ{Pk*8TaAVa)wgi9ce zqxY;Nm`sU>@qz?c1eL+!yg)1b{^$7Ucc%RB_k+s&JsJ3y>gKdqcCw35m;V+X7QUc# zlKr>;g}<)9hzFNn!h@Wb@gU%+zJpEFE!aht!!}w7yBHBIKN`E-7%>fiD6NSRhsqvm$1<9(<~MIWb~RE52Fdu=)E}`<}?8OM)<)^;1fT~N8dB0t2!J$ zGh6nKd#*yFb-~S+coZFE(a>_A9ub{wnS#{~Px%zJ_}-ufs2H3z=rn zY%Ql$!-;IFE{fq0Cxm@;Iqaj#U>C`QT?Fw`*hZAm%x{D*eYCG1BY|~<00RPf=%EvOx4 zRxJuI+2OBiFVc*sPJX`f5*}Q7xiR}wU&Z~z*KjZHb=-@31GgfXwCp@`sFGX_rvwQc zFN)wm7S~t->|>N}7cEfMd{TDQ;m2zps*wJUb%YQDLd#&`ork^)(rKnsl`}7mF1DoP z^qQUklgY6#8Xtw8W5Up9_hp!$<-#nmtX25$pDst=)8(}tx-)jqQFyrLDE@9qYBJNS zpY`(8g4pR~<;Xu9#WRn#yqFSG* z9kSq(n%_`%wDk3@BP%d4jE?~!r7-*H7EI?P(?ym*C*{VNfG1f$HUd4zN1)HQmtc0L z1ZHP>Fb^u%gdf-hKFNL(fKz2KJ;k%@umHHR>QYFB~YE8?BDzv3s35Nut^DEol*N+loV3+^{E|kM6mP9P5Mgx$a z>WKSkuPW<&y%X?c(M@UsKm1MH4S5Te(DZ+qIJ_ejGgJm!e zmgkCLd6ol2C}ox2y_qVOvNjqzb@K3#0dH=sQ;Jk3oqw0fvQ`#J(xhLqD?F4<@it#3}D z6EBCk3Vc)e{Z#PZZw7wv6Q$_&YiYLL1K^gUNNj6^jg%lpvKSlVkK=Ci8%p5h8uf+} zeE6HV8>%cjcZ1%-f6x5~Yr_NJ7%!sVfVRTdHb&C0=xV@kp|5|T0+t~HJ4P zY!k(Es;sf}sNkCt|CO7sSNJYD^8Ri)^1s{K-E_&Q0V7okMv@pCV~(Rbyr(kTX~wI- z2fu|s1K&pFITNf6I}XRV3gw0?sZysIo_536?CZC>(Q1^NP2krD;8z|@j`Pa&8UR<8 z!n<9qWztTd-vS93i6RV(y9wWjjktN9iJG9Es1EFjn}M!46tW3Jqi-sAxfjK7Ops8y z*=G3hEx>PBbekNex7gQjEBtb;@J$1F=oP@N*6%4-jzZS%zCPK}rYcL3bD{`N@d7x- z@!=F#4#(Jf=fg3+g2E@Y-zm9DPXkn~!`Ir^4;H}g6d&{Ulwj-n0_^_mI=)_f32Rs8 zV)D)#unOR*DV`?qezm%=Hz zQmyQC&LAG~ufPVB}v?q?Z7= z=g3F41b;+=2;RG6knyQEIOBJsaO`#@&-)4cc7RJf6SLCAGH;wBQ}Hk@fRrmXajDK+>8~zSseo3Ru{S1 z+= ze6$3HM@o|Q6aYnbbMV*t=Rz=kCxtH+N9)8+~hiqVZ30v2|WDRXL>8)H_*px6e+*wpsB?_|qb=e#!-`nHYps z<43Xew?+)NpM{yH3Gqqb7$#7XAY!>=ztMIWvM z`-3$o9I_e(gI3|&Z9&RKSC0=%42+h94UCWuv56PGMtne|$kQrZ9PtQzEn2@}qjk0n z@1Npg`I2M``pa1fD!)j7-#RlEo2N%Nz+XEl2%k?lgB4?c!^~NMF!mz>D560i@C^?a z!{~6yXq^M#mZ@0WT#F%f?vJ$At9w2Cl3@gXWA@(}{5kRmtwi*cui>Q8VyJ1m)^Bd3 z6(#vX+kIPxi?_6<^)*_{BmgJ57`Hi#)^`GX^NeVE-84Olg5Nkb4C^O{(7I3Ik2?vk zF##C5Iu=HLg)lx+1fwI30qEg-r?<`laLrPD|40DRs!%XyD}~J+u5t=~BZ}4FlkC4U zjDm&7iy19~dnOYwg}GLn|U%n&Hvt>ywu9ZzZtw%g34-;n*-Wi~`>< zg?K0hzjjhER!=;KRpXVJPvCzt{y6&laves#g)kynuYzyrTcps-V@%9!d6fzJUGk6v9Jys&meK~SHS1a2M+D67Nwtb^T%1&$dZXPE3 zK&#?uoZ)Hc>-Rm$MV|l;+`eI9&Ez0jW=OWLnHWeHTLOONxKmg@_5{2}AIFkWN8zwF z1xAPRVd%$hgzs03o`*QmI>T25;D*LVD}(fQDv>aAFN%h)qrj;Ttp~prY)=CJb0z#i zO8B?jmLYP&PGz$#u~KKPZ`FqJKl8B4H(G+|WF68Y8`0*;-Bz!Rx04Tpqec1zioi3VzPuRamqyo(@krs7A&0*w^2p z75;g_Hk}St0=O_eRtyvWBA6UuD>qtXq4gus$(5}vJ5Avq;-H&1+g5J@aLJTcKhoKx zqk_tBf%C-*c!m_>n~kRsF>xny2d$(YHhw$4TK^k7g6_aRny(xaC)rQtciN-%qg&qP zT833b4hR!{K-L7}W+9@XH1nI&`mK$TXzA;l_?N)MzgW4^I#R5m^&8;R0C3RVhjU49 z@KpgQYqqUSTFRt{pD3n>Dh{!HI7FAjA-WXyQN+odX1Q{7upWMbD*HR|P{l&qM(c6m zAJc5Gslzu^!B=KK2R#mQ(ER{=iCzQ1%#`J6?dzwKv2iI40-0nWXS!r?)*)8u%9{T; z@TD!nZ&Pboi`LgR!=r>>+79@|8t~sc$U%<-oVs`RbM*U+7&BAGYVkchq^n7e5fdeF zB-0GU8|F5}4K@FX_Vt5W(E8fotFpi8p-KaMwH}YU+-!hPvfrohJH5hJ2B7w0n_q%N zjuexslp8J5TF`lbN}?zD&Cl>O51-c#_(cuyd-xQ}jepF0NACe(WXO(o+)I$8YVak0 z4~&wWCi>nswDxVs2;sl2BZLkEBE;Vf2p7paYKBJxen1oW{!QRFqj;3?*+lt#rFZx= z0O_(V9r+R@8=~`LBm$cliHEj(u#OVjuBI86I``+;+g{pu0D_=B=N3Z+A!l zm>D%=JMtw+)-e*ceORSoYxiLlA?#&&p+eCy15|2@ZhPS$V56H)p_f5NnOkP1VY9D& z)W=JZqNT;QkyS=*y%)<1!d)#Ms&tUtY^wDe;M3AmnBC#;3}U3!6l;6u=HtEuiIg3y z2w|`G+=pebz`nDzesl12>_zIP$ZU`O5) zdb=+0oO5b*kzQtaqNI;~P+<`yaBU5~wudG3qxI|Ivn&6zujt9XXWBWXda1EMqbhAlw5uDv9*4*^rS9op??V9)+|VH_i-PV z&{^wK_-wrEeP^3NXPHxKt-V8H^?%zYH#J%e2X%qpFQ}rMS+JnEGqpbPclQ_i8g#Zf zBvwtdPpG=zCaoVW`P({LvQwA8XB8xQy?>D4a@*x*^AAgCQ#^)k(E2L)Ay3Ua;T#jI z7dQ1X*TeTxQAIF|Bv=O7~KI{ z|E$5`D>^6AGil~Q{Led6>v!MJ)=4-#^VUB|kfc@dXninRclg~76yELb&0cKqPq%*O z_}nM1^}X4`?)y2+&i?FAh4nwn|F14uzrFCg9Vm?G{!2-Z&i>p_jrBWMF6l6>uLi&S z0d`F{pTfDF{du1{>vx8Ku0yrH5Bu-#KJ1`(4;S?8?9cjCTK_YAm-kPX{jDGPk7#{X zPjB|1&i;%~z4bX=ept_1pVjkV;bWae{3ESj4Cm$Er^=#qg6~^&|Gh&+XL|UsT{`>o zJewAT7y6vw?d*Mm_eWc`eow!mKYRKXNA&PzFEBpZ0mD-NL^J-i+^AOocZ11sZgQ^x z9^d#F_nz@FuFU9YNr{nv@g>6}C8rIK6s>*Fk3G1XPu@S{|37wFmvvc}by=5nS(kNL fmvx!JvuOVh5a5F)ThAaT00000NkvXXu0mjfwnX-y literal 0 HcmV?d00001 diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json new file mode 100644 index 000000000..f275d129c --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json @@ -0,0 +1,12 @@ +{ + "ID": "4DFA743E1086414BAB0AA3071D561D75", + "ActionKeyword": "flowtheme", + "Name": "Flow Launcher Theme Selector", + "Description": "Quickly switch your Flow Launcher theme.", + "Author": "Odotocodot", + "Version": "1.0.0", + "Language": "csharp", + "Website": "https://github.com/Flow-Launcher/Flow.Launcher", + "IcoPath": "icon.png", + "ExecuteFileName": "Flow.Launcher.Plugin.FlowThemeSelector.dll" +} \ No newline at end of file From 3abd05f6b3a687e73fc9e6ab0f09ec2af2f6c06a Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:58:16 +0800 Subject: [PATCH 0006/1836] Implement double pinyin --- .../DoublePinAlphabet.cs | 193 ++++++++++++++++++ .../UserSettings/Settings.cs | 2 + 2 files changed, 195 insertions(+) create mode 100644 Flow.Launcher.Infrastructure/DoublePinAlphabet.cs diff --git a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs new file mode 100644 index 000000000..607582097 --- /dev/null +++ b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs @@ -0,0 +1,193 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using Flow.Launcher.Infrastructure.UserSettings; +using ToolGood.Words.Pinyin; + +namespace Flow.Launcher.Infrastructure +{ + public class DoublePinAlphabet : IAlphabet + { + private ConcurrentDictionary _doublePinCache = + new ConcurrentDictionary(); + + private Settings _settings; + + public void Initialize([NotNull] Settings settings) + { + _settings = settings ?? throw new ArgumentNullException(nameof(settings)); + } + + public bool CanBeTranslated(string stringToTranslate) + { + return WordsHelper.HasChinese(stringToTranslate); + } + + public (string translation, TranslationMapping map) Translate(string content) + { + if (_settings.ShouldUseDoublePin) + { + if (!_doublePinCache.ContainsKey(content)) + { + return BuildCacheFromContent(content); + } + else + { + return _doublePinCache[content]; + } + } + return (content, null); + } + + private (string translation, TranslationMapping map) BuildCacheFromContent(string content) + { + if (WordsHelper.HasChinese(content)) + { + var resultList = WordsHelper.GetPinyinList(content).Select(ToDoublePin).ToArray(); + StringBuilder resultBuilder = new StringBuilder(); + TranslationMapping map = new TranslationMapping(); + + bool pre = false; + + for (int i = 0; i < resultList.Length; i++) + { + if (content[i] >= 0x3400 && content[i] <= 0x9FD5) + { + map.AddNewIndex(i, resultBuilder.Length, resultList[i].Length + 1); + resultBuilder.Append(' '); + resultBuilder.Append(resultList[i]); + pre = true; + } + else + { + if (pre) + { + pre = false; + resultBuilder.Append(' '); + } + + resultBuilder.Append(resultList[i]); + } + } + + map.endConstruct(); + + var key = resultBuilder.ToString(); + map.setKey(key); + + return _doublePinCache[content] = (key, map); + } + else + { + return (content, null); + } + } + + private static readonly ReadOnlyDictionary special = new(new Dictionary(){ + {"a", "aa"}, + {"ai", "ai"}, + {"an", "an"}, + {"ang", "ah"}, + {"ao", "ao"}, + {"e", "ee"}, + {"ei", "ei"}, + {"en", "en"}, + {"er", "er"}, + {"o", "oo"}, + {"ou", "ou"} + }); + + + private static readonly ReadOnlyDictionary first = new(new Dictionary(){ + {"ch", "i"}, + {"sh", "u"}, + {"zh", "v"} + }); + + + private static readonly ReadOnlyDictionary second = new(new Dictionary() + { + {"ua", "x"}, + {"ei", "w"}, + {"e", "e"}, + {"ou", "z"}, + {"iu", "q"}, + {"ve", "t"}, + {"ue", "t"}, + {"u", "u"}, + {"i", "i"}, + {"o", "o"}, + {"uo", "o"}, + {"ie", "p"}, + {"a", "a"}, + {"ong", "s"}, + {"iong", "s"}, + {"ai", "d"}, + {"ing", "k"}, + {"uai", "k"}, + {"ang", "h"}, + {"uan", "r"}, + {"an", "j"}, + {"en", "f"}, + {"ia", "x"}, + {"iang", "l"}, + {"uang", "l"}, + {"eng", "g"}, + {"in", "b"}, + {"ao", "c"}, + {"v", "v"}, + {"ui", "v"}, + {"un", "y"}, + {"iao", "n"}, + {"ian", "m"} + }); + + private static string ToDoublePin(string fullPinyin) + { + // Assuming s is valid + StringBuilder doublePin = new StringBuilder(); + + if (fullPinyin.Length <= 3 && (fullPinyin[0] == 'a' || fullPinyin[0] == 'e' || fullPinyin[0] == 'o')) + { + if (special.ContainsKey(fullPinyin)) + { + return special[fullPinyin]; + } + } + + // zh, ch, sh + if (fullPinyin.Length >= 2 && first.ContainsKey(fullPinyin[..2])) + { + doublePin.Append(first[fullPinyin[..2]]); + + if (second.TryGetValue(fullPinyin[2..], out string tmp)) + { + doublePin.Append(tmp); + } + else + { + doublePin.Append(fullPinyin[2..]); + } + } + else + { + doublePin.Append(fullPinyin[0]); + + if (second.TryGetValue(fullPinyin[1..], out string tmp)) + { + doublePin.Append(tmp); + } + else + { + doublePin.Append(fullPinyin[1..]); + } + } + + return doublePin.ToString(); + } + } +} diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 458846665..8d94cdba5 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -185,6 +185,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings /// when false Alphabet static service will always return empty results /// public bool ShouldUsePinyin { get; set; } = false; + + public bool ShouldUseDoublePin { get; set; } = false; public bool AlwaysPreview { get; set; } = false; public bool AlwaysStartEn { get; set; } = false; From fb6635344b8e5ecae06aadd31a3b112471b48ae2 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:58:23 +0800 Subject: [PATCH 0007/1836] Test double pinyin --- Flow.Launcher/App.xaml.cs | 2 +- Flow.Launcher/PublicAPIInstance.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 765a1a559..d74ea62fb 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -30,7 +30,7 @@ namespace Flow.Launcher private SettingWindowViewModel _settingsVM; private readonly Updater _updater = new Updater(Flow.Launcher.Properties.Settings.Default.GithubRepo); private readonly Portable _portable = new Portable(); - private readonly PinyinAlphabet _alphabet = new PinyinAlphabet(); + private readonly DoublePinAlphabet _alphabet = new DoublePinAlphabet(); private StringMatcher _stringMatcher; [STAThread] diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index b49bf39d3..952ce0edb 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -32,11 +32,11 @@ namespace Flow.Launcher { private readonly SettingWindowViewModel _settingsVM; private readonly MainViewModel _mainVM; - private readonly PinyinAlphabet _alphabet; + private readonly DoublePinAlphabet _alphabet; #region Constructor - public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM, PinyinAlphabet alphabet) + public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM, DoublePinAlphabet alphabet) { _settingsVM = settingsVM; _mainVM = mainVM; From f6ae71a99f838b2237c14c62c6daff5e97e6eec0 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 18 Nov 2023 20:24:13 +0800 Subject: [PATCH 0008/1836] Only convert to double pinyin when meeting Chinese --- Flow.Launcher.Infrastructure/DoublePinAlphabet.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs index 607582097..e09046410 100644 --- a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs @@ -47,7 +47,7 @@ namespace Flow.Launcher.Infrastructure { if (WordsHelper.HasChinese(content)) { - var resultList = WordsHelper.GetPinyinList(content).Select(ToDoublePin).ToArray(); + var resultList = WordsHelper.GetPinyinList(content); StringBuilder resultBuilder = new StringBuilder(); TranslationMapping map = new TranslationMapping(); @@ -57,9 +57,10 @@ namespace Flow.Launcher.Infrastructure { if (content[i] >= 0x3400 && content[i] <= 0x9FD5) { - map.AddNewIndex(i, resultBuilder.Length, resultList[i].Length + 1); + string dp = ToDoublePin(resultList[i].ToLower()); + map.AddNewIndex(i, resultBuilder.Length, dp.Length + 1); resultBuilder.Append(' '); - resultBuilder.Append(resultList[i]); + resultBuilder.Append(dp); pre = true; } else From e5285b19921ae2cc49b6f55ebe5772a77f05cd54 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:30:17 +0800 Subject: [PATCH 0009/1836] Temp: compatibility with full pinyin option --- Flow.Launcher.Infrastructure/DoublePinAlphabet.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs index e09046410..e6930ad93 100644 --- a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs @@ -29,7 +29,7 @@ namespace Flow.Launcher.Infrastructure public (string translation, TranslationMapping map) Translate(string content) { - if (_settings.ShouldUseDoublePin) + if (_settings.ShouldUsePinyin) { if (!_doublePinCache.ContainsKey(content)) { @@ -57,7 +57,7 @@ namespace Flow.Launcher.Infrastructure { if (content[i] >= 0x3400 && content[i] <= 0x9FD5) { - string dp = ToDoublePin(resultList[i].ToLower()); + string dp = _settings.ShouldUseDoublePin ? resultList[i] : ToDoublePin(resultList[i].ToLower()); map.AddNewIndex(i, resultBuilder.Length, dp.Length + 1); resultBuilder.Append(' '); resultBuilder.Append(dp); From 99ff3b2ec5c9a4d8b4f136735a866f52914c246e Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:49:39 +0800 Subject: [PATCH 0010/1836] Fix wrong condition --- Flow.Launcher.Infrastructure/DoublePinAlphabet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs index e6930ad93..a1eb788d7 100644 --- a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs @@ -57,7 +57,7 @@ namespace Flow.Launcher.Infrastructure { if (content[i] >= 0x3400 && content[i] <= 0x9FD5) { - string dp = _settings.ShouldUseDoublePin ? resultList[i] : ToDoublePin(resultList[i].ToLower()); + string dp = _settings.ShouldUseDoublePin ? ToDoublePin(resultList[i].ToLower()) : resultList[i]; map.AddNewIndex(i, resultBuilder.Length, dp.Length + 1); resultBuilder.Append(' '); resultBuilder.Append(dp); From 46d49d8fdf373e020481b111cbd23bf8ee09538d Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 25 May 2024 15:02:37 +0800 Subject: [PATCH 0011/1836] Only translate when string is double pinyin --- Flow.Launcher.Infrastructure/DoublePinAlphabet.cs | 4 ++-- Flow.Launcher.Infrastructure/PinyinAlphabet.cs | 4 ++-- Flow.Launcher.Infrastructure/StringMatcher.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs index a1eb788d7..945f47a56 100644 --- a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs @@ -22,9 +22,9 @@ namespace Flow.Launcher.Infrastructure _settings = settings ?? throw new ArgumentNullException(nameof(settings)); } - public bool CanBeTranslated(string stringToTranslate) + public bool ShouldTranslate(string stringToTranslate) { - return WordsHelper.HasChinese(stringToTranslate); + return stringToTranslate.Length % 2 == 0 && !WordsHelper.HasChinese(stringToTranslate); } public (string translation, TranslationMapping map) Translate(string content) diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index 7d7235968..961af1d32 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -119,7 +119,7 @@ namespace Flow.Launcher.Infrastructure /// /// String to translate. /// - public bool CanBeTranslated(string stringToTranslate); + public bool ShouldTranslate(string stringToTranslate); } public class PinyinAlphabet : IAlphabet @@ -134,7 +134,7 @@ namespace Flow.Launcher.Infrastructure _settings = settings ?? throw new ArgumentNullException(nameof(settings)); } - public bool CanBeTranslated(string stringToTranslate) + public bool ShouldTranslate(string stringToTranslate) { return WordsHelper.HasChinese(stringToTranslate); } diff --git a/Flow.Launcher.Infrastructure/StringMatcher.cs b/Flow.Launcher.Infrastructure/StringMatcher.cs index bd5dbdda9..4929e4cd2 100644 --- a/Flow.Launcher.Infrastructure/StringMatcher.cs +++ b/Flow.Launcher.Infrastructure/StringMatcher.cs @@ -61,7 +61,7 @@ namespace Flow.Launcher.Infrastructure query = query.Trim(); TranslationMapping translationMapping = null; - if (_alphabet is not null && !_alphabet.CanBeTranslated(query)) + if (_alphabet is not null && _alphabet.ShouldTranslate(query)) { // We assume that if a query can be translated (containing characters of a language, like Chinese) // it actually means user doesn't want it to be translated to English letters. From b1cb852673005e955b1d4bd0bb2ed692e44308c9 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:18:57 +0800 Subject: [PATCH 0012/1836] Extract classes --- Flow.Launcher.Infrastructure/IAlphabet.cs | 22 ++++ .../PinyinAlphabet.cs | 113 ------------------ .../TranslationMapping.cs | 99 +++++++++++++++ 3 files changed, 121 insertions(+), 113 deletions(-) create mode 100644 Flow.Launcher.Infrastructure/IAlphabet.cs create mode 100644 Flow.Launcher.Infrastructure/TranslationMapping.cs diff --git a/Flow.Launcher.Infrastructure/IAlphabet.cs b/Flow.Launcher.Infrastructure/IAlphabet.cs new file mode 100644 index 000000000..e79ec0c6d --- /dev/null +++ b/Flow.Launcher.Infrastructure/IAlphabet.cs @@ -0,0 +1,22 @@ +namespace Flow.Launcher.Infrastructure +{ + /// + /// Translate a language to English letters using a given rule. + /// + public interface IAlphabet + { + /// + /// Translate a string to English letters, using a given rule. + /// + /// String to translate. + /// + public (string translation, TranslationMapping map) Translate(string stringToTranslate); + + /// + /// Determine if a string can be translated to English letter with this Alphabet. + /// + /// String to translate. + /// + public bool ShouldTranslate(string stringToTranslate); + } +} diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index 961af1d32..d98d823d7 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -9,119 +9,6 @@ using ToolGood.Words.Pinyin; namespace Flow.Launcher.Infrastructure { - public class TranslationMapping - { - private bool constructed; - - private List originalIndexs = new List(); - private List translatedIndexs = new List(); - private int translatedLength = 0; - - public string key { get; private set; } - - public void setKey(string key) - { - this.key = key; - } - - public void AddNewIndex(int originalIndex, int translatedIndex, int length) - { - if (constructed) - throw new InvalidOperationException("Mapping shouldn't be changed after constructed"); - - originalIndexs.Add(originalIndex); - translatedIndexs.Add(translatedIndex); - translatedIndexs.Add(translatedIndex + length); - translatedLength += length - 1; - } - - public int MapToOriginalIndex(int translatedIndex) - { - if (translatedIndex > translatedIndexs.Last()) - return translatedIndex - translatedLength - 1; - - int lowerBound = 0; - int upperBound = originalIndexs.Count - 1; - - int count = 0; - - // Corner case handle - if (translatedIndex < translatedIndexs[0]) - return translatedIndex; - if (translatedIndex > translatedIndexs.Last()) - { - int indexDef = 0; - for (int k = 0; k < originalIndexs.Count; k++) - { - indexDef += translatedIndexs[k * 2 + 1] - translatedIndexs[k * 2]; - } - - return translatedIndex - indexDef - 1; - } - - // Binary Search with Range - for (int i = originalIndexs.Count / 2;; count++) - { - if (translatedIndex < translatedIndexs[i * 2]) - { - // move to lower middle - upperBound = i; - i = (i + lowerBound) / 2; - } - else if (translatedIndex > translatedIndexs[i * 2 + 1] - 1) - { - lowerBound = i; - // move to upper middle - // due to floor of integer division, move one up on corner case - i = (i + upperBound + 1) / 2; - } - else - return originalIndexs[i]; - - if (upperBound - lowerBound <= 1 && - translatedIndex > translatedIndexs[lowerBound * 2 + 1] && - translatedIndex < translatedIndexs[upperBound * 2]) - { - int indexDef = 0; - - for (int j = 0; j < upperBound; j++) - { - indexDef += translatedIndexs[j * 2 + 1] - translatedIndexs[j * 2]; - } - - return translatedIndex - indexDef - 1; - } - } - } - - public void endConstruct() - { - if (constructed) - throw new InvalidOperationException("Mapping has already been constructed"); - constructed = true; - } - } - - /// - /// Translate a language to English letters using a given rule. - /// - public interface IAlphabet - { - /// - /// Translate a string to English letters, using a given rule. - /// - /// String to translate. - /// - public (string translation, TranslationMapping map) Translate(string stringToTranslate); - - /// - /// Determine if a string can be translated to English letter with this Alphabet. - /// - /// String to translate. - /// - public bool ShouldTranslate(string stringToTranslate); - } - public class PinyinAlphabet : IAlphabet { private ConcurrentDictionary _pinyinCache = diff --git a/Flow.Launcher.Infrastructure/TranslationMapping.cs b/Flow.Launcher.Infrastructure/TranslationMapping.cs new file mode 100644 index 000000000..f288c816a --- /dev/null +++ b/Flow.Launcher.Infrastructure/TranslationMapping.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Flow.Launcher.Infrastructure +{ + public class TranslationMapping + { + private bool constructed; + + private List originalIndexs = new List(); + private List translatedIndexs = new List(); + private int translatedLength = 0; + + public string key { get; private set; } + + public void setKey(string key) + { + this.key = key; + } + + public void AddNewIndex(int originalIndex, int translatedIndex, int length) + { + if (constructed) + throw new InvalidOperationException("Mapping shouldn't be changed after constructed"); + + originalIndexs.Add(originalIndex); + translatedIndexs.Add(translatedIndex); + translatedIndexs.Add(translatedIndex + length); + translatedLength += length - 1; + } + + public int MapToOriginalIndex(int translatedIndex) + { + if (translatedIndex > translatedIndexs.Last()) + return translatedIndex - translatedLength - 1; + + int lowerBound = 0; + int upperBound = originalIndexs.Count - 1; + + int count = 0; + + // Corner case handle + if (translatedIndex < translatedIndexs[0]) + return translatedIndex; + if (translatedIndex > translatedIndexs.Last()) + { + int indexDef = 0; + for (int k = 0; k < originalIndexs.Count; k++) + { + indexDef += translatedIndexs[k * 2 + 1] - translatedIndexs[k * 2]; + } + + return translatedIndex - indexDef - 1; + } + + // Binary Search with Range + for (int i = originalIndexs.Count / 2;; count++) + { + if (translatedIndex < translatedIndexs[i * 2]) + { + // move to lower middle + upperBound = i; + i = (i + lowerBound) / 2; + } + else if (translatedIndex > translatedIndexs[i * 2 + 1] - 1) + { + lowerBound = i; + // move to upper middle + // due to floor of integer division, move one up on corner case + i = (i + upperBound + 1) / 2; + } + else + return originalIndexs[i]; + + if (upperBound - lowerBound <= 1 && + translatedIndex > translatedIndexs[lowerBound * 2 + 1] && + translatedIndex < translatedIndexs[upperBound * 2]) + { + int indexDef = 0; + + for (int j = 0; j < upperBound; j++) + { + indexDef += translatedIndexs[j * 2 + 1] - translatedIndexs[j * 2]; + } + + return translatedIndex - indexDef - 1; + } + } + } + + public void endConstruct() + { + if (constructed) + throw new InvalidOperationException("Mapping has already been constructed"); + constructed = true; + } + } +} From 6807afbe6d753eed6984e1b1ab6019e2864767cd Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:03:00 +0800 Subject: [PATCH 0013/1836] Remove unused alphabet arg in PublicAPIInstance --- Flow.Launcher/App.xaml.cs | 2 +- Flow.Launcher/PublicAPIInstance.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index d74ea62fb..560bb052b 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -74,7 +74,7 @@ namespace Flow.Launcher PluginManager.LoadPlugins(_settings.PluginSettings); _mainVM = new MainViewModel(_settings); - API = new PublicAPIInstance(_settingsVM, _mainVM, _alphabet); + API = new PublicAPIInstance(_settingsVM, _mainVM); Http.API = API; Http.Proxy = _settings.Proxy; diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 952ce0edb..e14d692cd 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -32,15 +32,13 @@ namespace Flow.Launcher { private readonly SettingWindowViewModel _settingsVM; private readonly MainViewModel _mainVM; - private readonly DoublePinAlphabet _alphabet; #region Constructor - public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM, DoublePinAlphabet alphabet) + public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM) { _settingsVM = settingsVM; _mainVM = mainVM; - _alphabet = alphabet; GlobalHotkey.hookedKeyboardCallback = KListener_hookedKeyboardCallback; WebRequest.RegisterPrefix("data", new DataWebRequestFactory()); } From a2efa11699fed4b3aac21bdff26555ce57b274aa Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:19:27 +0800 Subject: [PATCH 0014/1836] Merge DoublePinAlphabet logic --- .../DoublePinAlphabet.cs | 194 ------------------ .../PinyinAlphabet.cs | 127 +++++++++++- .../UserSettings/Settings.cs | 3 +- Flow.Launcher/App.xaml.cs | 2 +- 4 files changed, 121 insertions(+), 205 deletions(-) delete mode 100644 Flow.Launcher.Infrastructure/DoublePinAlphabet.cs diff --git a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs b/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs deleted file mode 100644 index 945f47a56..000000000 --- a/Flow.Launcher.Infrastructure/DoublePinAlphabet.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using Flow.Launcher.Infrastructure.UserSettings; -using ToolGood.Words.Pinyin; - -namespace Flow.Launcher.Infrastructure -{ - public class DoublePinAlphabet : IAlphabet - { - private ConcurrentDictionary _doublePinCache = - new ConcurrentDictionary(); - - private Settings _settings; - - public void Initialize([NotNull] Settings settings) - { - _settings = settings ?? throw new ArgumentNullException(nameof(settings)); - } - - public bool ShouldTranslate(string stringToTranslate) - { - return stringToTranslate.Length % 2 == 0 && !WordsHelper.HasChinese(stringToTranslate); - } - - public (string translation, TranslationMapping map) Translate(string content) - { - if (_settings.ShouldUsePinyin) - { - if (!_doublePinCache.ContainsKey(content)) - { - return BuildCacheFromContent(content); - } - else - { - return _doublePinCache[content]; - } - } - return (content, null); - } - - private (string translation, TranslationMapping map) BuildCacheFromContent(string content) - { - if (WordsHelper.HasChinese(content)) - { - var resultList = WordsHelper.GetPinyinList(content); - StringBuilder resultBuilder = new StringBuilder(); - TranslationMapping map = new TranslationMapping(); - - bool pre = false; - - for (int i = 0; i < resultList.Length; i++) - { - if (content[i] >= 0x3400 && content[i] <= 0x9FD5) - { - string dp = _settings.ShouldUseDoublePin ? ToDoublePin(resultList[i].ToLower()) : resultList[i]; - map.AddNewIndex(i, resultBuilder.Length, dp.Length + 1); - resultBuilder.Append(' '); - resultBuilder.Append(dp); - pre = true; - } - else - { - if (pre) - { - pre = false; - resultBuilder.Append(' '); - } - - resultBuilder.Append(resultList[i]); - } - } - - map.endConstruct(); - - var key = resultBuilder.ToString(); - map.setKey(key); - - return _doublePinCache[content] = (key, map); - } - else - { - return (content, null); - } - } - - private static readonly ReadOnlyDictionary special = new(new Dictionary(){ - {"a", "aa"}, - {"ai", "ai"}, - {"an", "an"}, - {"ang", "ah"}, - {"ao", "ao"}, - {"e", "ee"}, - {"ei", "ei"}, - {"en", "en"}, - {"er", "er"}, - {"o", "oo"}, - {"ou", "ou"} - }); - - - private static readonly ReadOnlyDictionary first = new(new Dictionary(){ - {"ch", "i"}, - {"sh", "u"}, - {"zh", "v"} - }); - - - private static readonly ReadOnlyDictionary second = new(new Dictionary() - { - {"ua", "x"}, - {"ei", "w"}, - {"e", "e"}, - {"ou", "z"}, - {"iu", "q"}, - {"ve", "t"}, - {"ue", "t"}, - {"u", "u"}, - {"i", "i"}, - {"o", "o"}, - {"uo", "o"}, - {"ie", "p"}, - {"a", "a"}, - {"ong", "s"}, - {"iong", "s"}, - {"ai", "d"}, - {"ing", "k"}, - {"uai", "k"}, - {"ang", "h"}, - {"uan", "r"}, - {"an", "j"}, - {"en", "f"}, - {"ia", "x"}, - {"iang", "l"}, - {"uang", "l"}, - {"eng", "g"}, - {"in", "b"}, - {"ao", "c"}, - {"v", "v"}, - {"ui", "v"}, - {"un", "y"}, - {"iao", "n"}, - {"ian", "m"} - }); - - private static string ToDoublePin(string fullPinyin) - { - // Assuming s is valid - StringBuilder doublePin = new StringBuilder(); - - if (fullPinyin.Length <= 3 && (fullPinyin[0] == 'a' || fullPinyin[0] == 'e' || fullPinyin[0] == 'o')) - { - if (special.ContainsKey(fullPinyin)) - { - return special[fullPinyin]; - } - } - - // zh, ch, sh - if (fullPinyin.Length >= 2 && first.ContainsKey(fullPinyin[..2])) - { - doublePin.Append(first[fullPinyin[..2]]); - - if (second.TryGetValue(fullPinyin[2..], out string tmp)) - { - doublePin.Append(tmp); - } - else - { - doublePin.Append(fullPinyin[2..]); - } - } - else - { - doublePin.Append(fullPinyin[0]); - - if (second.TryGetValue(fullPinyin[1..], out string tmp)) - { - doublePin.Append(tmp); - } - else - { - doublePin.Append(fullPinyin[1..]); - } - } - - return doublePin.ToString(); - } - } -} diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index d98d823d7..37e4f93d2 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -1,18 +1,18 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; using System.Text; using JetBrains.Annotations; using Flow.Launcher.Infrastructure.UserSettings; using ToolGood.Words.Pinyin; +using System.Collections.Generic; +using System.Collections.ObjectModel; namespace Flow.Launcher.Infrastructure { public class PinyinAlphabet : IAlphabet { - private ConcurrentDictionary _pinyinCache = - new ConcurrentDictionary(); + private readonly ConcurrentDictionary _pinyinCache = + new(); private Settings _settings; @@ -23,20 +23,22 @@ namespace Flow.Launcher.Infrastructure public bool ShouldTranslate(string stringToTranslate) { - return WordsHelper.HasChinese(stringToTranslate); + return _settings.UseDoublePinyin ? + (WordsHelper.HasChinese(stringToTranslate) && stringToTranslate.Length % 2 == 0) : + WordsHelper.HasChinese(stringToTranslate); } public (string translation, TranslationMapping map) Translate(string content) { if (_settings.ShouldUsePinyin) { - if (!_pinyinCache.ContainsKey(content)) + if (!_pinyinCache.TryGetValue(content, out var value)) { return BuildCacheFromContent(content); } else { - return _pinyinCache[content]; + return value; } } return (content, null); @@ -57,9 +59,10 @@ namespace Flow.Launcher.Infrastructure { if (content[i] >= 0x3400 && content[i] <= 0x9FD5) { - map.AddNewIndex(i, resultBuilder.Length, resultList[i].Length + 1); + string dp = _settings.UseDoublePinyin ? ToDoublePin(resultList[i].ToLower()) : resultList[i]; + map.AddNewIndex(i, resultBuilder.Length, dp.Length + 1); resultBuilder.Append(' '); - resultBuilder.Append(resultList[i]); + resultBuilder.Append(dp); pre = true; } else @@ -86,5 +89,111 @@ namespace Flow.Launcher.Infrastructure return (content, null); } } + + #region Double Pinyin + + private static readonly ReadOnlyDictionary special = new(new Dictionary(){ + {"a", "aa"}, + {"ai", "ai"}, + {"an", "an"}, + {"ang", "ah"}, + {"ao", "ao"}, + {"e", "ee"}, + {"ei", "ei"}, + {"en", "en"}, + {"er", "er"}, + {"o", "oo"}, + {"ou", "ou"} + }); + + + private static readonly ReadOnlyDictionary first = new(new Dictionary(){ + {"ch", "i"}, + {"sh", "u"}, + {"zh", "v"} + }); + + + private static readonly ReadOnlyDictionary second = new(new Dictionary() + { + {"ua", "x"}, + {"ei", "w"}, + {"e", "e"}, + {"ou", "z"}, + {"iu", "q"}, + {"ve", "t"}, + {"ue", "t"}, + {"u", "u"}, + {"i", "i"}, + {"o", "o"}, + {"uo", "o"}, + {"ie", "p"}, + {"a", "a"}, + {"ong", "s"}, + {"iong", "s"}, + {"ai", "d"}, + {"ing", "k"}, + {"uai", "k"}, + {"ang", "h"}, + {"uan", "r"}, + {"an", "j"}, + {"en", "f"}, + {"ia", "x"}, + {"iang", "l"}, + {"uang", "l"}, + {"eng", "g"}, + {"in", "b"}, + {"ao", "c"}, + {"v", "v"}, + {"ui", "v"}, + {"un", "y"}, + {"iao", "n"}, + {"ian", "m"} + }); + + private static string ToDoublePin(string fullPinyin) + { + // Assuming s is valid + StringBuilder doublePin = new StringBuilder(); + + if (fullPinyin.Length <= 3 && (fullPinyin[0] == 'a' || fullPinyin[0] == 'e' || fullPinyin[0] == 'o')) + { + if (special.TryGetValue(fullPinyin, out var value)) + { + return value; + } + } + + // zh, ch, sh + if (fullPinyin.Length >= 2 && first.ContainsKey(fullPinyin[..2])) + { + doublePin.Append(first[fullPinyin[..2]]); + + if (second.TryGetValue(fullPinyin[2..], out string tmp)) + { + doublePin.Append(tmp); + } + else + { + doublePin.Append(fullPinyin[2..]); + } + } + else + { + doublePin.Append(fullPinyin[0]); + + if (second.TryGetValue(fullPinyin[1..], out string tmp)) + { + doublePin.Append(tmp); + } + else + { + doublePin.Append(fullPinyin[1..]); + } + } + + return doublePin.ToString(); + } + #endregion } } diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 8d94cdba5..e79c3f52d 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -186,7 +186,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings /// public bool ShouldUsePinyin { get; set; } = false; - public bool ShouldUseDoublePin { get; set; } = false; + public bool UseDoublePinyin { get; set; } = false; + public bool AlwaysPreview { get; set; } = false; public bool AlwaysStartEn { get; set; } = false; diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 560bb052b..83870837a 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -30,7 +30,7 @@ namespace Flow.Launcher private SettingWindowViewModel _settingsVM; private readonly Updater _updater = new Updater(Flow.Launcher.Properties.Settings.Default.GithubRepo); private readonly Portable _portable = new Portable(); - private readonly DoublePinAlphabet _alphabet = new DoublePinAlphabet(); + private readonly PinyinAlphabet _alphabet = new PinyinAlphabet(); private StringMatcher _stringMatcher; [STAThread] From 12c4e37a95df44fc968a6459e7a3cbf6de4063e6 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:33:49 +0800 Subject: [PATCH 0015/1836] Developing --- Flow.Launcher.Infrastructure/UserSettings/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index e79c3f52d..30e3b77be 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -186,7 +186,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings /// public bool ShouldUsePinyin { get; set; } = false; - public bool UseDoublePinyin { get; set; } = false; + public bool UseDoublePinyin { get; set; } = true; //For developing public bool AlwaysPreview { get; set; } = false; public bool AlwaysStartEn { get; set; } = false; From f673000d67e4ff1180e6d2856bf85f1640433a7c Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:37:15 +0800 Subject: [PATCH 0016/1836] Fix ShouldTranslate() --- Flow.Launcher.Infrastructure/PinyinAlphabet.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index 37e4f93d2..b48a61090 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -23,9 +23,9 @@ namespace Flow.Launcher.Infrastructure public bool ShouldTranslate(string stringToTranslate) { - return _settings.UseDoublePinyin ? - (WordsHelper.HasChinese(stringToTranslate) && stringToTranslate.Length % 2 == 0) : - WordsHelper.HasChinese(stringToTranslate); + return _settings.UseDoublePinyin ? + (!WordsHelper.HasChinese(stringToTranslate) && stringToTranslate.Length % 2 == 0) : + !WordsHelper.HasChinese(stringToTranslate); } public (string translation, TranslationMapping map) Translate(string content) From b10a6e19df5afcbd13ca612f6e6952f19a3b9dde Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 2 Jun 2024 15:18:24 +0800 Subject: [PATCH 0017/1836] Capitalize first letter --- .../PinyinAlphabet.cs | 104 +++++++++--------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index b48a61090..cbec7feae 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -46,71 +46,69 @@ namespace Flow.Launcher.Infrastructure private (string translation, TranslationMapping map) BuildCacheFromContent(string content) { - if (WordsHelper.HasChinese(content)) - { - var resultList = WordsHelper.GetPinyinList(content); - - StringBuilder resultBuilder = new StringBuilder(); - TranslationMapping map = new TranslationMapping(); - - bool pre = false; - - for (int i = 0; i < resultList.Length; i++) - { - if (content[i] >= 0x3400 && content[i] <= 0x9FD5) - { - string dp = _settings.UseDoublePinyin ? ToDoublePin(resultList[i].ToLower()) : resultList[i]; - map.AddNewIndex(i, resultBuilder.Length, dp.Length + 1); - resultBuilder.Append(' '); - resultBuilder.Append(dp); - pre = true; - } - else - { - if (pre) - { - pre = false; - resultBuilder.Append(' '); - } - - resultBuilder.Append(resultList[i]); - } - } - - map.endConstruct(); - - var key = resultBuilder.ToString(); - map.setKey(key); - - return _pinyinCache[content] = (key, map); - } - else + if (!WordsHelper.HasChinese(content)) { return (content, null); } + + var resultList = WordsHelper.GetPinyinList(content); + + StringBuilder resultBuilder = new StringBuilder(); + TranslationMapping map = new TranslationMapping(); + + bool pre = false; + + for (int i = 0; i < resultList.Length; i++) + { + if (content[i] >= 0x3400 && content[i] <= 0x9FD5) + { + string dp = _settings.UseDoublePinyin ? ToDoublePin(resultList[i]) : resultList[i]; + map.AddNewIndex(i, resultBuilder.Length, dp.Length + 1); + resultBuilder.Append(' '); + resultBuilder.Append(dp); + pre = true; + } + else + { + if (pre) + { + pre = false; + resultBuilder.Append(' '); + } + + resultBuilder.Append(resultList[i]); + } + } + + map.endConstruct(); + + var key = resultBuilder.ToString(); + map.setKey(key); + + return _pinyinCache[content] = (key, map); } #region Double Pinyin private static readonly ReadOnlyDictionary special = new(new Dictionary(){ - {"a", "aa"}, - {"ai", "ai"}, - {"an", "an"}, - {"ang", "ah"}, - {"ao", "ao"}, - {"e", "ee"}, - {"ei", "ei"}, - {"en", "en"}, - {"er", "er"}, - {"o", "oo"}, - {"ou", "ou"} + {"A", "aa"}, + {"Ai", "ai"}, + {"An", "an"}, + {"Ang", "ah"}, + {"Ao", "ao"}, + {"E", "ee"}, + {"Ei", "ei"}, + {"En", "en"}, + {"Er", "er"}, + {"O", "oo"}, + {"Ou", "ou"} }); private static readonly ReadOnlyDictionary first = new(new Dictionary(){ - {"ch", "i"}, - {"sh", "u"}, - {"zh", "v"} + {"Ch", "i"}, + {"Sh", "u"}, + {"Zh", "v"} }); From b816d1b866aa93b6d8f2da9f5cef334bda64748b Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 2 Jun 2024 15:21:04 +0800 Subject: [PATCH 0018/1836] Remove unused key in pinyin alphabet --- Flow.Launcher.Infrastructure/PinyinAlphabet.cs | 1 - Flow.Launcher.Infrastructure/TranslationMapping.cs | 7 ------- 2 files changed, 8 deletions(-) diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index cbec7feae..10799c676 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -83,7 +83,6 @@ namespace Flow.Launcher.Infrastructure map.endConstruct(); var key = resultBuilder.ToString(); - map.setKey(key); return _pinyinCache[content] = (key, map); } diff --git a/Flow.Launcher.Infrastructure/TranslationMapping.cs b/Flow.Launcher.Infrastructure/TranslationMapping.cs index f288c816a..c976fc522 100644 --- a/Flow.Launcher.Infrastructure/TranslationMapping.cs +++ b/Flow.Launcher.Infrastructure/TranslationMapping.cs @@ -12,13 +12,6 @@ namespace Flow.Launcher.Infrastructure private List translatedIndexs = new List(); private int translatedLength = 0; - public string key { get; private set; } - - public void setKey(string key) - { - this.key = key; - } - public void AddNewIndex(int originalIndex, int translatedIndex, int length) { if (constructed) From 24cc4757b4d924158885edf36071097794ba08a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:40:45 +0000 Subject: [PATCH 0019/1836] Bump Microsoft.Data.Sqlite from 8.0.3 to 8.0.6 Bumps [Microsoft.Data.Sqlite](https://github.com/dotnet/efcore) from 8.0.3 to 8.0.6. - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v8.0.3...v8.0.6) --- updated-dependencies: - dependency-name: Microsoft.Data.Sqlite dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Plugin.BrowserBookmark.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index 234afe28a..9177813f4 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -95,7 +95,7 @@ - + From 37ccf259405e4ac70c2587b1f7b3a5e8c45159ec Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 5 Jun 2024 04:53:31 +0900 Subject: [PATCH 0020/1836] Add Top Positioning per monitor --- Flow.Launcher/MainWindow.xaml.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 22799a63d..6c0889295 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -306,15 +306,15 @@ namespace Flow.Launcher break; case SearchWindowAligns.CenterTop: Left = HorizonCenter(screen); - Top = 10; + Top = VerticalTop(screen); break; case SearchWindowAligns.LeftTop: Left = HorizonLeft(screen); - Top = 10; + Top = VerticalTop(screen); break; case SearchWindowAligns.RightTop: Left = HorizonRight(screen); - Top = 10; + Top = VerticalTop(screen); break; case SearchWindowAligns.Custom: Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X; @@ -727,6 +727,13 @@ namespace Flow.Launcher return left; } + public double VerticalTop(Screen screen) + { + var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); + var top = dip1.Y +10; + return top; + } + /// /// Register up and down key /// todo: any way to put this in xaml ? From 63ce735169afe7cf871d3d2a8eb6086e49fefa9a Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 5 Jun 2024 06:42:33 +0900 Subject: [PATCH 0021/1836] =?UTF-8?q?When=20using=20the=20=E2=80=9Cremembe?= =?UTF-8?q?r=20last=20position=E2=80=9D=20setting,=20if=20the=20resolution?= =?UTF-8?q?=20or=20dpi=20has=20changed,=20the=20position=20will=20be=20res?= =?UTF-8?q?caled=20proportionally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Flow.Launcher/MainWindow.xaml.cs | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 6c0889295..87e818154 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -27,6 +27,7 @@ using DataObject = System.Windows.DataObject; using System.Windows.Media; using System.Windows.Interop; using System.Runtime.InteropServices; +using System.Drawing; namespace Flow.Launcher { @@ -48,6 +49,10 @@ namespace Flow.Launcher private MediaPlayer animationSoundWMP; private SoundPlayer animationSoundWPF; + private double _previousScreenWidth; + private double _previousScreenHeight; + private double _previousDpiX; + private double _previousDpiY; #endregion @@ -288,8 +293,31 @@ namespace Flow.Launcher }; } + private (double X, double Y) GetCurrentDpi(Screen screen) + { + using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) + { + return (g.DpiX, g.DpiY); + } + } private void InitializePosition() { + var screen = SelectedScreen(); + var currentDpi = GetCurrentDpi(screen); + double currentScreenWidth = screen.WorkingArea.Width; + double currentScreenHeight = screen.WorkingArea.Height; + + if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0) + { + double widthRatio = currentScreenWidth / _previousScreenWidth; + double heightRatio = currentScreenHeight / _previousScreenHeight; + double dpiXRatio = currentDpi.X / _previousDpiX; + double dpiYRatio = currentDpi.Y / _previousDpiY; + + _settings.WindowLeft *= widthRatio * dpiXRatio; + _settings.WindowTop *= heightRatio * dpiYRatio; + } + if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { Top = _settings.WindowTop; @@ -297,7 +325,6 @@ namespace Flow.Launcher } else { - var screen = SelectedScreen(); switch (_settings.SearchWindowAlign) { case SearchWindowAligns.Center: @@ -323,6 +350,10 @@ namespace Flow.Launcher } } + _previousScreenWidth = currentScreenWidth; + _previousScreenHeight = currentScreenHeight; + _previousDpiX = currentDpi.X; + _previousDpiY = currentDpi.Y; } private void UpdateNotifyIconText() From ae0ec8ecf292ee56417da240966f516028f4c88d Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 5 Jun 2024 06:51:25 +0900 Subject: [PATCH 0022/1836] Revert "Fix blurry situation when changed dpi in some case" This reverts commit 2869812a74160517b2cd4ba6a7436b40eaa59195. --- Flow.Launcher/app.manifest | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/app.manifest b/Flow.Launcher/app.manifest index c45508fcf..52d1c3932 100644 --- a/Flow.Launcher/app.manifest +++ b/Flow.Launcher/app.manifest @@ -49,12 +49,13 @@ DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> + From 45dd84a3fa39e5784d9101bde4aabd5eff7e7969 Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 5 Jun 2024 07:03:26 +0900 Subject: [PATCH 0023/1836] Adjust Code --- Flow.Launcher/MainWindow.xaml.cs | 96 +++++++++++++++++--------------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 87e818154..927067f93 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -307,53 +307,61 @@ namespace Flow.Launcher double currentScreenWidth = screen.WorkingArea.Width; double currentScreenHeight = screen.WorkingArea.Height; - if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0) + if (!( + _previousScreenWidth == currentScreenWidth && + _previousScreenHeight == currentScreenHeight && + _previousDpiX == currentDpi.X && + _previousDpiY == currentDpi.Y + )) { - double widthRatio = currentScreenWidth / _previousScreenWidth; - double heightRatio = currentScreenHeight / _previousScreenHeight; - double dpiXRatio = currentDpi.X / _previousDpiX; - double dpiYRatio = currentDpi.Y / _previousDpiY; - - _settings.WindowLeft *= widthRatio * dpiXRatio; - _settings.WindowTop *= heightRatio * dpiYRatio; - } - - if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) - { - Top = _settings.WindowTop; - Left = _settings.WindowLeft; - } - else - { - switch (_settings.SearchWindowAlign) + if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0) { - case SearchWindowAligns.Center: - Left = HorizonCenter(screen); - Top = VerticalCenter(screen); - break; - case SearchWindowAligns.CenterTop: - Left = HorizonCenter(screen); - Top = VerticalTop(screen); - break; - case SearchWindowAligns.LeftTop: - Left = HorizonLeft(screen); - Top = VerticalTop(screen); - break; - case SearchWindowAligns.RightTop: - Left = HorizonRight(screen); - Top = VerticalTop(screen); - break; - case SearchWindowAligns.Custom: - Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X; - Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y; - break; - } - } + double widthRatio = currentScreenWidth / _previousScreenWidth; + double heightRatio = currentScreenHeight / _previousScreenHeight; + double dpiXRatio = currentDpi.X / _previousDpiX; + double dpiYRatio = currentDpi.Y / _previousDpiY; - _previousScreenWidth = currentScreenWidth; - _previousScreenHeight = currentScreenHeight; - _previousDpiX = currentDpi.X; - _previousDpiY = currentDpi.Y; + _settings.WindowLeft *= widthRatio * dpiXRatio; + _settings.WindowTop *= heightRatio * dpiYRatio; + } + + if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) + { + Top = _settings.WindowTop; + Left = _settings.WindowLeft; + } + else + { + switch (_settings.SearchWindowAlign) + { + case SearchWindowAligns.Center: + Left = HorizonCenter(screen); + Top = VerticalCenter(screen); + break; + case SearchWindowAligns.CenterTop: + Left = HorizonCenter(screen); + Top = VerticalTop(screen); + break; + case SearchWindowAligns.LeftTop: + Left = HorizonLeft(screen); + Top = VerticalTop(screen); + break; + case SearchWindowAligns.RightTop: + Left = HorizonRight(screen); + Top = VerticalTop(screen); + break; + case SearchWindowAligns.Custom: + Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X; + Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y; + break; + } + } + + _previousScreenWidth = currentScreenWidth; + _previousScreenHeight = currentScreenHeight; + _previousDpiX = currentDpi.X; + _previousDpiY = currentDpi.Y; + } } private void UpdateNotifyIconText() From e0cdc92766b7a3602385be45911c187754ea9637 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 06:02:26 +0900 Subject: [PATCH 0024/1836] Revert "Adjust Code" This reverts commit 45dd84a3fa39e5784d9101bde4aabd5eff7e7969. --- Flow.Launcher/MainWindow.xaml.cs | 96 +++++++++++++++----------------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 927067f93..87e818154 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -307,61 +307,53 @@ namespace Flow.Launcher double currentScreenWidth = screen.WorkingArea.Width; double currentScreenHeight = screen.WorkingArea.Height; - if (!( - _previousScreenWidth == currentScreenWidth && - _previousScreenHeight == currentScreenHeight && - _previousDpiX == currentDpi.X && - _previousDpiY == currentDpi.Y - )) + if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0) { - if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0) - { - double widthRatio = currentScreenWidth / _previousScreenWidth; - double heightRatio = currentScreenHeight / _previousScreenHeight; - double dpiXRatio = currentDpi.X / _previousDpiX; - double dpiYRatio = currentDpi.Y / _previousDpiY; + double widthRatio = currentScreenWidth / _previousScreenWidth; + double heightRatio = currentScreenHeight / _previousScreenHeight; + double dpiXRatio = currentDpi.X / _previousDpiX; + double dpiYRatio = currentDpi.Y / _previousDpiY; - _settings.WindowLeft *= widthRatio * dpiXRatio; - _settings.WindowTop *= heightRatio * dpiYRatio; - } - - if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) - { - Top = _settings.WindowTop; - Left = _settings.WindowLeft; - } - else - { - switch (_settings.SearchWindowAlign) - { - case SearchWindowAligns.Center: - Left = HorizonCenter(screen); - Top = VerticalCenter(screen); - break; - case SearchWindowAligns.CenterTop: - Left = HorizonCenter(screen); - Top = VerticalTop(screen); - break; - case SearchWindowAligns.LeftTop: - Left = HorizonLeft(screen); - Top = VerticalTop(screen); - break; - case SearchWindowAligns.RightTop: - Left = HorizonRight(screen); - Top = VerticalTop(screen); - break; - case SearchWindowAligns.Custom: - Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X; - Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y; - break; - } - } - - _previousScreenWidth = currentScreenWidth; - _previousScreenHeight = currentScreenHeight; - _previousDpiX = currentDpi.X; - _previousDpiY = currentDpi.Y; + _settings.WindowLeft *= widthRatio * dpiXRatio; + _settings.WindowTop *= heightRatio * dpiYRatio; } + + if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) + { + Top = _settings.WindowTop; + Left = _settings.WindowLeft; + } + else + { + switch (_settings.SearchWindowAlign) + { + case SearchWindowAligns.Center: + Left = HorizonCenter(screen); + Top = VerticalCenter(screen); + break; + case SearchWindowAligns.CenterTop: + Left = HorizonCenter(screen); + Top = VerticalTop(screen); + break; + case SearchWindowAligns.LeftTop: + Left = HorizonLeft(screen); + Top = VerticalTop(screen); + break; + case SearchWindowAligns.RightTop: + Left = HorizonRight(screen); + Top = VerticalTop(screen); + break; + case SearchWindowAligns.Custom: + Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X; + Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y; + break; + } + } + + _previousScreenWidth = currentScreenWidth; + _previousScreenHeight = currentScreenHeight; + _previousDpiX = currentDpi.X; + _previousDpiY = currentDpi.Y; } private void UpdateNotifyIconText() From 5c6f539c6ffc469b70bdfc5839d2ed2ff0fcfae3 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 06:02:36 +0900 Subject: [PATCH 0025/1836] Reapply "Fix blurry situation when changed dpi in some case" This reverts commit ae0ec8ecf292ee56417da240966f516028f4c88d. --- Flow.Launcher/app.manifest | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Flow.Launcher/app.manifest b/Flow.Launcher/app.manifest index 52d1c3932..c45508fcf 100644 --- a/Flow.Launcher/app.manifest +++ b/Flow.Launcher/app.manifest @@ -49,13 +49,12 @@ DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> - From 4f16a1123fb2e28bf86b3bea711869a36d42f31f Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 06:02:52 +0900 Subject: [PATCH 0026/1836] Revert "Fix blurry situation when changed dpi in some case" This reverts commit 2869812a74160517b2cd4ba6a7436b40eaa59195. --- Flow.Launcher/app.manifest | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/app.manifest b/Flow.Launcher/app.manifest index c45508fcf..52d1c3932 100644 --- a/Flow.Launcher/app.manifest +++ b/Flow.Launcher/app.manifest @@ -49,12 +49,13 @@ DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> + From d2472084a2804bd2e3795051d6e1bf28ad08b0ee Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 06:02:55 +0900 Subject: [PATCH 0027/1836] =?UTF-8?q?Revert=20"When=20using=20the=20?= =?UTF-8?q?=E2=80=9Cremember=20last=20position=E2=80=9D=20setting,=20if=20?= =?UTF-8?q?the=20resolution=20or=20dpi=20has=20changed,=20the=20position?= =?UTF-8?q?=20will=20be=20rescaled=20proportionally"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 63ce735169afe7cf871d3d2a8eb6086e49fefa9a. --- Flow.Launcher/MainWindow.xaml.cs | 33 +------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 87e818154..6c0889295 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -27,7 +27,6 @@ using DataObject = System.Windows.DataObject; using System.Windows.Media; using System.Windows.Interop; using System.Runtime.InteropServices; -using System.Drawing; namespace Flow.Launcher { @@ -49,10 +48,6 @@ namespace Flow.Launcher private MediaPlayer animationSoundWMP; private SoundPlayer animationSoundWPF; - private double _previousScreenWidth; - private double _previousScreenHeight; - private double _previousDpiX; - private double _previousDpiY; #endregion @@ -293,31 +288,8 @@ namespace Flow.Launcher }; } - private (double X, double Y) GetCurrentDpi(Screen screen) - { - using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) - { - return (g.DpiX, g.DpiY); - } - } private void InitializePosition() { - var screen = SelectedScreen(); - var currentDpi = GetCurrentDpi(screen); - double currentScreenWidth = screen.WorkingArea.Width; - double currentScreenHeight = screen.WorkingArea.Height; - - if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0) - { - double widthRatio = currentScreenWidth / _previousScreenWidth; - double heightRatio = currentScreenHeight / _previousScreenHeight; - double dpiXRatio = currentDpi.X / _previousDpiX; - double dpiYRatio = currentDpi.Y / _previousDpiY; - - _settings.WindowLeft *= widthRatio * dpiXRatio; - _settings.WindowTop *= heightRatio * dpiYRatio; - } - if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { Top = _settings.WindowTop; @@ -325,6 +297,7 @@ namespace Flow.Launcher } else { + var screen = SelectedScreen(); switch (_settings.SearchWindowAlign) { case SearchWindowAligns.Center: @@ -350,10 +323,6 @@ namespace Flow.Launcher } } - _previousScreenWidth = currentScreenWidth; - _previousScreenHeight = currentScreenHeight; - _previousDpiX = currentDpi.X; - _previousDpiY = currentDpi.Y; } private void UpdateNotifyIconText() From ab40e7a2e4045772a36b6a6b6f712187e24be377 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 07:37:13 +0900 Subject: [PATCH 0028/1836] Adjust logic --- .../UserSettings/Settings.cs | 4 + Flow.Launcher/MainWindow.xaml.cs | 114 +++++++++++++++++- 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 458846665..c44e0369a 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -205,6 +205,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings public double WindowLeft { get; set; } public double WindowTop { get; set; } + public double PreviousScreenWidth { get; set; } + public double PreviousScreenHeight { get; set; } + public double PreviousDpiX { get; set; } + public double PreviousDpiY { get; set; } /// /// Custom left position on selected monitor diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 6c0889295..a699eaa64 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -27,6 +27,7 @@ using DataObject = System.Windows.DataObject; using System.Windows.Media; using System.Windows.Interop; using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.Arm; namespace Flow.Launcher { @@ -292,11 +293,39 @@ namespace Flow.Launcher { if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { - Top = _settings.WindowTop; + // Get the previous screen width, height, DPI X, and DPI Y + double previousScreenWidth = _settings.PreviousScreenWidth; + double previousScreenHeight = _settings.PreviousScreenHeight; + double previousDpiX = _settings.PreviousDpiX; + double previousDpiY = _settings.PreviousDpiY; + + // Save current screen width, height, DPI X, and DPI Y + _settings.PreviousScreenWidth = SystemParameters.VirtualScreenWidth; + _settings.PreviousScreenHeight = SystemParameters.VirtualScreenHeight; + _settings.PreviousDpiX = GetDpiX(); + _settings.PreviousDpiY = GetDpiY(); + + // If previous screen width, height, DPI X, or DPI Y are not zero + if (previousScreenWidth != 0 && previousScreenHeight != 0 && + previousDpiX != 0 && previousDpiY != 0) + { + // If previous and current screen properties are different, adjust position + if (previousScreenWidth != SystemParameters.VirtualScreenWidth || + previousScreenHeight != SystemParameters.VirtualScreenHeight || + previousDpiX != GetDpiX() || previousDpiY != GetDpiY()) + { + AdjustPositionForResolutionChange(); + return; + } + } + + // If previous screen width, height, DPI X, and DPI Y are the same, initialize with previous position Left = _settings.WindowLeft; + Top = _settings.WindowTop; } else { + // Keep the existing logic var screen = SelectedScreen(); switch (_settings.SearchWindowAlign) { @@ -322,9 +351,90 @@ namespace Flow.Launcher break; } } - } + private void AdjustPositionForResolutionChange() + { + double screenWidth = SystemParameters.VirtualScreenWidth; + double screenHeight = SystemParameters.VirtualScreenHeight; + double screenLeft = SystemParameters.VirtualScreenLeft; + double screenTop = SystemParameters.VirtualScreenTop; + double currentDpiX = GetDpiX(); + double currentDpiY = GetDpiY(); + + // Get current screen width, height, left, top, and DPI X, DPI Y + double currentScreenWidth = screenWidth; + double currentScreenHeight = screenHeight; + double currentScreenLeft = screenLeft; + double currentScreenTop = screenTop; + + // Get previous window left, top, and DPI X, DPI Y + double previousLeft = _settings.WindowLeft; + double previousTop = _settings.WindowTop; + double previousDpiX = _settings.PreviousDpiX; + double previousDpiY = _settings.PreviousDpiY; + + // Calculate ratios for width, height, DPI X, and DPI Y + double widthRatio = currentScreenWidth / _settings.PreviousScreenWidth; + double heightRatio = currentScreenHeight / _settings.PreviousScreenHeight; + double dpiXRatio = currentDpiX / previousDpiX; + double dpiYRatio = currentDpiY / previousDpiY; + + // Adjust previous position according to current resolution and DPI + double newLeft = previousLeft * widthRatio * dpiXRatio; + double newTop = previousTop * heightRatio * dpiYRatio; + + // Ensure the adjusted position is within the current screen boundaries + if (newLeft + ActualWidth > currentScreenLeft + currentScreenWidth) + { + newLeft = currentScreenLeft + currentScreenWidth - ActualWidth; + } + else if (newLeft < currentScreenLeft) + { + newLeft = currentScreenLeft; + } + + if (newTop + ActualHeight > currentScreenTop + currentScreenHeight) + { + newTop = currentScreenTop + currentScreenHeight - ActualHeight; + } + else if (newTop < currentScreenTop) + { + newTop = currentScreenTop; + } + + // Set the new position + Left = newLeft; + Top = newTop; + } + + private double GetDpiX() + { + // Get the PresentationSource for this visual + PresentationSource source = PresentationSource.FromVisual(this); + // Check if the PresentationSource and its CompositionTarget are not null + if (source != null && source.CompositionTarget != null) + { + // Get the transform matrix for the CompositionTarget + Matrix m = source.CompositionTarget.TransformToDevice; + // Calculate DPI in X direction + double dpiX = 96 * m.M11; + return dpiX; + } + return 96; //Return a default DPI of 96 if PresentationSource or CompositionTarget is null + } + + private double GetDpiY() + { + PresentationSource source = PresentationSource.FromVisual(this); + if (source != null && source.CompositionTarget != null) + { + Matrix m = source.CompositionTarget.TransformToDevice; + double dpiY = 96 * m.M22; + return dpiY; + } + return 96; + } private void UpdateNotifyIconText() { var menu = contextMenu; From 5df736267426dd5e2191e1d757895eae99ad1015 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 08:10:40 +0900 Subject: [PATCH 0029/1836] - Add Logic in settingwindow --- Flow.Launcher/SettingWindow.xaml.cs | 34 ++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index de4fd1f91..99c363222 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -112,23 +112,45 @@ public partial class SettingWindow { if (_settings.SettingWindowTop == null || _settings.SettingWindowLeft == null) { - Top = WindowTop(); - Left = WindowLeft(); + SetWindowPosition(WindowTop(), WindowLeft()); } else { - Top = _settings.SettingWindowTop.Value; - Left = _settings.SettingWindowLeft.Value; + double left = _settings.SettingWindowLeft.Value; + double top = _settings.SettingWindowTop.Value; + AdjustWindowPosition(ref top, ref left); + SetWindowPosition(top, left); } 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() { 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 - this.ActualWidth) / 2 + dip1.X; + var left = (dip2.X - ActualWidth) / 2 + dip1.X; return left; } @@ -137,7 +159,7 @@ public partial class SettingWindow var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); 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; } From 88c6fe3acbeef0e3cbb53d9d8f1308afb5a67678 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 09:32:46 +0900 Subject: [PATCH 0030/1836] Adjust Code --- Flow.Launcher/MainWindow.xaml.cs | 111 ++++++++++--------------------- 1 file changed, 34 insertions(+), 77 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index a699eaa64..b9b82909d 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -293,39 +293,31 @@ namespace Flow.Launcher { if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { - // Get the previous screen width, height, DPI X, and DPI Y double previousScreenWidth = _settings.PreviousScreenWidth; double previousScreenHeight = _settings.PreviousScreenHeight; - double previousDpiX = _settings.PreviousDpiX; - double previousDpiY = _settings.PreviousDpiY; + double previousDpiX, previousDpiY; + GetDpi(out previousDpiX, out previousDpiY); - // Save current screen width, height, DPI X, and DPI Y _settings.PreviousScreenWidth = SystemParameters.VirtualScreenWidth; _settings.PreviousScreenHeight = SystemParameters.VirtualScreenHeight; - _settings.PreviousDpiX = GetDpiX(); - _settings.PreviousDpiY = GetDpiY(); + double currentDpiX, currentDpiY; + GetDpi(out currentDpiX, out currentDpiY); - // If previous screen width, height, DPI X, or DPI Y are not zero if (previousScreenWidth != 0 && previousScreenHeight != 0 && - previousDpiX != 0 && previousDpiY != 0) + previousDpiX != 0 && previousDpiY != 0 && + (previousScreenWidth != SystemParameters.VirtualScreenWidth || + previousScreenHeight != SystemParameters.VirtualScreenHeight || + previousDpiX != currentDpiX || previousDpiY != currentDpiY)) { - // If previous and current screen properties are different, adjust position - if (previousScreenWidth != SystemParameters.VirtualScreenWidth || - previousScreenHeight != SystemParameters.VirtualScreenHeight || - previousDpiX != GetDpiX() || previousDpiY != GetDpiY()) - { - AdjustPositionForResolutionChange(); - return; - } + AdjustPositionForResolutionChange(); + return; } - // If previous screen width, height, DPI X, and DPI Y are the same, initialize with previous position Left = _settings.WindowLeft; Top = _settings.WindowTop; } else { - // Keep the existing logic var screen = SelectedScreen(); switch (_settings.SearchWindowAlign) { @@ -346,8 +338,10 @@ namespace Flow.Launcher Top = VerticalTop(screen); break; case SearchWindowAligns.Custom: - Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X; - Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y; + var customLeft = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0); + var customTop = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop); + Left = customLeft.X; + Top = customTop.Y; break; } } @@ -357,83 +351,46 @@ namespace Flow.Launcher { double screenWidth = SystemParameters.VirtualScreenWidth; double screenHeight = SystemParameters.VirtualScreenHeight; - double screenLeft = SystemParameters.VirtualScreenLeft; - double screenTop = SystemParameters.VirtualScreenTop; - double currentDpiX = GetDpiX(); - double currentDpiY = GetDpiY(); + double currentDpiX, currentDpiY; + GetDpi(out currentDpiX, out currentDpiY); - // Get current screen width, height, left, top, and DPI X, DPI Y - double currentScreenWidth = screenWidth; - double currentScreenHeight = screenHeight; - double currentScreenLeft = screenLeft; - double currentScreenTop = screenTop; - - // Get previous window left, top, and DPI X, DPI Y double previousLeft = _settings.WindowLeft; double previousTop = _settings.WindowTop; - double previousDpiX = _settings.PreviousDpiX; - double previousDpiY = _settings.PreviousDpiY; + double previousDpiX, previousDpiY; + GetDpi(out previousDpiX, out previousDpiY); - // Calculate ratios for width, height, DPI X, and DPI Y - double widthRatio = currentScreenWidth / _settings.PreviousScreenWidth; - double heightRatio = currentScreenHeight / _settings.PreviousScreenHeight; + double widthRatio = screenWidth / _settings.PreviousScreenWidth; + double heightRatio = screenHeight / _settings.PreviousScreenHeight; double dpiXRatio = currentDpiX / previousDpiX; double dpiYRatio = currentDpiY / previousDpiY; - // Adjust previous position according to current resolution and DPI double newLeft = previousLeft * widthRatio * dpiXRatio; double newTop = previousTop * heightRatio * dpiYRatio; - // Ensure the adjusted position is within the current screen boundaries - if (newLeft + ActualWidth > currentScreenLeft + currentScreenWidth) - { - newLeft = currentScreenLeft + currentScreenWidth - ActualWidth; - } - else if (newLeft < currentScreenLeft) - { - newLeft = currentScreenLeft; - } + double screenLeft = SystemParameters.VirtualScreenLeft; + double screenTop = SystemParameters.VirtualScreenTop; - if (newTop + ActualHeight > currentScreenTop + currentScreenHeight) - { - newTop = currentScreenTop + currentScreenHeight - ActualHeight; - } - else if (newTop < currentScreenTop) - { - newTop = currentScreenTop; - } + double maxX = screenLeft + screenWidth - ActualWidth; + double maxY = screenTop + screenHeight - ActualHeight; - // Set the new position - Left = newLeft; - Top = newTop; + Left = Math.Max(screenLeft, Math.Min(newLeft, maxX)); + Top = Math.Max(screenTop, Math.Min(newTop, maxY)); } - private double GetDpiX() - { - // Get the PresentationSource for this visual - PresentationSource source = PresentationSource.FromVisual(this); - // Check if the PresentationSource and its CompositionTarget are not null - if (source != null && source.CompositionTarget != null) - { - // Get the transform matrix for the CompositionTarget - Matrix m = source.CompositionTarget.TransformToDevice; - // Calculate DPI in X direction - double dpiX = 96 * m.M11; - return dpiX; - } - return 96; //Return a default DPI of 96 if PresentationSource or CompositionTarget is null - } - - private double GetDpiY() + private void GetDpi(out double dpiX, out double dpiY) { PresentationSource source = PresentationSource.FromVisual(this); if (source != null && source.CompositionTarget != null) { Matrix m = source.CompositionTarget.TransformToDevice; - double dpiY = 96 * m.M22; - return dpiY; + dpiX = 96 * m.M11; + dpiY = 96 * m.M22; + } + else + { + dpiX = 96; + dpiY = 96; } - return 96; } private void UpdateNotifyIconText() { From 1bd9e8131d2a50ccd28a3600c15e0049bc34fdc8 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 09:35:44 +0900 Subject: [PATCH 0031/1836] Fix app manifest --- Flow.Launcher/app.manifest | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/app.manifest b/Flow.Launcher/app.manifest index 52d1c3932..b6944273a 100644 --- a/Flow.Launcher/app.manifest +++ b/Flow.Launcher/app.manifest @@ -49,13 +49,12 @@ DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> - From e863d998ab4698dbdf73bb813f59d543e620e223 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 6 Jun 2024 09:36:25 +0900 Subject: [PATCH 0032/1836] Adjust Typo --- Flow.Launcher/app.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/app.manifest b/Flow.Launcher/app.manifest index b6944273a..c45508fcf 100644 --- a/Flow.Launcher/app.manifest +++ b/Flow.Launcher/app.manifest @@ -49,7 +49,7 @@ DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> - + true PerMonitorV2, PerMonitor From ca970bbe75d914e65791446e5d39c7bffd5d153c Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Sun, 9 Jun 2024 18:45:23 +0600 Subject: [PATCH 0033/1836] Localize startup messages about missing Python/NodeJS --- .../Environments/AbstractPluginEnvironment.cs | 19 ++++++++++--------- Flow.Launcher.Core/Plugin/PluginManager.cs | 4 ++++ .../Resource/Internationalization.cs | 3 +-- Flow.Launcher/App.xaml.cs | 8 +++----- Flow.Launcher/Languages/en.xaml | 9 +++++++++ Flow.Launcher/Languages/ru.xaml | 8 ++++++++ 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs index 40eb1be3e..30e812c6f 100644 --- a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs +++ b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows.Forms; +using Flow.Launcher.Core.Resource; namespace Flow.Launcher.Core.ExternalPlugins.Environments { @@ -50,14 +51,15 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments return SetPathForPluginPairs(PluginsSettingsFilePath, Language); } - if (MessageBox.Show($"Flow detected you have installed {Language} plugins, which " + - $"will require {EnvName} to run. Would you like to download {EnvName}? " + - Environment.NewLine + Environment.NewLine + - "Click no if it's already installed, " + - $"and you will be prompted to select the folder that contains the {EnvName} executable", - string.Empty, MessageBoxButtons.YesNo) == DialogResult.No) + var noRuntimeMessage = string.Format( + InternationalizationManager.Instance.GetTranslation("runtimePluginInstalledChooseRuntimePrompt"), + Language, + EnvName, + Environment.NewLine + ); + if (MessageBox.Show(noRuntimeMessage, string.Empty, MessageBoxButtons.YesNo) == DialogResult.No) { - var msg = $"Please select the {EnvName} executable"; + var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName); string selectedFile; selectedFile = GetFileFromDialog(msg, FileDialogFilter); @@ -80,8 +82,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments } else { - MessageBox.Show( - $"Unable to set {Language} executable path, please try from Flow's settings (scroll down to the bottom)."); + MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language)); Log.Error("PluginsLoader", $"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.", $"{Language}Environment"); diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index e7dfb31c0..3c8d654fe 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -13,6 +13,7 @@ using Flow.Launcher.Plugin; using ISavable = Flow.Launcher.Plugin.ISavable; using Flow.Launcher.Plugin.SharedCommands; using System.Text.Json; +using Flow.Launcher.Core.Resource; namespace Flow.Launcher.Core.Plugin { @@ -160,6 +161,9 @@ namespace Flow.Launcher.Core.Plugin } } + InternationalizationManager.Instance.AddPluginLanguageDirectories(); + InternationalizationManager.Instance.ChangeLanguage(InternationalizationManager.Instance.Settings.Language); + if (failedPlugins.Any()) { var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name)); diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 06eb868b8..741cb9f3b 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -25,7 +25,6 @@ namespace Flow.Launcher.Core.Resource public Internationalization() { - AddPluginLanguageDirectories(); LoadDefaultLanguage(); // we don't want to load /Languages/en.xaml twice // so add flowlauncher language directory after load plugin language files @@ -40,7 +39,7 @@ namespace Flow.Launcher.Core.Resource } - private void AddPluginLanguageDirectories() + internal void AddPluginLanguageDirectories() { foreach (var plugin in PluginManager.GetPluginsForInterface()) { diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 765a1a559..4d1adc6cd 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -71,6 +71,9 @@ namespace Flow.Launcher StringMatcher.Instance = _stringMatcher; _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; + InternationalizationManager.Instance.Settings = _settings; + InternationalizationManager.Instance.ChangeLanguage(_settings.Language); + PluginManager.LoadPlugins(_settings.PluginSettings); _mainVM = new MainViewModel(_settings); @@ -89,11 +92,6 @@ namespace Flow.Launcher Current.MainWindow = window; Current.MainWindow.Title = Constant.FlowLauncher; - // todo temp fix for instance code logic - // load plugin before change language, because plugin language also needs be changed - InternationalizationManager.Instance.Settings = _settings; - InternationalizationManager.Instance.ChangeLanguage(_settings.Language); - HotKeyMapper.Initialize(_mainVM); // main windows needs initialized before theme change because of blur settings diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 83831a398..700e60933 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -2,6 +2,15 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> + + + Flow detected you have installed {0} plugins, which will require {1} to run. Would you like to download {1}? + {2}{2} + Click no if it's already installed, and you will be prompted to select the folder that contains the {1} executable + + Please select the {0} executable + Unable to set {0} executable path, please try from Flow's settings (scroll down to the bottom). + Failed to register hotkey "{0}". The hotkey may be in use by another program. Change to a different hotkey, or exit another program. Flow Launcher diff --git a/Flow.Launcher/Languages/ru.xaml b/Flow.Launcher/Languages/ru.xaml index 739252da7..74d9ded0f 100644 --- a/Flow.Launcher/Languages/ru.xaml +++ b/Flow.Launcher/Languages/ru.xaml @@ -3,6 +3,14 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> + + + Flow определил, что вы установили {0} плагины, которым требуется {1} для работы. Скачать {1}? + {2}{2} + Кликните нет, если он уже установлен, и вам будет предложено выбрать папку, где находится исполняемый файл {1} + + Please select the {0} executable + Unable to set {0} executable path, please try from Flow's settings (scroll down to the bottom). Не удалось зарегистрировать сочетание клавиш "{0}". Возможно, оно используется другой программой. Измените сочетание клавиш или закройте другую программу. Flow Launcher From 49a71d7d53a3c66a3feac30f743f625f47059f83 Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Sat, 15 Jun 2024 12:16:36 +0100 Subject: [PATCH 0034/1836] Move Theme Selector into Sys plugin --- ...w.Launcher.Plugin.FlowThemeSelector.csproj | 37 ------------------ .../plugin.json | 12 ------ .../Flow.Launcher.Plugin.Sys.csproj | 1 + .../Images/theme_selector.png} | Bin .../Languages/en.xaml | 4 +- Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 29 +++++++++++++- .../ThemeSelector.cs} | 24 +++++++----- 7 files changed, 45 insertions(+), 62 deletions(-) delete mode 100644 Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj delete mode 100644 Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json rename Plugins/{Flow.Launcher.Plugin.FlowThemeSelector/icon.png => Flow.Launcher.Plugin.Sys/Images/theme_selector.png} (100%) rename Plugins/{Flow.Launcher.Plugin.FlowThemeSelector/Main.cs => Flow.Launcher.Plugin.Sys/ThemeSelector.cs} (72%) diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj deleted file mode 100644 index ba0ddd6ab..000000000 --- a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Flow.Launcher.Plugin.FlowThemeSelector.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - - Library - net7.0-windows - true - false - - - - ..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.FlowThemeSelector - - - - ..\..\Output\Release\Plugins\Flow.Launcher.Plugin.FlowThemeSelector - - - - - - - - - - - PreserveNewest - - - - - - PreserveNewest - - - - diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json b/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json deleted file mode 100644 index f275d129c..000000000 --- a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/plugin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ID": "4DFA743E1086414BAB0AA3071D561D75", - "ActionKeyword": "flowtheme", - "Name": "Flow Launcher Theme Selector", - "Description": "Quickly switch your Flow Launcher theme.", - "Author": "Odotocodot", - "Version": "1.0.0", - "Language": "csharp", - "Website": "https://github.com/Flow-Launcher/Flow.Launcher", - "IcoPath": "icon.png", - "ExecuteFileName": "Flow.Launcher.Plugin.FlowThemeSelector.dll" -} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj index c7a722189..bba466384 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj +++ b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj @@ -38,6 +38,7 @@ + diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/icon.png b/Plugins/Flow.Launcher.Plugin.Sys/Images/theme_selector.png similarity index 100% rename from Plugins/Flow.Launcher.Plugin.FlowThemeSelector/icon.png rename to Plugins/Flow.Launcher.Plugin.Sys/Images/theme_selector.png diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml index 91f32a844..2a266f8f6 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml @@ -27,6 +27,7 @@ Flow Launcher Tips Flow Launcher UserData Folder Toggle Game Mode + Set the Flow Launcher Theme Shutdown Computer @@ -49,8 +50,9 @@ Visit Flow Launcher's documentation for more help and how to use tips Open the location where Flow Launcher's settings are stored Toggle Game Mode + Quickly change the Flow Launcher theme - + Success All Flow Launcher settings saved Reloaded all applicable plugin data diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index 1ec07915d..0dbb46be9 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -18,9 +18,10 @@ using MessageBox = System.Windows.MessageBox; namespace Flow.Launcher.Plugin.Sys { - public class Main : IPlugin, ISettingProvider, IPluginI18n + public class Main : IPlugin, ISettingProvider, IPluginI18n, IDisposable { private PluginInitContext context; + private ThemeSelector themeSelector; private Dictionary KeywordTitleMappings = new Dictionary(); #region DllImport @@ -58,6 +59,11 @@ namespace Flow.Launcher.Plugin.Sys public List Query(Query query) { + if(query.Search.StartsWith(ThemeSelector.Keyword)) + { + return themeSelector.Query(query); + } + var commands = Commands(); var results = new List(); foreach (var c in commands) @@ -106,6 +112,7 @@ namespace Flow.Launcher.Plugin.Sys public void Init(PluginInitContext context) { this.context = context; + themeSelector = new ThemeSelector(context); KeywordTitleMappings = new Dictionary{ {"Shutdown", "flowlauncher_plugin_sys_shutdown_computer_cmd"}, {"Restart", "flowlauncher_plugin_sys_restart_computer_cmd"}, @@ -126,7 +133,8 @@ namespace Flow.Launcher.Plugin.Sys {"Open Log Location", "flowlauncher_plugin_sys_open_log_location_cmd"}, {"Flow Launcher Tips", "flowlauncher_plugin_sys_open_docs_tips_cmd"}, {"Flow Launcher UserData Folder", "flowlauncher_plugin_sys_open_userdata_location_cmd"}, - {"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"} + {"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"}, + {"Set Flow Launcher Theme", "flowlauncher_plugin_sys_theme_selector_cmd"} }; } @@ -426,6 +434,18 @@ namespace Flow.Launcher.Plugin.Sys context.API.ToggleGameMode(); return true; } + }, + new Result + { + Title = "Set Flow Launcher Theme", + SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_theme_selector"), + IcoPath = "Images\\theme_selector.png", + Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue790"), + Action = c => + { + context.API.ChangeQuery($"{ThemeSelector.Keyword} "); + return false; + } } }); @@ -441,5 +461,10 @@ namespace Flow.Launcher.Plugin.Sys { return context.API.GetTranslation("flowlauncher_plugin_sys_plugin_description"); } + + public void Dispose() + { + themeSelector.Dispose(); + } } } diff --git a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs similarity index 72% rename from Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Main.cs rename to Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs index 6fd6472db..24d17486e 100644 --- a/Plugins/Flow.Launcher.Plugin.FlowThemeSelector/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs @@ -4,14 +4,16 @@ using System.IO; using System.Linq; using Flow.Launcher.Core.Resource; -namespace Flow.Launcher.Plugin.FlowThemeSelector +namespace Flow.Launcher.Plugin.Sys { - public class FlowThemeSelector : IPlugin, IReloadable, IDisposable + public class ThemeSelector : IReloadable, IDisposable { - private PluginInitContext context; + public const string Keyword = "fltheme"; + + private readonly PluginInitContext context; private IEnumerable themes; - public void Init(PluginInitContext context) + public ThemeSelector(PluginInitContext context) { this.context = context; context.API.VisibilityChanged += OnVisibilityChanged; @@ -24,14 +26,16 @@ namespace Flow.Launcher.Plugin.FlowThemeSelector LoadThemes(); } - if (string.IsNullOrWhiteSpace(query.Search)) + string search = query.Search[(query.Search.IndexOf(Keyword, StringComparison.Ordinal) + Keyword.Length + 1)..]; + + if (string.IsNullOrWhiteSpace(search)) { return themes.Select(CreateThemeResult) .OrderBy(x => x.Title) .ToList(); } - return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(query.Search, theme))) + return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(search, theme))) .Where(x => x.matchResult.IsSearchPrecisionScoreMet()) .Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData)) .OrderBy(x => x.Title) @@ -46,11 +50,12 @@ namespace Flow.Launcher.Plugin.FlowThemeSelector } } - public void LoadThemes() => themes = ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension); + private void LoadThemes() + => themes = ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension); - public static Result CreateThemeResult(string theme) => CreateThemeResult(theme, 0, null); + private static Result CreateThemeResult(string theme) => CreateThemeResult(theme, 0, null); - public static Result CreateThemeResult(string theme, int score, IList highlightData) + private static Result CreateThemeResult(string theme, int score, IList highlightData) { string title; if (theme == ThemeManager.Instance.Settings.Theme) @@ -86,6 +91,5 @@ namespace Flow.Launcher.Plugin.FlowThemeSelector context.API.VisibilityChanged -= OnVisibilityChanged; } } - } } From 7a0be2c6103939312eeead86c3a1e01a3d618a3f Mon Sep 17 00:00:00 2001 From: Odotocodot <48138990+Odotocodot@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:50:00 +0100 Subject: [PATCH 0035/1836] Remove Reloadable from theme selector --- Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs b/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs index 24d17486e..758250421 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs @@ -6,7 +6,7 @@ using Flow.Launcher.Core.Resource; namespace Flow.Launcher.Plugin.Sys { - public class ThemeSelector : IReloadable, IDisposable + public class ThemeSelector : IDisposable { public const string Keyword = "fltheme"; @@ -82,8 +82,6 @@ namespace Flow.Launcher.Plugin.Sys }; } - public void ReloadData() => LoadThemes(); - public void Dispose() { if (context != null && context.API != null) From ce100c46278eb3d94fae35ba0b34a7ab9171f633 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 19 Jun 2024 11:38:34 -0700 Subject: [PATCH 0036/1836] refactor code with Point2D.cs --- .../UserSettings/Point2D.cs | 46 +++++ .../UserSettings/Settings.cs | 10 +- Flow.Launcher/MainWindow.xaml.cs | 177 ++++++++---------- Flow.Launcher/ViewModel/MainViewModel.cs | 6 +- 4 files changed, 133 insertions(+), 106 deletions(-) create mode 100644 Flow.Launcher.Infrastructure/UserSettings/Point2D.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Point2D.cs b/Flow.Launcher.Infrastructure/UserSettings/Point2D.cs new file mode 100644 index 000000000..4c47ba6c0 --- /dev/null +++ b/Flow.Launcher.Infrastructure/UserSettings/Point2D.cs @@ -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)); + } +} diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index c44e0369a..c216efad2 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -203,12 +203,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings public bool AutoUpdates { get; set; } = false; - public double WindowLeft { get; set; } - public double WindowTop { get; set; } - public double PreviousScreenWidth { get; set; } - public double PreviousScreenHeight { get; set; } - public double PreviousDpiX { get; set; } - public double PreviousDpiY { get; set; } + + public Point2D WindowPosition { get; set; } + public Point2D PreviousScreen { get; set; } + public Point2D PreviousDpi { get; set; } /// /// Custom left position on selected monitor diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index b9b82909d..3516d7e69 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -73,11 +73,7 @@ namespace Flow.Launcher }; } - DispatcherTimer timer = new DispatcherTimer - { - Interval = new TimeSpan(0, 0, 0, 0, 500), - IsEnabled = false - }; + DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500), IsEnabled = false }; public MainWindow() { @@ -88,6 +84,7 @@ namespace Flow.Launcher private const int WM_EXITSIZEMOVE = 0x0232; private int _initialWidth; private int _initialHeight; + private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == WM_ENTERSIZEMOVE) @@ -96,18 +93,22 @@ namespace Flow.Launcher _initialHeight = (int)Height; handled = true; } + if (msg == WM_EXITSIZEMOVE) { - if ( _initialHeight != (int)Height) + if (_initialHeight != (int)Height) { OnResizeEnd(); } + if (_initialWidth != (int)Width) { FlowMainWindow.SizeToContent = SizeToContent.Height; } + handled = true; } + return IntPtr.Zero; } @@ -132,6 +133,7 @@ namespace Flow.Launcher _settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount)); } } + FlowMainWindow.SizeToContent = SizeToContent.Height; _viewModel.MainWindowWidth = Width; } @@ -176,6 +178,7 @@ namespace Flow.Launcher private void OnInitialized(object sender, EventArgs e) { } + private void OnLoaded(object sender, RoutedEventArgs _) { // MouseEventHandler @@ -207,6 +210,7 @@ namespace Flow.Launcher { SoundPlay(); } + UpdatePosition(); PreviewReset(); Activate(); @@ -218,7 +222,8 @@ namespace Flow.Launcher _viewModel.LastQuerySelected = true; } - if (_viewModel.ProgressBarVisibility == Visibility.Visible && isProgressBarStoryboardPaused) + if (_viewModel.ProgressBarVisibility == Visibility.Visible && + isProgressBarStoryboardPaused) { _progressBarStoryboard.Begin(ProgressBar, true); isProgressBarStoryboardPaused = false; @@ -259,9 +264,12 @@ namespace Flow.Launcher MoveQueryTextToEnd(); _viewModel.QueryTextCursorMovedToEnd = false; } + break; 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; } }; @@ -279,11 +287,8 @@ namespace Flow.Launcher case nameof(Settings.Hotkey): UpdateNotifyIconText(); break; - case nameof(Settings.WindowLeft): - Left = _settings.WindowLeft; - break; - case nameof(Settings.WindowTop): - Top = _settings.WindowTop; + case nameof(Settings.WindowPosition): + (Left, Top) = _settings.WindowPosition; break; } }; @@ -293,28 +298,24 @@ namespace Flow.Launcher { if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { - double previousScreenWidth = _settings.PreviousScreenWidth; - double previousScreenHeight = _settings.PreviousScreenHeight; - double previousDpiX, previousDpiY; - GetDpi(out previousDpiX, out previousDpiY); + var previousScreen = _settings.PreviousScreen; - _settings.PreviousScreenWidth = SystemParameters.VirtualScreenWidth; - _settings.PreviousScreenHeight = SystemParameters.VirtualScreenHeight; - double currentDpiX, currentDpiY; - GetDpi(out currentDpiX, out currentDpiY); + var previousDpi = _settings.PreviousDpi; - if (previousScreenWidth != 0 && previousScreenHeight != 0 && - previousDpiX != 0 && previousDpiY != 0 && - (previousScreenWidth != SystemParameters.VirtualScreenWidth || - previousScreenHeight != SystemParameters.VirtualScreenHeight || - previousDpiX != currentDpiX || previousDpiY != currentDpiY)) + _settings.PreviousScreen = (SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight); + + var currentDpi = GetDpi(); + + if (previousScreen != default || + previousDpi != default || + (previousScreen != (SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight) || + previousDpi != currentDpi)) { AdjustPositionForResolutionChange(); return; } - Left = _settings.WindowLeft; - Top = _settings.WindowTop; + (Left, Top) = _settings.WindowPosition; } else { @@ -338,8 +339,10 @@ namespace Flow.Launcher Top = VerticalTop(screen); break; case SearchWindowAligns.Custom: - var customLeft = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0); - var customTop = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop); + var customLeft = WindowsInteropHelper.TransformPixelsToDIP(this, + screen.WorkingArea.X + _settings.CustomWindowLeft, 0); + var customTop = WindowsInteropHelper.TransformPixelsToDIP(this, 0, + screen.WorkingArea.Y + _settings.CustomWindowTop); Left = customLeft.X; Top = customTop.Y; break; @@ -349,58 +352,48 @@ namespace Flow.Launcher private void AdjustPositionForResolutionChange() { - double screenWidth = SystemParameters.VirtualScreenWidth; - double screenHeight = SystemParameters.VirtualScreenHeight; - double currentDpiX, currentDpiY; - GetDpi(out currentDpiX, out currentDpiY); + Point2D screenBound = (SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight); - double previousLeft = _settings.WindowLeft; - double previousTop = _settings.WindowTop; - double previousDpiX, previousDpiY; - GetDpi(out previousDpiX, out previousDpiY); + var currentDpi = GetDpi(); - double widthRatio = screenWidth / _settings.PreviousScreenWidth; - double heightRatio = screenHeight / _settings.PreviousScreenHeight; - double dpiXRatio = currentDpiX / previousDpiX; - double dpiYRatio = currentDpiY / previousDpiY; + var previousPosition = _settings.WindowPosition; - double newLeft = previousLeft * widthRatio * dpiXRatio; - double newTop = previousTop * heightRatio * dpiYRatio; + var ratio = screenBound / _settings.PreviousScreen; - double screenLeft = SystemParameters.VirtualScreenLeft; - double screenTop = SystemParameters.VirtualScreenTop; + var dpiXRatio = currentDpi / _settings.PreviousDpi; - double maxX = screenLeft + screenWidth - ActualWidth; - double maxY = screenTop + screenHeight - ActualHeight; + var newPosition = previousPosition * ratio * dpiXRatio; - Left = Math.Max(screenLeft, Math.Min(newLeft, maxX)); - Top = Math.Max(screenTop, Math.Min(newTop, maxY)); + Point2D screenPosition = (SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop); + + var maxPosition = screenPosition + screenBound - (ActualWidth, ActualHeight); + + (Left, Top) = newPosition.Clamp(screenPosition, maxPosition); } - private void GetDpi(out double dpiX, out double dpiY) + private Point2D GetDpi() { PresentationSource source = PresentationSource.FromVisual(this); - if (source != null && source.CompositionTarget != null) + Point2D point = (96, 96); + if (source is { CompositionTarget: not null }) { Matrix m = source.CompositionTarget.TransformToDevice; - dpiX = 96 * m.M11; - dpiY = 96 * m.M22; - } - else - { - dpiX = 96; - dpiY = 96; + point.X = 96 * m.M11; + point.Y = 96 * m.M22; } + + return point; } + private void UpdateNotifyIconText() { 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[2]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset"); ((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"); ((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"); - } private void InitializeNotifyIcon() @@ -412,50 +405,34 @@ namespace Flow.Launcher Visible = !_settings.HideNotifyIcon }; - var openIcon = new FontIcon - { - Glyph = "\ue71e" - }; + var openIcon = new FontIcon { Glyph = "\ue71e" }; var open = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")", + Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + + _settings.Hotkey + ")", Icon = openIcon }; - var gamemodeIcon = new FontIcon - { - Glyph = "\ue7fc" - }; + var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" }; var gamemode = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("GameMode"), - Icon = gamemodeIcon - }; - var positionresetIcon = new FontIcon - { - Glyph = "\ue73f" + Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon }; + var positionresetIcon = new FontIcon { Glyph = "\ue73f" }; var positionreset = new MenuItem { Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), Icon = positionresetIcon }; - var settingsIcon = new FontIcon - { - Glyph = "\ue713" - }; + var settingsIcon = new FontIcon { Glyph = "\ue713" }; var settings = new MenuItem { Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"), Icon = settingsIcon }; - var exitIcon = new FontIcon - { - Glyph = "\ue7e8" - }; + var exitIcon = new FontIcon { Glyph = "\ue7e8" }; var exit = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), - Icon = exitIcon + Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon }; open.Click += (o, e) => _viewModel.ToggleFlowLauncher(); @@ -488,6 +465,7 @@ namespace Flow.Launcher { _ = SetForegroundWindow(hwndSource.Handle); } + contextMenu.Focus(); break; } @@ -521,8 +499,10 @@ namespace Flow.Launcher private void InitProgressbarAnimation() { - var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, 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))); + var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, + 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(da1, new PropertyPath("(Line.X1)")); _progressBarStoryboard.Children.Add(da); @@ -624,14 +604,14 @@ namespace Flow.Launcher iconsb.Children.Add(IconOpacity); windowsb.Completed += (_, _) => _animating = false; - _settings.WindowLeft = Left; - _settings.WindowTop = Top; + _settings.WindowPosition = (Left, Top); isArrowKeyPressed = false; if (QueryTextBox.Text.Length == 0) { clocksb.Begin(ClockPanel); } + iconsb.Begin(SearchIcon); windowsb.Begin(FlowMainWindow); } @@ -685,8 +665,7 @@ namespace Flow.Launcher private async void OnDeactivated(object sender, EventArgs e) { - _settings.WindowLeft = Left; - _settings.WindowTop = Top; + _settings.WindowPosition = (Left, Top); //This condition stops extra hide call when animator is on, // which causes the toggling to occasional hide instead of show. if (_viewModel.MainWindowVisibilityStatus) @@ -717,8 +696,7 @@ namespace Flow.Launcher return; if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { - _settings.WindowLeft = Left; - _settings.WindowTop = Top; + _settings.WindowPosition = (Left, Top); } } @@ -738,7 +716,7 @@ namespace Flow.Launcher public Screen SelectedScreen() { Screen screen = null; - switch(_settings.SearchWindowScreen) + switch (_settings.SearchWindowScreen) { case SearchWindowScreens.Cursor: screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); @@ -760,6 +738,7 @@ namespace Flow.Launcher screen = Screen.AllScreens[0]; break; } + return screen ?? Screen.AllScreens[0]; } @@ -797,7 +776,7 @@ namespace Flow.Launcher public double VerticalTop(Screen screen) { var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); - var top = dip1.Y +10; + var top = dip1.Y + 10; return top; } @@ -836,6 +815,7 @@ namespace Flow.Launcher _viewModel.LoadContextMenuCommand.Execute(null); e.Handled = true; } + break; case Key.Left: if (!_viewModel.SelectedIsFromQueryResults() && QueryTextBox.CaretIndex == 0) @@ -843,6 +823,7 @@ namespace Flow.Launcher _viewModel.EscCommand.Execute(null); e.Handled = true; } + break; case Key.Back: if (specialKeyState.CtrlPressed) @@ -861,12 +842,13 @@ namespace Flow.Launcher } } } + break; default: break; - } } + private void OnKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Up || e.Key == Key.Down) @@ -882,6 +864,7 @@ namespace Flow.Launcher e.Handled = true; // Ignore Mouse Hover when press Arrowkeys } } + public void PreviewReset() { _viewModel.ResetPreview(); diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index a793ceaa5..406d2af58 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -543,20 +543,20 @@ namespace Flow.Launcher.ViewModel private void IncreaseWidth() { Settings.WindowSize += 100; - Settings.WindowLeft -= 50; + Settings.WindowPosition -= (50, 0); OnPropertyChanged(nameof(MainWindowWidth)); } [RelayCommand] private void DecreaseWidth() { - if (MainWindowWidth - 100 < 400 || Settings.WindowSize == 400) + if (MainWindowWidth - 100 < 400 || Math.Abs(Settings.WindowSize - 400) < 0.01) { Settings.WindowSize = 400; } else { - Settings.WindowLeft += 50; + Settings.WindowPosition += (50, 0); Settings.WindowSize -= 100; } From feaf6c45c128fb59d0e9f9bbfe75e4e7cc472d35 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 19 Jun 2024 11:42:37 -0700 Subject: [PATCH 0037/1836] fix a variable name --- Flow.Launcher/MainWindow.xaml.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index ae57e7934..4fd0145db 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -360,15 +360,15 @@ namespace Flow.Launcher var ratio = screenBound / _settings.PreviousScreen; - var dpiXRatio = currentDpi / _settings.PreviousDpi; + var dpiRatio = currentDpi / _settings.PreviousDpi; - var newPosition = previousPosition * ratio * dpiXRatio; + var newPosition = previousPosition * ratio * dpiRatio; - Point2D screenPosition = (SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop); + Point2D minPosition = (SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop); - var maxPosition = screenPosition + screenBound - (ActualWidth, ActualHeight); + var maxPosition = minPosition + screenBound - (ActualWidth, ActualHeight); - (Left, Top) = newPosition.Clamp(screenPosition, maxPosition); + (Left, Top) = newPosition.Clamp(minPosition, maxPosition); } private Point2D GetDpi() From 70a24e077459309a62b19481741b29d5509c96e3 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 19 Jun 2024 11:43:23 -0700 Subject: [PATCH 0038/1836] remove unused intrinsic --- Flow.Launcher/MainWindow.xaml.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 4fd0145db..9e09c3470 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -27,7 +27,6 @@ using DataObject = System.Windows.DataObject; using System.Windows.Media; using System.Windows.Interop; using System.Runtime.InteropServices; -using System.Runtime.Intrinsics.Arm; namespace Flow.Launcher { From 58caa493bcec26ef74e5b93653b94111ca1356fb Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 19 Jun 2024 11:45:23 -0700 Subject: [PATCH 0039/1836] fix logic --- Flow.Launcher/MainWindow.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 9e09c3470..4027e7698 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -305,8 +305,8 @@ namespace Flow.Launcher var currentDpi = GetDpi(); - if (previousScreen != default || - previousDpi != default || + if (previousScreen == default || + previousDpi == default || (previousScreen != (SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight) || previousDpi != currentDpi)) { From 6bf23c939db096e79a6da603612ddef534261627 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:07:12 +0000 Subject: [PATCH 0040/1836] Bump BitFaster.Caching from 2.5.0 to 2.5.1 Bumps [BitFaster.Caching](https://github.com/bitfaster/BitFaster.Caching) from 2.5.0 to 2.5.1. - [Release notes](https://github.com/bitfaster/BitFaster.Caching/releases) - [Commits](https://github.com/bitfaster/BitFaster.Caching/compare/v2.5.0...v2.5.1) --- updated-dependencies: - dependency-name: BitFaster.Caching dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Infrastructure.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj index 7d6448c43..688b40c83 100644 --- a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj +++ b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj @@ -49,7 +49,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From d167813e66f38f440f65f419b1a0d234f35f6619 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:08:21 +0000 Subject: [PATCH 0041/1836] Bump Microsoft.NET.Test.Sdk from 17.9.0 to 17.10.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.9.0 to 17.10.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.9.0...v17.10.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Flow.Launcher.Test/Flow.Launcher.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Test/Flow.Launcher.Test.csproj b/Flow.Launcher.Test/Flow.Launcher.Test.csproj index fd967de4a..9f2b64134 100644 --- a/Flow.Launcher.Test/Flow.Launcher.Test.csproj +++ b/Flow.Launcher.Test/Flow.Launcher.Test.csproj @@ -54,7 +54,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + \ No newline at end of file From 83830472cbae4c2b1181b4a038c2127360e6d00c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:09:41 +0000 Subject: [PATCH 0042/1836] Bump FSharp.Core from 7.0.401 to 8.0.300 Bumps [FSharp.Core](https://github.com/dotnet/fsharp) from 7.0.401 to 8.0.300. - [Release notes](https://github.com/dotnet/fsharp/releases) - [Changelog](https://github.com/dotnet/fsharp/blob/main/release-notes.md) - [Commits](https://github.com/dotnet/fsharp/commits) --- updated-dependencies: - dependency-name: FSharp.Core dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Flow.Launcher.Core/Flow.Launcher.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Flow.Launcher.Core.csproj b/Flow.Launcher.Core/Flow.Launcher.Core.csproj index fe2cb7e58..6d97e1c52 100644 --- a/Flow.Launcher.Core/Flow.Launcher.Core.csproj +++ b/Flow.Launcher.Core/Flow.Launcher.Core.csproj @@ -54,7 +54,7 @@ - + From 7a5fc1c534e90e7af1e3a3cdbb5696c5fb31766a Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 25 Jun 2024 16:35:32 +0900 Subject: [PATCH 0043/1836] Add Exception handling for qttabbar --- .../UserSettings/Settings.cs | 9 +++- Flow.Launcher/PublicAPIInstance.cs | 45 +++++++++++++------ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0c7de10fd..5e66eaff9 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -91,7 +91,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings public double? SettingWindowTop { get; set; } = null; public double? SettingWindowLeft { get; set; } = null; public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal; - public int CustomExplorerIndex { get; set; } = 0; [JsonIgnore] @@ -132,6 +131,14 @@ namespace Flow.Launcher.Infrastructure.UserSettings Path = "Files", DirectoryArgument = "-select \"%d\"", FileArgument = "-select \"%f\"" + }, + new() + { + Name = "QTTabBar", + Path = "Explorer", + DirectoryArgument = "\"%d\"", + FileArgument = "\"%f\"", + Editable = false } }; diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index b49bf39d3..c35dcc2ba 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -25,6 +25,7 @@ using Flow.Launcher.Infrastructure.Storage; using System.Collections.Concurrent; using System.Diagnostics; using System.Collections.Specialized; +using Flow.Launcher.Infrastructure.UserSettings; namespace Flow.Launcher { @@ -228,21 +229,39 @@ namespace Flow.Launcher public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null) { - using var explorer = new Process(); + var customExplorerList = _settingsVM.Settings.CustomExplorerList; var explorerInfo = _settingsVM.Settings.CustomExplorer; - explorer.StartInfo = new ProcessStartInfo + + var qttabbarIndex = customExplorerList.FindIndex(e => e.Name.Equals("QTTABBAR", StringComparison.OrdinalIgnoreCase)); + var isQttabbarSelected = qttabbarIndex >= 0 && _settingsVM.Settings.CustomExplorerIndex == qttabbarIndex; + + if (isQttabbarSelected) { - FileName = explorerInfo.Path, - UseShellExecute = true, - Arguments = FileNameOrFilePath is null - ? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) - : explorerInfo.FileArgument - .Replace("%d", DirectoryPath) - .Replace("%f", - Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath) - ) - }; - explorer.Start(); + Process.Start(new ProcessStartInfo + { + FileName = DirectoryPath, + UseShellExecute = true, + Verb = "open", + Arguments = FileNameOrFilePath + }); + } + else + { + using var explorer = new Process(); + explorer.StartInfo = new ProcessStartInfo + { + FileName = explorerInfo.Path, + UseShellExecute = true, + Arguments = FileNameOrFilePath is null + ? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) + : explorerInfo.FileArgument + .Replace("%d", DirectoryPath) + .Replace("%f", + Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath) + ) + }; + explorer.Start(); + } } private void OpenUri(Uri uri, bool? inPrivate = null) From 6223d3a570ef265a82ae2fba082d34d37b2ffdd2 Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 25 Jun 2024 17:05:11 +0900 Subject: [PATCH 0044/1836] Simplify compare selected indexe part --- Flow.Launcher/PublicAPIInstance.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index c35dcc2ba..5470c2ddd 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -233,7 +233,7 @@ namespace Flow.Launcher var explorerInfo = _settingsVM.Settings.CustomExplorer; var qttabbarIndex = customExplorerList.FindIndex(e => e.Name.Equals("QTTABBAR", StringComparison.OrdinalIgnoreCase)); - var isQttabbarSelected = qttabbarIndex >= 0 && _settingsVM.Settings.CustomExplorerIndex == qttabbarIndex; + var isQttabbarSelected = qttabbarIndex == _settingsVM.Settings.CustomExplorerIndex; if (isQttabbarSelected) { From 44d8af33f2a210d488077f5df36ff3e33e6b1d7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:50:26 +0000 Subject: [PATCH 0045/1836] Bump Meziantou.Framework.Win32.Jobs from 3.2.1 to 3.4.0 Bumps [Meziantou.Framework.Win32.Jobs](https://github.com/meziantou/Meziantou.Framework) from 3.2.1 to 3.4.0. - [Commits](https://github.com/meziantou/Meziantou.Framework/commits) --- updated-dependencies: - dependency-name: Meziantou.Framework.Win32.Jobs dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Flow.Launcher.Core/Flow.Launcher.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Flow.Launcher.Core.csproj b/Flow.Launcher.Core/Flow.Launcher.Core.csproj index 6d97e1c52..851541fc2 100644 --- a/Flow.Launcher.Core/Flow.Launcher.Core.csproj +++ b/Flow.Launcher.Core/Flow.Launcher.Core.csproj @@ -55,7 +55,7 @@ - + From d502f1dd25c17ba3cff9312aecd2446e02936b06 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Thu, 27 Jun 2024 11:05:18 +0600 Subject: [PATCH 0046/1836] Correctly load plugin localization files --- Flow.Launcher.Core/Plugin/PluginManager.cs | 2 +- .../Resource/Internationalization.cs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index b78331690..8c73ae400 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -203,7 +203,7 @@ namespace Flow.Launcher.Core.Plugin } } - InternationalizationManager.Instance.AddPluginLanguageDirectories(); + InternationalizationManager.Instance.AddPluginLanguageDirectories(GetPluginsForInterface()); InternationalizationManager.Instance.ChangeLanguage(InternationalizationManager.Instance.Settings.Language); if (failedPlugins.Any()) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 741cb9f3b..192ed2e81 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -25,9 +25,6 @@ namespace Flow.Launcher.Core.Resource public Internationalization() { - LoadDefaultLanguage(); - // we don't want to load /Languages/en.xaml twice - // so add flowlauncher language directory after load plugin language files AddFlowLauncherLanguageDirectory(); } @@ -39,9 +36,9 @@ namespace Flow.Launcher.Core.Resource } - internal void AddPluginLanguageDirectories() + internal void AddPluginLanguageDirectories(IEnumerable plugins) { - foreach (var plugin in PluginManager.GetPluginsForInterface()) + foreach (var plugin in plugins) { var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location; var dir = Path.GetDirectoryName(location); @@ -55,6 +52,8 @@ namespace Flow.Launcher.Core.Resource Log.Error($"|Internationalization.AddPluginLanguageDirectories|Can't find plugin path <{location}> for <{plugin.Metadata.Name}>"); } } + + LoadDefaultLanguage(); } private void LoadDefaultLanguage() @@ -139,11 +138,14 @@ namespace Flow.Launcher.Core.Resource private void LoadLanguage(Language language) { + var flowEnglishFile = Path.Combine(Constant.ProgramDirectory, Folder, DefaultFile); var dicts = Application.Current.Resources.MergedDictionaries; var filename = $"{language.LanguageCode}{Extension}"; var files = _languageDirectories .Select(d => LanguageFile(d, filename)) - .Where(f => !string.IsNullOrEmpty(f)) + // Exclude Flow's English language file since it's built into the binary, and there's no need to load + // it again from the file system. + .Where(f => !string.IsNullOrEmpty(f) && f != flowEnglishFile) .ToArray(); if (files.Length > 0) From bfd8dfe2e133b50a3cac672c268c707713d1ec8a Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Thu, 27 Jun 2024 11:10:12 +0600 Subject: [PATCH 0047/1836] Localize plugin init fail message --- Flow.Launcher.Core/Plugin/PluginManager.cs | 12 +++++++++--- Flow.Launcher/Languages/en.xaml | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 8c73ae400..2d13f7d7f 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -209,9 +209,15 @@ namespace Flow.Launcher.Core.Plugin if (failedPlugins.Any()) { var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name)); - API.ShowMsg($"Fail to Init Plugins", - $"Plugins: {failed} - fail to load and would be disabled, please contact plugin creator for help", - "", false); + API.ShowMsg( + InternationalizationManager.Instance.GetTranslation("failedToInitializePluginsTitle"), + string.Format( + InternationalizationManager.Instance.GetTranslation("failedToInitializePluginsMessage"), + failed + ), + "", + false + ); } } diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 3844ccf11..2f11f118b 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -10,6 +10,8 @@ Please select the {0} executable Unable to set {0} executable path, please try from Flow's settings (scroll down to the bottom). + Fail to Init Plugins + Plugins: {0} - fail to load and would be disabled, please contact plugin creator for help Failed to register hotkey "{0}". The hotkey may be in use by another program. Change to a different hotkey, or exit another program. From 1c2d9e8f52d0d617baf10dd3e2a9096d4c2fcd36 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Thu, 27 Jun 2024 11:10:50 +0600 Subject: [PATCH 0048/1836] Remove unnecessary spaces --- Flow.Launcher.Core/Plugin/PluginManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 2d13f7d7f..f5fa5e518 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -52,7 +52,7 @@ namespace Flow.Launcher.Core.Plugin } /// - /// Save json and ISavable + /// Save json and ISavable /// public static void Save() { @@ -225,11 +225,11 @@ namespace Flow.Launcher.Core.Plugin { if (query is null) return Array.Empty(); - + if (!NonGlobalPlugins.ContainsKey(query.ActionKeyword)) return GlobalPlugins; - - + + var plugin = NonGlobalPlugins[query.ActionKeyword]; return new List { @@ -289,8 +289,8 @@ namespace Flow.Launcher.Core.Plugin r.PluginID = metadata.ID; r.OriginQuery = query; - // ActionKeywordAssigned is used for constructing MainViewModel's query text auto-complete suggestions - // Plugins may have multi-actionkeywords eg. WebSearches. In this scenario it needs to be overriden on the plugin level + // ActionKeywordAssigned is used for constructing MainViewModel's query text auto-complete suggestions + // Plugins may have multi-actionkeywords eg. WebSearches. In this scenario it needs to be overriden on the plugin level if (metadata.ActionKeywords.Count == 1) r.ActionKeywordAssigned = query.ActionKeyword; } @@ -473,7 +473,7 @@ namespace Flow.Launcher.Core.Plugin // Unzip plugin files to temp folder var tempFolderPluginPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, tempFolderPluginPath); - + if(!plugin.IsFromLocalInstallPath) File.Delete(zipFilePath); From c9ec16549e0344daa21cbd824a17bc2bf4724637 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Thu, 27 Jun 2024 11:33:03 +0600 Subject: [PATCH 0049/1836] Fix untranslated Russian strings --- Flow.Launcher/Languages/ru.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/Languages/ru.xaml b/Flow.Launcher/Languages/ru.xaml index c733018ac..b94b1f540 100644 --- a/Flow.Launcher/Languages/ru.xaml +++ b/Flow.Launcher/Languages/ru.xaml @@ -9,8 +9,8 @@ {2}{2} Кликните нет, если он уже установлен, и вам будет предложено выбрать папку, где находится исполняемый файл {1} - Please select the {0} executable - Unable to set {0} executable path, please try from Flow's settings (scroll down to the bottom). + Пожалуйста, выберите исполняемый файл {0} + Не удалось установить путь к исполняемому файлу {0}, пожалуйста, попробуйте через настройки Flow (прокрутите вниз). Не удалось зарегистрировать сочетание клавиш "{0}". Возможно, оно используется другой программой. Измените сочетание клавиш или закройте другую программу. Flow Launcher From 224b364a5ac4fb12d151deb41cfe9bafb94aeb8e Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Fri, 28 Jun 2024 05:56:28 +0600 Subject: [PATCH 0050/1836] Modify gitstream todo checks --- .cm/gitstream.cm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.cm/gitstream.cm b/.cm/gitstream.cm index c372f5a6c..eee43c969 100644 --- a/.cm/gitstream.cm +++ b/.cm/gitstream.cm @@ -32,12 +32,12 @@ automations: args: comment: | This PR is {{ changes.ratio }}% new code. - # Post a comment that request changes for a PR that contains a TODO statement. + # Post a comment notifying that the PR contains a TODO statement. review_todo_comments: if: - - {{ source.diff.files | matchDiffLines(regex=r/^[+].*(TODO)|(todo)/) | some }} + - {{ source.diff.files | matchDiffLines(regex=r/^[+].*\b(TODO|todo)\b/) | some }} run: - - action: request-changes@v1 + - action: add-comment@v1 args: comment: | This PR contains a TODO statement. Please check to see if they should be removed. @@ -76,4 +76,4 @@ changes: has: screenshot_link: {{ pr.description | includes(regex=r/!\[.*\]\(.*(jpg|svg|png|gif|psd).*\)/) }} - image_uploaded: {{ pr.description | includes(regex=r//) }} \ No newline at end of file + image_uploaded: {{ pr.description | includes(regex=r//) }} From 55cd12d5325c21b0f6f5620551be7c75a34c89d2 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 30 Jun 2024 04:38:24 +1000 Subject: [PATCH 0051/1836] New Crowdin updates (#2795) Updated translations --- Flow.Launcher/Languages/fr.xaml | 4 +-- Flow.Launcher/Languages/sk.xaml | 12 ++++---- Flow.Launcher/Languages/vi.xaml | 30 +++++++++---------- .../Languages/fr.xaml | 8 ++--- .../Languages/pt-pt.xaml | 8 ++--- .../Languages/vi.xaml | 28 ++++++++--------- .../Languages/vi.xaml | 8 ++--- .../Languages/vi.xaml | 4 +-- .../Properties/Resources.vi-VN.resx | 18 +++++------ 9 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Flow.Launcher/Languages/fr.xaml b/Flow.Launcher/Languages/fr.xaml index a30fa0b19..65a41cbf3 100644 --- a/Flow.Launcher/Languages/fr.xaml +++ b/Flow.Launcher/Languages/fr.xaml @@ -178,8 +178,8 @@ Personnalisé Heure Date - This theme supports two(light/dark) modes. - This theme supports Blur Transparent Background. + Ce thème prend en charge deux modes (clair/sombre). + Ce thème prend en charge l'arrière-plan flou et transparent. diff --git a/Flow.Launcher/Languages/sk.xaml b/Flow.Launcher/Languages/sk.xaml index ef5fbd716..079c03e80 100644 --- a/Flow.Launcher/Languages/sk.xaml +++ b/Flow.Launcher/Languages/sk.xaml @@ -54,7 +54,7 @@ Ponechať Označiť Vymazať - Fixed Window Height + Pevná výška okna Výška okna sa nedá nastaviť ťahaním. Maximum výsledkov Túto hodnotu môžete rýchlo upraviť aj pomocou klávesových skratiek CTRL + znamienko plus (+) a CTRL + znamienko mínus (-). @@ -146,13 +146,13 @@ Spúšťanie programov ako správca alebo iný používateľ ProcessKiller Ukončenie nežiaducich procesov - Search Bar Height - Item Height + Výška vyhľadávacieho panela + Výška položky Písmo vyhľadávacieho poľa - Result Title Font - Result Subtitle Font + Písmo nadpisu výsledku + Písmo podnadpisu výsledku Resetovať - Customize + Prispôsobiť Režim okno Nepriehľadnosť Motív {0} neexistuje, použije sa predvolený motív diff --git a/Flow.Launcher/Languages/vi.xaml b/Flow.Launcher/Languages/vi.xaml index 312dbbb76..b7804381b 100644 --- a/Flow.Launcher/Languages/vi.xaml +++ b/Flow.Launcher/Languages/vi.xaml @@ -213,10 +213,10 @@ Chạy với quyền admin Refresh Search Results Dữ liệu plugin không tải - Quick Adjust Window Width - Quick Adjust Window Height - Use when require plugins to reload and update their existing data. - You can add one more hotkey for this function. + Điều chỉnh nhanh độ rộng cửa sổ + Điều chỉnh nhanh chiều cao cửa sổ + Sử dụng khi yêu cầu plugin tải lại và cập nhật dữ liệu hiện có của chúng. + Bạn có thể thêm một phím nóng nữa cho chức năng này. Phím tắt truy vấn tùy chỉnh Lối tắt truy vấn tùy chỉnh Phím tắt tích hợp @@ -283,9 +283,9 @@ Xóa tệp nhật ký Bạn có chắc chắn muốn xóa tất cả nhật ký không? Wizard - User Data Location - User settings and installed plugins are saved in the user data folder. This location may vary depending on whether it's in portable mode or not. - Open Folder + Vị trí dữ liệu người dùng + Thiết đặt người dùng và plugin đã cài đặt sẽ được lưu trong thư mục dữ liệu người dùng. Vị trí này có thể thay đổi tùy thuộc vào việc nó có ở chế độ di động hay không. + Mở thư mục Chọn trình quản lý tệp @@ -332,7 +332,7 @@ Tổ hợp phím plugin không hợp lệ Cập nhật Binding Hotkey - Current hotkey is unavailable. + Phím nóng hiện tại không có sẵn. This hotkey is reserved for "{0}" and can't be used. Please choose another hotkey. This hotkey is already in use by "{0}". If you press "Overwrite", it will be removed from "{0}". Press the keys you want to use for this function. @@ -429,10 +429,10 @@ Mở cửa sổ cài đặt Dữ liệu plugin không tải - Select first result - Select last result - Run current query again - Open result + Chọn kết quả đầu tiên + Chọn kết quả cuối cùng + Chạy lại truy vấn hiện tại + Mở kết quả Open result #{0} Thời Tiết @@ -445,7 +445,7 @@ Ghi chú - File Size - Created - Last Modified + Kích thước tệp + Đã tạo + Sửa đổi lần cuối diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/fr.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/fr.xaml index ab1d1f4c9..4ff56e85e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/fr.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/fr.xaml @@ -151,8 +151,8 @@ Il peut être très lent sans index (qui n'est supporté que dans Everything v1.5+). - Native Context Menu - Display native context menu (experimental) - Below you can specify items you want to include in the context menu, they can be partial (e.g. 'pen wit') or complete ('Open with'). - Below you can specify items you want to exclude from context menu, they can be partial (e.g. 'pen wit') or complete ('Open with') + Menu contextuel natif + Afficher le menu contextuel natif (expérimental) + Ci-dessous, vous pouvez spécifier les éléments que vous souhaitez inclure dans le menu contextuel. Ils peuvent être partiels ('pen wit') ou complets ('Ouvrir avec'). + Vous pouvez spécifier ci-dessous les éléments que vous souhaitez exclure du menu contextuel. Ces éléments peuvent être partiels ('pen wit') ou complets ('Open with'). diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/pt-pt.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/pt-pt.xaml index c43ea6231..106d75c45 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/pt-pt.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/pt-pt.xaml @@ -151,8 +151,8 @@ Pode ser muito lento sem índice (que apenas existe em Everything v1.5+) - Native Context Menu - Display native context menu (experimental) - Below you can specify items you want to include in the context menu, they can be partial (e.g. 'pen wit') or complete ('Open with'). - Below you can specify items you want to exclude from context menu, they can be partial (e.g. 'pen wit') or complete ('Open with') + Menu de contexto nativo + Mostrar menu de contexto nativo (experimental) + Aqui pode especificar os itens a incluir no menu de contexto. Podem ser parciais (ex.: 'brir co') ou completos ('Abrir com'). + Aqui pode especificar os itens a excluir do menu de contexto. Podem ser parciais (ex.: 'brir co') ou completos ('Abrir com'). diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/vi.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/vi.xaml index c8039c677..68c56f584 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/vi.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/vi.xaml @@ -27,12 +27,12 @@ Tùy chỉnh từ khóa hành động Liên kết truy cập nhanh Cài đặt mọi thứ - Preview Panel + Bảng xem trước Kích thước Date Created Date Modified - Display File Info - Date and time format + Hiển thị thông tin tệp + Định dạng ngày và giờ Tùy Chọn Sắp Xếp Đường dẫn mọi thứ: Khởi chạy ẩn @@ -53,29 +53,29 @@ Đã bật Khi bị tắt, Flow sẽ không thực thi tùy chọn tìm kiếm này và sẽ hoàn nguyên về '*' để giải phóng từ khóa hành động Tất cả mọi thứ - Windows Index - Direct Enumeration - File Editor Path + Chỉ mục Windows + Đếm trực tiếp + Đường dẫn trình soạn thảo tệp Folder Editor Path - Content Search Engine + Công cụ tìm kiếm nội dung Directory Recursive Search Engine - Index Search Engine + Công cụ tìm kiếm chỉ mục Mở tùy chọn lập chỉ mục Windows Thư mục - Find and manage files and folders via Windows Search or Everything + Tìm và quản lý tệp và thư mục thông qua Windows Search hoặc Everything - Ctrl + Enter to open the directory - Ctrl + Enter to open the containing folder + Ctrl + Enter để mở thư mục + Ctrl + Enter để mở thư mục chứa Copy đường dẫn - Copy path of current item to clipboard + Sao chép đường dẫn của mục hiện tại vào clipboard Sao chép - Copy current file to clipboard + Sao chép tập tin hiện tại vào clipboard Copy current folder to clipboard Xóa Permanently delete current file @@ -88,7 +88,7 @@ Open the location that contains current item Mở bằng trình chỉnh sửa: Failed to open file at {0} with Editor {1} at {2} - Open With Shell: + Mở bằng Shell: Failed to open folder {0} with Shell {1} at {2} Loại trừ các thư mục hiện tại và thư mục con khỏi Tìm kiếm chỉ mục Bị loại trừ khỏi Tìm kiếm chỉ mục diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/vi.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/vi.xaml index 92687641a..8038427ca 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/vi.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/vi.xaml @@ -44,10 +44,10 @@ Hãy chọn một nguồn dữ liệu Bạn có chắc chắn là muốn xóa các đặt hàng đã chọn? - Another program source with the same location already exists. + Đã tồn tại một nguồn chương trình khác có cùng vị trí. - Program Source - Edit directory and status of this program source. + Nguồn chương trình + Chỉnh sửa thư mục và trạng thái của nguồn chương trình này. Cập nhật Program Plugin will only index files with selected suffixes and .url files with selected protocols. @@ -73,7 +73,7 @@ Chạy với quyền quản trị Mở thư mục chứa Vô hiệu hóa chương trình này hiển thị - Open target folder + Mở thư mục đích Chương trình Tìm kiếm chương trình trong Flow Launcher diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Languages/vi.xaml b/Plugins/Flow.Launcher.Plugin.Shell/Languages/vi.xaml index 22d909686..1a0d55e66 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Languages/vi.xaml +++ b/Plugins/Flow.Launcher.Plugin.Shell/Languages/vi.xaml @@ -2,8 +2,8 @@ Thay thế Win + R - Close Command Prompt after pressing any key - Press any key to close this window... + Đóng Command Prompt sau khi nhấn phím bất kỳ + Nhấn phím bất kỳ để đóng cửa sổ này... Không đóng dấu nhắc lệnh sau khi thực hiện lệnh Luôn chạy với tư cách quản trị viên Xóa lựa chọn đã chọn diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.vi-VN.resx b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.vi-VN.resx index 851470744..1ec616d9d 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.vi-VN.resx +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.vi-VN.resx @@ -1132,7 +1132,7 @@ Area Control Panel (legacy settings) - Pen and touch + Bút và cảm ứng Area Control Panel (legacy settings) @@ -1144,15 +1144,15 @@ Area Control Panel (legacy settings) - Performance information and tools + Thông tin hiệu suất và công cụ Area Control Panel (legacy settings) - Permissions and history + Quyền và lịch sử Area Cortana - Personalization (category) + Cá nhân hóa (danh mục) Area Personalization @@ -1160,23 +1160,23 @@ Area Phone - Phone and modem + Điện thoại và modem Area Control Panel (legacy settings) - Phone and modem - Options + Điện thoại và modem - Tùy chọn Area Control Panel (legacy settings) - Phone calls + Cuộc gọi điện thoại Area Privacy - Phone - Default apps + Điện thoại - Ứng dụng mặc định Area System - Picture + Hình ảnh Hình ảnh From 55d61dee371ea3320640b8e07d60277f4459be75 Mon Sep 17 00:00:00 2001 From: DB P Date: Sun, 30 Jun 2024 16:42:15 +0900 Subject: [PATCH 0052/1836] Update README.md Add Sponsor --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 866cdf8b3..c09add1fd 100644 --- a/README.md +++ b/README.md @@ -330,13 +330,15 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea ## Sponsors -

- + + +
+
+ + -
-

From 763a3843b959bcdc841066033e50869177328603 Mon Sep 17 00:00:00 2001 From: DB P Date: Sun, 30 Jun 2024 16:47:30 +0900 Subject: [PATCH 0053/1836] Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c09add1fd..e06380981 100644 --- a/README.md +++ b/README.md @@ -332,7 +332,7 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea ## Sponsors

- + Appwrite Logo

From f2025791f83766833f43f6be9470f3c6fa4ac897 Mon Sep 17 00:00:00 2001 From: DB P Date: Sun, 30 Jun 2024 16:48:00 +0900 Subject: [PATCH 0054/1836] Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e06380981..4fe1392b4 100644 --- a/README.md +++ b/README.md @@ -337,7 +337,7 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea

- + Coderabbit Logo

From 3875d7fa6610ef491bec8831ce3e0b7bd0a6f913 Mon Sep 17 00:00:00 2001 From: DB P Date: Sun, 30 Jun 2024 16:48:28 +0900 Subject: [PATCH 0055/1836] remove style --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fe1392b4..5cca0105b 100644 --- a/README.md +++ b/README.md @@ -337,7 +337,7 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea

- Coderabbit Logo + Coderabbit Logo

From 7729c7f4c73a2135b6cd0a689ae874d07461df6d Mon Sep 17 00:00:00 2001 From: DB P Date: Sun, 30 Jun 2024 16:53:05 +0900 Subject: [PATCH 0056/1836] Changed sponsor order --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5cca0105b..b5d075515 100644 --- a/README.md +++ b/README.md @@ -331,24 +331,21 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea ## Sponsors

- - Appwrite Logo - -
-
Coderabbit Logo + +
+
+ + Appwrite Logo

-


-

-

From 496050b64144ba13addc295281f401e116a7c133 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 30 Jun 2024 18:04:16 +1000 Subject: [PATCH 0057/1836] update sponsor order --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b5d075515..c563eafc9 100644 --- a/README.md +++ b/README.md @@ -336,13 +336,13 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea

- - Appwrite Logo + +

- - + + Appwrite Logo

From 56f76447b1a07300b77d1302e31a05655fd5974e Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 30 Jun 2024 17:44:24 +0900 Subject: [PATCH 0058/1836] Add style for hide sep when turn off info state --- .../Views/PreviewPanel.xaml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml index a2910f230..22aa8f597 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml @@ -58,6 +58,7 @@ + Fill="{Binding ElementName=PreviewSep, Path=Fill}"> + + + + @@ -84,7 +101,6 @@ - Date: Sun, 30 Jun 2024 18:03:25 +0900 Subject: [PATCH 0059/1836] Revert "Fix Window Positioning with Multiple Montiors" --- .../UserSettings/Point2D.cs | 46 ----- .../UserSettings/Settings.cs | 6 +- Flow.Launcher/MainWindow.xaml.cs | 170 ++++++------------ Flow.Launcher/SettingWindow.xaml.cs | 34 +--- Flow.Launcher/ViewModel/MainViewModel.cs | 6 +- 5 files changed, 68 insertions(+), 194 deletions(-) delete mode 100644 Flow.Launcher.Infrastructure/UserSettings/Point2D.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Point2D.cs b/Flow.Launcher.Infrastructure/UserSettings/Point2D.cs deleted file mode 100644 index 4c47ba6c0..000000000 --- a/Flow.Launcher.Infrastructure/UserSettings/Point2D.cs +++ /dev/null @@ -1,46 +0,0 @@ -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)); - } -} diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 125447d83..0c7de10fd 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -205,10 +205,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings public bool AutoUpdates { get; set; } = false; - - public Point2D WindowPosition { get; set; } - public Point2D PreviousScreen { get; set; } - public Point2D PreviousDpi { get; set; } + public double WindowLeft { get; set; } + public double WindowTop { get; set; } /// /// Custom left position on selected monitor diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 4027e7698..60048d070 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -72,7 +72,11 @@ namespace Flow.Launcher }; } - DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500), IsEnabled = false }; + DispatcherTimer timer = new DispatcherTimer + { + Interval = new TimeSpan(0, 0, 0, 0, 500), + IsEnabled = false + }; public MainWindow() { @@ -83,7 +87,6 @@ namespace Flow.Launcher private const int WM_EXITSIZEMOVE = 0x0232; private int _initialWidth; private int _initialHeight; - private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == WM_ENTERSIZEMOVE) @@ -92,22 +95,18 @@ namespace Flow.Launcher _initialHeight = (int)Height; handled = true; } - if (msg == WM_EXITSIZEMOVE) { - if (_initialHeight != (int)Height) + if ( _initialHeight != (int)Height) { OnResizeEnd(); } - if (_initialWidth != (int)Width) { FlowMainWindow.SizeToContent = SizeToContent.Height; } - handled = true; } - return IntPtr.Zero; } @@ -132,7 +131,6 @@ namespace Flow.Launcher _settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount)); } } - FlowMainWindow.SizeToContent = SizeToContent.Height; _viewModel.MainWindowWidth = Width; } @@ -177,7 +175,6 @@ namespace Flow.Launcher private void OnInitialized(object sender, EventArgs e) { } - private void OnLoaded(object sender, RoutedEventArgs _) { // MouseEventHandler @@ -209,7 +206,6 @@ namespace Flow.Launcher { SoundPlay(); } - UpdatePosition(); PreviewReset(); Activate(); @@ -221,8 +217,7 @@ namespace Flow.Launcher _viewModel.LastQuerySelected = true; } - if (_viewModel.ProgressBarVisibility == Visibility.Visible && - isProgressBarStoryboardPaused) + if (_viewModel.ProgressBarVisibility == Visibility.Visible && isProgressBarStoryboardPaused) { _progressBarStoryboard.Begin(ProgressBar, true); isProgressBarStoryboardPaused = false; @@ -263,12 +258,9 @@ namespace Flow.Launcher MoveQueryTextToEnd(); _viewModel.QueryTextCursorMovedToEnd = false; } - break; 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; } }; @@ -286,8 +278,11 @@ namespace Flow.Launcher case nameof(Settings.Hotkey): UpdateNotifyIconText(); break; - case nameof(Settings.WindowPosition): - (Left, Top) = _settings.WindowPosition; + case nameof(Settings.WindowLeft): + Left = _settings.WindowLeft; + break; + case nameof(Settings.WindowTop): + Top = _settings.WindowTop; break; } }; @@ -297,24 +292,8 @@ namespace Flow.Launcher { if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { - var previousScreen = _settings.PreviousScreen; - - 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; + Top = _settings.WindowTop; + Left = _settings.WindowLeft; } else { @@ -327,72 +306,34 @@ namespace Flow.Launcher break; case SearchWindowAligns.CenterTop: Left = HorizonCenter(screen); - Top = VerticalTop(screen); + Top = 10; break; case SearchWindowAligns.LeftTop: Left = HorizonLeft(screen); - Top = VerticalTop(screen); + Top = 10; break; case SearchWindowAligns.RightTop: Left = HorizonRight(screen); - Top = VerticalTop(screen); + Top = 10; break; case SearchWindowAligns.Custom: - var customLeft = WindowsInteropHelper.TransformPixelsToDIP(this, - screen.WorkingArea.X + _settings.CustomWindowLeft, 0); - var customTop = WindowsInteropHelper.TransformPixelsToDIP(this, 0, - screen.WorkingArea.Y + _settings.CustomWindowTop); - Left = customLeft.X; - Top = customTop.Y; + Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X; + Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y; 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() { 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[2]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset"); ((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"); ((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"); + } private void InitializeNotifyIcon() @@ -404,34 +345,50 @@ namespace Flow.Launcher Visible = !_settings.HideNotifyIcon }; - var openIcon = new FontIcon { Glyph = "\ue71e" }; + var openIcon = new FontIcon + { + Glyph = "\ue71e" + }; var open = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + - _settings.Hotkey + ")", + Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")", Icon = openIcon }; - var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" }; + var gamemodeIcon = new FontIcon + { + Glyph = "\ue7fc" + }; var gamemode = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon + Header = InternationalizationManager.Instance.GetTranslation("GameMode"), + Icon = gamemodeIcon + }; + var positionresetIcon = new FontIcon + { + Glyph = "\ue73f" }; - var positionresetIcon = new FontIcon { Glyph = "\ue73f" }; var positionreset = new MenuItem { Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), Icon = positionresetIcon }; - var settingsIcon = new FontIcon { Glyph = "\ue713" }; + var settingsIcon = new FontIcon + { + Glyph = "\ue713" + }; var settings = new MenuItem { Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"), Icon = settingsIcon }; - var exitIcon = new FontIcon { Glyph = "\ue7e8" }; + var exitIcon = new FontIcon + { + Glyph = "\ue7e8" + }; var exit = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon + Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), + Icon = exitIcon }; open.Click += (o, e) => _viewModel.ToggleFlowLauncher(); @@ -464,7 +421,6 @@ namespace Flow.Launcher { _ = SetForegroundWindow(hwndSource.Handle); } - contextMenu.Focus(); break; } @@ -498,10 +454,8 @@ namespace Flow.Launcher private void InitProgressbarAnimation() { - var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, - 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))); + var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, 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(da1, new PropertyPath("(Line.X1)")); _progressBarStoryboard.Children.Add(da); @@ -603,14 +557,14 @@ namespace Flow.Launcher iconsb.Children.Add(IconOpacity); windowsb.Completed += (_, _) => _animating = false; - _settings.WindowPosition = (Left, Top); + _settings.WindowLeft = Left; + _settings.WindowTop = Top; isArrowKeyPressed = false; if (QueryTextBox.Text.Length == 0) { clocksb.Begin(ClockPanel); } - iconsb.Begin(SearchIcon); windowsb.Begin(FlowMainWindow); } @@ -664,7 +618,8 @@ namespace Flow.Launcher private async void OnDeactivated(object sender, EventArgs e) { - _settings.WindowPosition = (Left, Top); + _settings.WindowLeft = Left; + _settings.WindowTop = Top; //This condition stops extra hide call when animator is on, // which causes the toggling to occasional hide instead of show. if (_viewModel.MainWindowVisibilityStatus) @@ -695,7 +650,8 @@ namespace Flow.Launcher return; if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation) { - _settings.WindowPosition = (Left, Top); + _settings.WindowLeft = Left; + _settings.WindowTop = Top; } } @@ -715,7 +671,7 @@ namespace Flow.Launcher public Screen SelectedScreen() { Screen screen = null; - switch (_settings.SearchWindowScreen) + switch(_settings.SearchWindowScreen) { case SearchWindowScreens.Cursor: screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); @@ -737,7 +693,6 @@ namespace Flow.Launcher screen = Screen.AllScreens[0]; break; } - return screen ?? Screen.AllScreens[0]; } @@ -772,13 +727,6 @@ namespace Flow.Launcher return left; } - public double VerticalTop(Screen screen) - { - var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); - var top = dip1.Y + 10; - return top; - } - /// /// Register up and down key /// todo: any way to put this in xaml ? @@ -814,7 +762,6 @@ namespace Flow.Launcher _viewModel.LoadContextMenuCommand.Execute(null); e.Handled = true; } - break; case Key.Left: if (!_viewModel.SelectedIsFromQueryResults() && QueryTextBox.CaretIndex == 0) @@ -822,7 +769,6 @@ namespace Flow.Launcher _viewModel.EscCommand.Execute(null); e.Handled = true; } - break; case Key.Back: if (specialKeyState.CtrlPressed) @@ -841,13 +787,12 @@ namespace Flow.Launcher } } } - break; default: break; + } } - private void OnKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Up || e.Key == Key.Down) @@ -863,7 +808,6 @@ namespace Flow.Launcher e.Handled = true; // Ignore Mouse Hover when press Arrowkeys } } - public void PreviewReset() { _viewModel.ResetPreview(); diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 99c363222..de4fd1f91 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -112,45 +112,23 @@ public partial class SettingWindow { if (_settings.SettingWindowTop == null || _settings.SettingWindowLeft == null) { - SetWindowPosition(WindowTop(), WindowLeft()); + Top = WindowTop(); + Left = WindowLeft(); } else { - double left = _settings.SettingWindowLeft.Value; - double top = _settings.SettingWindowTop.Value; - AdjustWindowPosition(ref top, ref left); - SetWindowPosition(top, left); + Top = _settings.SettingWindowTop.Value; + Left = _settings.SettingWindowLeft.Value; } 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() { 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) / 2 + dip1.X; + var left = (dip2.X - this.ActualWidth) / 2 + dip1.X; return left; } @@ -159,7 +137,7 @@ public partial class SettingWindow var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height); - var top = (dip2.Y - ActualHeight) / 2 + dip1.Y; + var top = (dip2.Y - this.ActualHeight) / 2 + dip1.Y - 20; return top; } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 5756e46ae..6c17e21f0 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -547,20 +547,20 @@ namespace Flow.Launcher.ViewModel private void IncreaseWidth() { Settings.WindowSize += 100; - Settings.WindowPosition -= (50, 0); + Settings.WindowLeft -= 50; OnPropertyChanged(nameof(MainWindowWidth)); } [RelayCommand] private void DecreaseWidth() { - if (MainWindowWidth - 100 < 400 || Math.Abs(Settings.WindowSize - 400) < 0.01) + if (MainWindowWidth - 100 < 400 || Settings.WindowSize == 400) { Settings.WindowSize = 400; } else { - Settings.WindowPosition += (50, 0); + Settings.WindowLeft += 50; Settings.WindowSize -= 100; } From c0afb197c21866008a2df16b6209f2f28c695aa9 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 1 Jul 2024 21:02:07 +1000 Subject: [PATCH 0060/1836] allow custom explorer profile's File Manager Path to replace with path greater flexibility with custom explorer profile --- .../UserSettings/Settings.cs | 9 +--- Flow.Launcher/PublicAPIInstance.cs | 44 ++++++------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 7291017fb..125447d83 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -91,6 +91,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings public double? SettingWindowTop { get; set; } = null; public double? SettingWindowLeft { get; set; } = null; public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal; + public int CustomExplorerIndex { get; set; } = 0; [JsonIgnore] @@ -131,14 +132,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings Path = "Files", DirectoryArgument = "-select \"%d\"", FileArgument = "-select \"%f\"" - }, - new() - { - Name = "QTTabBar", - Path = "Explorer", - DirectoryArgument = "\"%d\"", - FileArgument = "\"%f\"", - Editable = false } }; diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 5470c2ddd..20b02ddee 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -25,7 +25,6 @@ using Flow.Launcher.Infrastructure.Storage; using System.Collections.Concurrent; using System.Diagnostics; using System.Collections.Specialized; -using Flow.Launcher.Infrastructure.UserSettings; namespace Flow.Launcher { @@ -229,39 +228,22 @@ namespace Flow.Launcher public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null) { - var customExplorerList = _settingsVM.Settings.CustomExplorerList; + using var explorer = new Process(); var explorerInfo = _settingsVM.Settings.CustomExplorer; - var qttabbarIndex = customExplorerList.FindIndex(e => e.Name.Equals("QTTABBAR", StringComparison.OrdinalIgnoreCase)); - var isQttabbarSelected = qttabbarIndex == _settingsVM.Settings.CustomExplorerIndex; - - if (isQttabbarSelected) + explorer.StartInfo = new ProcessStartInfo { - Process.Start(new ProcessStartInfo - { - FileName = DirectoryPath, - UseShellExecute = true, - Verb = "open", - Arguments = FileNameOrFilePath - }); - } - else - { - using var explorer = new Process(); - explorer.StartInfo = new ProcessStartInfo - { - FileName = explorerInfo.Path, - UseShellExecute = true, - Arguments = FileNameOrFilePath is null - ? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) - : explorerInfo.FileArgument - .Replace("%d", DirectoryPath) - .Replace("%f", - Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath) - ) - }; - explorer.Start(); - } + FileName = explorerInfo.Path.Replace("%d", DirectoryPath), + UseShellExecute = true, + Arguments = FileNameOrFilePath is null + ? explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) + : explorerInfo.FileArgument + .Replace("%d", DirectoryPath) + .Replace("%f", + Path.IsPathRooted(FileNameOrFilePath) ? FileNameOrFilePath : Path.Combine(DirectoryPath, FileNameOrFilePath) + ) + }; + explorer.Start(); } private void OpenUri(Uri uri, bool? inPrivate = null) From 7952a2ec53b9d9e63d2117b547c5453783c1b7d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 22:23:44 +0000 Subject: [PATCH 0061/1836] Bump Microsoft.VisualStudio.Threading from 17.7.30 to 17.10.48 Bumps [Microsoft.VisualStudio.Threading](https://github.com/microsoft/vs-threading) from 17.7.30 to 17.10.48. - [Release notes](https://github.com/microsoft/vs-threading/releases) - [Commits](https://github.com/microsoft/vs-threading/compare/v17.7.30...v17.10.48) --- updated-dependencies: - dependency-name: Microsoft.VisualStudio.Threading dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Infrastructure.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj index 688b40c83..3a8e07b4a 100644 --- a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj +++ b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj @@ -55,7 +55,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + From bdbde14355d15595852fbf5d1ec52a9d9e782443 Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 2 Jul 2024 11:14:30 +0900 Subject: [PATCH 0062/1836] Change 'Arg For Folder' and 'Arg For File' inputs to not be required --- Flow.Launcher/SelectFileManagerWindow.xaml | 50 ++++++++++------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/Flow.Launcher/SelectFileManagerWindow.xaml b/Flow.Launcher/SelectFileManagerWindow.xaml index 776cf66e1..399ef679b 100644 --- a/Flow.Launcher/SelectFileManagerWindow.xaml +++ b/Flow.Launcher/SelectFileManagerWindow.xaml @@ -57,11 +57,11 @@ - - + + - + - + /// Choose the first result after reload if true; keep the last selected result if false. Default is true. public void ReQuery(bool reselect = true); + + /// + /// Back to the query results. + /// This method should run when selected item is from context menu or history. + /// + public void BackToQueryResults(); } } diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 20b02ddee..8a07e7a5c 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -318,6 +318,8 @@ namespace Flow.Launcher public void ReQuery(bool reselect = true) => _mainVM.ReQuery(reselect); + public void BackToQueryResults() => _mainVM.BackToQueryResults(); + #endregion #region Private Methods diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 6c17e21f0..445484347 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -484,6 +484,14 @@ namespace Flow.Launcher.ViewModel } } + public void BackToQueryResults() + { + if (!SelectedIsFromQueryResults()) + { + SelectedResults = Results; + } + } + [RelayCommand] public void ToggleGameMode() { From 6df0837906b07e7c84084fa8ceb6e49ce7ce5529 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 21 Nov 2024 19:18:15 +0800 Subject: [PATCH 0156/1836] improve requery doc --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index e5df91ae9..f3d773122 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -294,7 +294,7 @@ namespace Flow.Launcher.Plugin /// /// Reloads the query. - /// This method should run + /// This method should run when selected item is from query results. /// /// Choose the first result after reload if true; keep the last selected result if false. Default is true. public void ReQuery(bool reselect = true); From 6b6b0faadfcdda46d213e107f9eb17fe50b65843 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 21 Nov 2024 22:07:35 +0800 Subject: [PATCH 0157/1836] fix possible content frame navigation issue --- Flow.Launcher/SettingWindow.xaml | 1 + Flow.Launcher/SettingWindow.xaml.cs | 24 ++++++++++++++++++++++-- Flow.Launcher/WelcomeWindow.xaml | 15 ++++++++------- Flow.Launcher/WelcomeWindow.xaml.cs | 9 +++++++-- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index f6381b465..a81d9e0d1 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -171,6 +171,7 @@ IsPaneToggleButtonVisible="False" IsSettingsVisible="False" IsTabStop="False" + Loaded="NavView_Loaded" OpenPaneLength="240" PaneDisplayMode="Left" SelectionChanged="NavigationView_SelectionChanged"> diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 4cc125fa4..cb3f1e4a1 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -29,7 +29,6 @@ public partial class SettingWindow _api = api; InitializePosition(); InitializeComponent(); - NavView.SelectedItem = NavView.MenuItems[0]; /* Set First Page */ } private void OnLoaded(object sender, RoutedEventArgs e) @@ -169,7 +168,11 @@ public partial class SettingWindow else { var selectedItem = (NavigationViewItem)args.SelectedItem; - if (selectedItem == null) return; + if (selectedItem == null) + { + NavView_Loaded(sender, null); /* Reset First Page */ + return; + } var pageType = selectedItem.Name switch { @@ -186,5 +189,22 @@ public partial class SettingWindow } } + private void NavView_Loaded(object sender, RoutedEventArgs e) + { + if (ContentFrame.IsLoaded) + { + ContentFrame_Loaded(sender, e); + } + else + { + ContentFrame.Loaded += ContentFrame_Loaded; + } + } + + private void ContentFrame_Loaded(object sender, RoutedEventArgs e) + { + NavView.SelectedItem ??= NavView.MenuItems[0]; /* Set First Page */ + } + public record PaneData(Settings Settings, Updater Updater, IPortable Portable); } diff --git a/Flow.Launcher/WelcomeWindow.xaml b/Flow.Launcher/WelcomeWindow.xaml index 003dac5bc..d8cb38149 100644 --- a/Flow.Launcher/WelcomeWindow.xaml +++ b/Flow.Launcher/WelcomeWindow.xaml @@ -43,12 +43,12 @@ Grid.Column="0" Width="16" Height="16" - Margin="10,4,4,4" + Margin="10 4 4 4" RenderOptions.BitmapScalingMode="HighQuality" Source="/Images/app.png" /> @@ -97,7 +98,7 @@ Grid.Row="1" Background="{DynamicResource Color00B}" BorderBrush="{DynamicResource PopupButtonAreaBorderColor}" - BorderThickness="0,1,0,0"> + BorderThickness="0 1 0 0"> @@ -111,7 +112,7 @@ VerticalAlignment="Center"> /// /// - public static void CopyAll(this string sourcePath, string targetPath) + /// + public static void CopyAll(this string sourcePath, string targetPath, Func messageBoxExShow) { // Get the subdirectories for the specified directory. DirectoryInfo dir = new DirectoryInfo(sourcePath); @@ -54,7 +55,7 @@ namespace Flow.Launcher.Plugin.SharedCommands foreach (DirectoryInfo subdir in dirs) { string temppath = Path.Combine(targetPath, subdir.Name); - CopyAll(subdir.FullName, temppath); + CopyAll(subdir.FullName, temppath, messageBoxExShow); } } catch (Exception) @@ -62,7 +63,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else - MessageBox.Show(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath)); + messageBoxExShow(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath)); RemoveFolderIfExists(targetPath); #endif } @@ -75,8 +76,9 @@ namespace Flow.Launcher.Plugin.SharedCommands ///
/// /// + /// /// - public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath) + public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath, Func messageBoxExShow) { try { @@ -96,7 +98,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else - MessageBox.Show(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath)); + messageBoxExShow(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath)); return false; #endif } @@ -107,7 +109,8 @@ namespace Flow.Launcher.Plugin.SharedCommands /// Deletes a folder if it exists ///
/// - public static void RemoveFolderIfExists(this string path) + /// + public static void RemoveFolderIfExists(this string path, Func messageBoxExShow) { try { @@ -119,7 +122,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else - MessageBox.Show(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path)); + messageBoxExShow(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path)); #endif } } @@ -148,7 +151,8 @@ namespace Flow.Launcher.Plugin.SharedCommands /// Open a directory window (using the OS's default handler, usually explorer) ///
/// - public static void OpenPath(string fileOrFolderPath) + /// + public static void OpenPath(string fileOrFolderPath, Func messageBoxExShow) { var psi = new ProcessStartInfo { @@ -166,7 +170,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else - MessageBox.Show(string.Format("Unable to open the path {0}, please check if it exists", fileOrFolderPath)); + messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", fileOrFolderPath)); #endif } } @@ -175,9 +179,10 @@ namespace Flow.Launcher.Plugin.SharedCommands /// Open a file with associated application /// /// File path + /// /// Working directory /// Open as Administrator - public static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false) + public static void OpenFile(string filePath, Func messageBoxExShow, string workingDir = "", bool asAdmin = false) { var psi = new ProcessStartInfo { @@ -196,7 +201,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else - MessageBox.Show(string.Format("Unable to open the path {0}, please check if it exists", filePath)); + messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", filePath)); #endif } } diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs index 5077e6061..54a6f7a44 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Globalization; using System.Runtime.InteropServices; using System.Text.RegularExpressions; -using System.Windows; using System.Windows.Controls; using Mages.Core; using Flow.Launcher.Plugin.Calculator.ViewModels; using Flow.Launcher.Plugin.Calculator.Views; +using Flow.Launcher.Core; namespace Flow.Launcher.Plugin.Calculator { @@ -101,7 +101,7 @@ namespace Flow.Launcher.Plugin.Calculator } catch (ExternalException) { - MessageBox.Show("Copy failed, please try later"); + MessageBoxEx.Show("Copy failed, please try later"); return false; } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index f061ca183..8c40cac9a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -10,11 +10,9 @@ using Flow.Launcher.Plugin.Explorer.Search; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using System.Linq; using Flow.Launcher.Plugin.Explorer.Helper; -using MessageBox = System.Windows.Forms.MessageBox; -using MessageBoxIcon = System.Windows.Forms.MessageBoxIcon; -using MessageBoxButton = System.Windows.Forms.MessageBoxButtons; -using DialogResult = System.Windows.Forms.DialogResult; using Flow.Launcher.Plugin.Explorer.ViewModels; +using Flow.Launcher.Core; +using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage; namespace Flow.Launcher.Plugin.Explorer { @@ -177,12 +175,12 @@ namespace Flow.Launcher.Plugin.Explorer { try { - if (MessageBox.Show( + if (MessageBoxEx.Show( string.Format(Context.API.GetTranslation("plugin_explorer_delete_folder_link"), record.FullPath), string.Empty, MessageBoxButton.YesNo, - MessageBoxIcon.Warning) - == DialogResult.No) + MessageBoxImage.Warning) + == MessageBoxResult.No) return false; if (isFile) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs index ef923632d..b890e6e18 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs @@ -1,10 +1,13 @@ using Droplex; +using Flow.Launcher.Core; using Flow.Launcher.Plugin.SharedCommands; using Microsoft.Win32; using System; using System.IO; using System.Linq; using System.Threading.Tasks; +using System.Windows; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Plugin.Explorer.Search.Everything; @@ -19,10 +22,10 @@ public static class EverythingDownloadHelper if (string.IsNullOrEmpty(installedLocation)) { - if (System.Windows.Forms.MessageBox.Show( + if (MessageBoxEx.Show( string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine), api.GetTranslation("flowlauncher_plugin_everything_installing_title"), - System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) + MessageBoxType.YesNo) == MessageBoxResult.Yes) { var dlg = new System.Windows.Forms.OpenFileDialog { @@ -50,7 +53,7 @@ public static class EverythingDownloadHelper installedLocation = "C:\\Program Files\\Everything\\Everything.exe"; - FilesFolders.OpenPath(installedLocation); + FilesFolders.OpenPath(installedLocation, MessageBoxEx.Show); return installedLocation; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 1e7555a8d..bffe75c29 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -12,6 +12,7 @@ using Path = System.IO.Path; using System.Windows.Controls; using Flow.Launcher.Plugin.Explorer.Views; using Peter; +using Flow.Launcher.Core; namespace Flow.Launcher.Plugin.Explorer.Search { @@ -123,7 +124,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } catch (Exception ex) { - MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); + MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); return false; } } @@ -137,7 +138,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } catch (Exception ex) { - MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); + MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); return false; } } @@ -152,7 +153,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } catch (Exception ex) { - MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); + MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); return false; } } @@ -315,7 +316,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } catch (Exception ex) { - MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error")); + MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error")); } return true; @@ -337,7 +338,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search private static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false) { IncrementEverythingRunCounterIfNeeded(filePath); - FilesFolders.OpenFile(filePath, workingDir, asAdmin); + FilesFolders.OpenFile(filePath, MessageBoxEx.Show, workingDir, asAdmin); } private static void OpenFolder(string folderPath, string fileNameOrFilePath = null) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 309f7a6f7..49b4a9fa2 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -1,4 +1,5 @@ #nullable enable +using Flow.Launcher.Core; using Flow.Launcher.Plugin.Explorer.Search; using Flow.Launcher.Plugin.Explorer.Search.Everything; using Flow.Launcher.Plugin.Explorer.Search.Everything.Exceptions; @@ -14,7 +15,6 @@ using System.Linq; using System.Windows; using System.Windows.Forms; using System.Windows.Input; -using MessageBox = System.Windows.Forms.MessageBox; namespace Flow.Launcher.Plugin.Explorer.ViewModels { @@ -358,7 +358,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels private void ShowUnselectedMessage() { var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs index 9e86ce4b4..fdfe1638a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs @@ -1,8 +1,9 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Input; +using Flow.Launcher.Core; namespace Flow.Launcher.Plugin.Explorer.Views { @@ -62,10 +63,10 @@ namespace Flow.Launcher.Plugin.Explorer.Views switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled) { case (Settings.ActionKeyword.FileContentSearchActionKeyword, true): - MessageBox.Show(api.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); + MessageBoxEx.Show(api.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); return; case (Settings.ActionKeyword.QuickAccessActionKeyword, true): - MessageBox.Show(api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid")); + MessageBoxEx.Show(api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid")); return; } @@ -77,7 +78,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views } // The keyword is not valid, so show message - MessageBox.Show(api.GetTranslation("newActionKeywordsHasBeenAssigned")); + MessageBoxEx.Show(api.GetTranslation("newActionKeywordsHasBeenAssigned")); } private void BtnCancel_OnClick(object sender, RoutedEventArgs e) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index 2d71329b4..fcba3ebee 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -1,4 +1,5 @@ -using Flow.Launcher.Core.ExternalPlugins; +using Flow.Launcher.Core; +using Flow.Launcher.Core.ExternalPlugins; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Http; @@ -12,6 +13,7 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using System.Windows; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Plugin.PluginsManager { @@ -131,8 +133,8 @@ namespace Flow.Launcher.Plugin.PluginsManager Environment.NewLine); } - if (MessageBox.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"), - MessageBoxButton.YesNo) == MessageBoxResult.No) + if (MessageBoxEx.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"), + MessageBoxType.YesNo) == MessageBoxResult.No) return; // at minimum should provide a name, but handle plugin that is not downloaded from plugins manifest and is a url download @@ -265,9 +267,9 @@ namespace Flow.Launcher.Plugin.PluginsManager Environment.NewLine); } - if (MessageBox.Show(message, + if (MessageBoxEx.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_update_title"), - MessageBoxButton.YesNo) != MessageBoxResult.Yes) + MessageBoxType.YesNo) != MessageBoxResult.Yes) { return false; } @@ -360,9 +362,9 @@ namespace Flow.Launcher.Plugin.PluginsManager resultsForUpdate.Count()); } - if (MessageBox.Show(message, + if (MessageBoxEx.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_update_title"), - MessageBoxButton.YesNo) == MessageBoxResult.No) + MessageBoxType.YesNo) == MessageBoxResult.No) { return false; } @@ -474,12 +476,12 @@ namespace Flow.Launcher.Plugin.PluginsManager if (Settings.WarnFromUnknownSource) { if (!InstallSourceKnown(plugin.UrlDownload) - && MessageBox.Show(string.Format( + && MessageBoxEx.Show(string.Format( Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"), Environment.NewLine), Context.API.GetTranslation( "plugin_pluginsmanager_install_unknown_source_warning_title"), - MessageBoxButton.YesNo) == MessageBoxResult.No) + MessageBoxType.YesNo) == MessageBoxResult.No) return false; } @@ -511,13 +513,13 @@ namespace Flow.Launcher.Plugin.PluginsManager if (Settings.WarnFromUnknownSource) { if (!InstallSourceKnown(plugin.Website) - && MessageBox.Show(string.Format( + && MessageBoxEx.Show(string.Format( Context.API.GetTranslation( "plugin_pluginsmanager_install_unknown_source_warning"), Environment.NewLine), Context.API.GetTranslation( "plugin_pluginsmanager_install_unknown_source_warning_title"), - MessageBoxButton.YesNo) == MessageBoxResult.No) + MessageBoxType.YesNo) == MessageBoxResult.No) return false; } @@ -648,9 +650,9 @@ namespace Flow.Launcher.Plugin.PluginsManager Environment.NewLine); } - if (MessageBox.Show(message, + if (MessageBoxEx.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"), - MessageBoxButton.YesNo) == MessageBoxResult.Yes) + MessageBoxType.YesNo) == MessageBoxResult.Yes) { Application.Current.MainWindow.Hide(); Uninstall(x.Metadata); diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs index be8b768bd..fef16cb33 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using Flow.Launcher.Core; using Flow.Launcher.Plugin.Program.ViewModels; namespace Flow.Launcher.Plugin.Program @@ -32,7 +33,7 @@ namespace Flow.Launcher.Plugin.Program var (modified, msg) = ViewModel.AddOrUpdate(); if (modified == false && msg != null) { - MessageBox.Show(msg); // Invalid + MessageBoxEx.Show(msg); // Invalid return; } DialogResult = modified; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj index 4d88eef2c..68363c1fa 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj +++ b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj @@ -54,6 +54,7 @@ + diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs index 31565c8b0..af1df8e71 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Windows; +using Flow.Launcher.Core; namespace Flow.Launcher.Plugin.Program { @@ -39,14 +40,14 @@ namespace Flow.Launcher.Plugin.Program if (suffixes.Length == 0 && UseCustomSuffixes) { string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); return; } if (protocols.Length == 0 && UseCustomProtocols) { string warning = context.API.GetTranslation("flowlauncher_plugin_protocols_cannot_empty"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); return; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs index 7570d6b4d..e85b7534e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -10,6 +10,8 @@ using Flow.Launcher.Plugin.Program.Programs; using System.ComponentModel; using System.Windows.Data; using Flow.Launcher.Plugin.Program.ViewModels; +using Flow.Launcher.Core; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Plugin.Program.Views { @@ -178,7 +180,7 @@ namespace Flow.Launcher.Plugin.Program.Views if (selectedProgramSource == null) { string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"); - MessageBox.Show(msg); + MessageBoxEx.Show(msg); } else { @@ -283,7 +285,7 @@ namespace Flow.Launcher.Plugin.Program.Views if (selectedItems.Count == 0) { string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"); - MessageBox.Show(msg); + MessageBoxEx.Show(msg); return; } @@ -292,7 +294,7 @@ namespace Flow.Launcher.Plugin.Program.Views var msg = string.Format( context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source")); - if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No) + if (MessageBoxEx.Show(msg, string.Empty, MessageBoxType.YesNo) == MessageBoxResult.No) { return; } diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj index b797b3cf4..4e804e82c 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj +++ b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj @@ -37,6 +37,7 @@ + diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index 1ec07915d..72f3639ff 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using System.Windows; using System.Windows.Forms; using System.Windows.Interop; +using Flow.Launcher.Core; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; @@ -14,7 +15,7 @@ using Flow.Launcher.Plugin.SharedCommands; using Application = System.Windows.Application; using Control = System.Windows.Controls.Control; using FormsApplication = System.Windows.Forms.Application; -using MessageBox = System.Windows.MessageBox; +using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage; namespace Flow.Launcher.Plugin.Sys { @@ -143,7 +144,7 @@ namespace Flow.Launcher.Plugin.Sys IcoPath = "Images\\shutdown.png", Action = c => { - var result = MessageBox.Show( + var result = MessageBoxEx.Show( context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_shutdown_computer"), context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"), MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -163,7 +164,7 @@ namespace Flow.Launcher.Plugin.Sys IcoPath = "Images\\restart.png", Action = c => { - var result = MessageBox.Show( + var result = MessageBoxEx.Show( context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer"), context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"), MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -183,7 +184,7 @@ namespace Flow.Launcher.Plugin.Sys IcoPath = "Images\\restart_advanced.png", Action = c => { - var result = MessageBox.Show( + var result = MessageBoxEx.Show( context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer_advanced"), context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"), MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -202,7 +203,7 @@ namespace Flow.Launcher.Plugin.Sys IcoPath = "Images\\logoff.png", Action = c => { - var result = MessageBox.Show( + var result = MessageBoxEx.Show( context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_logoff_computer"), context.API.GetTranslation("flowlauncher_plugin_sys_log_off"), MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -279,7 +280,7 @@ namespace Flow.Launcher.Plugin.Sys var result = SHEmptyRecycleBin(new WindowInteropHelper(Application.Current.MainWindow).Handle, 0); if (result != (uint) HRESULT.S_OK && result != (uint) 0x8000FFFF) { - MessageBox.Show($"Error emptying recycle bin, error code: {result}\n" + + MessageBoxEx.Show($"Error emptying recycle bin, error code: {result}\n" + "please refer to https://msdn.microsoft.com/en-us/library/windows/desktop/aa378137", "Error", MessageBoxButton.OK, MessageBoxImage.Error); diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs index 60863ee82..8336f4b9a 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs @@ -2,6 +2,7 @@ using System.Windows; using Microsoft.Win32; using Flow.Launcher.Core.Plugin; +using Flow.Launcher.Core; namespace Flow.Launcher.Plugin.WebSearch { @@ -55,17 +56,17 @@ namespace Flow.Launcher.Plugin.WebSearch if (string.IsNullOrEmpty(_searchSource.Title)) { var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_title"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); } else if (string.IsNullOrEmpty(_searchSource.Url)) { var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_url"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); } else if (string.IsNullOrEmpty(_searchSource.ActionKeyword)) { var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_action_keyword"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); } else if (_action == Action.Add) { @@ -92,7 +93,7 @@ namespace Flow.Launcher.Plugin.WebSearch else { var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); } } @@ -113,7 +114,7 @@ namespace Flow.Launcher.Plugin.WebSearch else { var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned"); - MessageBox.Show(warning); + MessageBoxEx.Show(warning); } if (!string.IsNullOrEmpty(selectedNewIconImageFullPath)) @@ -138,7 +139,7 @@ namespace Flow.Launcher.Plugin.WebSearch if (!string.IsNullOrEmpty(selectedNewIconImageFullPath)) { if (_viewModel.ShouldProvideHint(selectedNewIconImageFullPath)) - MessageBox.Show(_api.GetTranslation("flowlauncher_plugin_websearch_iconpath_hint")); + MessageBoxEx.Show(_api.GetTranslation("flowlauncher_plugin_websearch_iconpath_hint")); imgPreviewIcon.Source = await _viewModel.LoadPreviewIconAsync(selectedNewIconImageFullPath); } diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs index 105e7dd68..0495772d5 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs @@ -41,7 +41,7 @@ namespace Flow.Launcher.Plugin.WebSearch #if DEBUG throw; #else - MessageBox.Show(string.Format("Copying the selected image file to {0} has failed, changes will now be reverted", destinationFileNameFullPath)); + Flow.Launcher.Core.MessageBoxEx.Show(string.Format("Copying the selected image file to {0} has failed, changes will now be reverted", destinationFileNameFullPath)); UpdateIconAttributes(selectedSearchSource, fullPathToOriginalImage); #endif } diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs index 7caa5beb3..7e4edf653 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs @@ -1,8 +1,10 @@ -using System.Windows; +using System.Windows; using System.Windows.Controls; using Flow.Launcher.Core.Plugin; using System.ComponentModel; using System.Windows.Data; +using Flow.Launcher.Core; +using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Plugin.WebSearch { @@ -36,7 +38,7 @@ namespace Flow.Launcher.Plugin.WebSearch var warning = _context.API.GetTranslation("flowlauncher_plugin_websearch_delete_warning"); var formated = string.Format(warning, selected.Title); - var result = MessageBox.Show(formated, string.Empty, MessageBoxButton.YesNo); + var result = MessageBoxEx.Show(formated, string.Empty, MessageBoxType.YesNo); if (result == MessageBoxResult.Yes) { var id = _context.CurrentPluginMetadata.ID; From 4bc9e86a27a7f7568543cf3c98e8f88caf18c5db Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 25 Nov 2024 12:06:33 +0800 Subject: [PATCH 0167/1836] Improve MessageBoxEx style as System.Windows.MessageBox --- Flow.Launcher.Core/MessageBoxEx.xaml | 24 ++++++++++++------------ Flow.Launcher.Core/MessageBoxEx.xaml.cs | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Flow.Launcher.Core/MessageBoxEx.xaml b/Flow.Launcher.Core/MessageBoxEx.xaml index 3467b3a0c..8edb0873d 100644 --- a/Flow.Launcher.Core/MessageBoxEx.xaml +++ b/Flow.Launcher.Core/MessageBoxEx.xaml @@ -124,18 +124,6 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal"> - + + + + + + + + + + + + + +