From 14216a4ac08643c49907f5134311484e75575ba7 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 22 Dec 2022 22:57:15 +0800 Subject: [PATCH 01/10] Remove redundant default value --- Flow.Launcher/ViewModel/MainViewModel.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 09bba6e5c..3deb15740 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -32,8 +32,6 @@ namespace Flow.Launcher.ViewModel { #region Private Fields - private const string DefaultOpenResultModifiers = "Alt"; - private bool _isQueryRunning; private Query _lastQuery; private string _queryTextBeforeLeaveResults; @@ -103,8 +101,6 @@ namespace Flow.Launcher.ViewModel RegisterViewUpdate(); RegisterResultsUpdatedEvent(); RegisterClockAndDateUpdateAsync(); - - SetOpenResultModifiers(); } private void RegisterViewUpdate() @@ -513,7 +509,7 @@ namespace Flow.Launcher.ViewModel public string PluginIconPath { get; set; } = null; - public string OpenResultCommandModifiers { get; private set; } + public string OpenResultCommandModifiers => Settings.OpenResultModifiers; public string Image => Constant.QueryTextBoxIconImagePath; @@ -876,11 +872,6 @@ namespace Flow.Launcher.ViewModel #region Hotkey - private void SetOpenResultModifiers() - { - OpenResultCommandModifiers = Settings.OpenResultModifiers ?? DefaultOpenResultModifiers; - } - public void ToggleFlowLauncher() { if (!MainWindowVisibilityStatus) From 5de74c4676f6b9c88389469fb1f4eaa4efd07f64 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 01:08:06 +0800 Subject: [PATCH 02/10] Fix changing OpenResultModifiers in settings won't reflect to main window --- Flow.Launcher/ViewModel/MainViewModel.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 3deb15740..4153c02e2 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -72,6 +72,9 @@ namespace Flow.Launcher.ViewModel case nameof(Settings.AlwaysStartEn): OnPropertyChanged(nameof(StartWithEnglishMode)); break; + case nameof(Settings.OpenResultModifiers): + OnPropertyChanged(nameof(OpenResultCommandModifiers)); + break; } }; From f97c9fe249368a15da1be06e71d20bb0302252b3 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 13:14:54 +0800 Subject: [PATCH 03/10] Update wording for consistency --- Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 94b46b230..5678a3177 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -66,7 +66,7 @@ Copy path - Copy path of current result to clipboard + Copy path of current item to clipboard Copy Copy current file to clipboard Copy current folder to clipboard @@ -78,7 +78,7 @@ Run as different user Run the selected using a different user account Open containing folder - Opens the location that contains the item + Opens the location that contains current item Open With Editor: Failed to open file at {0} with Editor {1} at {2} Open With Shell: @@ -89,7 +89,7 @@ Manage indexed files and folders Failed to open Windows Indexing Options Add to Quick Access - Add current result to Quick Access + Add current item to Quick Access Successfully Added Successfully added to Quick Access Successfully Removed @@ -97,7 +97,7 @@ Add to Quick Access so it can be opened with Explorer's Search Activation action keyword Remove from Quick Access Remove from Quick Access - Remove current result from Quick Access + Remove current item from Quick Access Show Windows Context Menu From 599bdc42facad14f093ff593dc8c073b80ee0569 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 13:20:10 +0800 Subject: [PATCH 04/10] Remove quotation marks --- Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 5678a3177..acdb21471 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -130,6 +130,6 @@ Click here to start it Unable to find an Everything installation, would you like to manually select a location?{0}{0}Click no and Everything will be automatically installed for you Do you want to enable content search for Everything? - "It can be very slow without index (which is only supported in Everything v1.5+)" + It can be very slow without index (which is only supported in Everything v1.5+) From b1eb1910444a389eb7fbc8314d99791acebc3f2b Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 11:46:12 +0800 Subject: [PATCH 05/10] Formatting --- Flow.Launcher/MainWindow.xaml | 4 ---- Flow.Launcher/MainWindow.xaml.cs | 8 +++++++- Flow.Launcher/ViewModel/MainViewModel.cs | 20 ++++++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 095382e76..36a45da74 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -86,14 +86,10 @@ Key="O" Command="{Binding LoadContextMenuCommand}" Modifiers="Ctrl" /> - - - - /// Checks if Flow Launcher should ignore any hotkeys /// @@ -939,7 +947,7 @@ namespace Flow.Launcher.ViewModel return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen(); } - + #endregion #region Public Methods From b18f5f4c02a0024a06a4c02cd8b90d2494d2ef45 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 11:51:34 +0800 Subject: [PATCH 06/10] remove unused using --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index d4b989eea..9940ab0be 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows; -using System.Windows.Input; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; @@ -24,7 +23,6 @@ using System.IO; using System.Collections.Specialized; using CommunityToolkit.Mvvm.Input; using System.Globalization; -using System.Windows.Threading; namespace Flow.Launcher.ViewModel { From 33615d1d46dfe9f8ecfc850db97fba4596601dee Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 11:47:06 +0800 Subject: [PATCH 07/10] Neutralize warning --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 9940ab0be..26ad89fff 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -101,7 +101,7 @@ namespace Flow.Launcher.ViewModel RegisterViewUpdate(); RegisterResultsUpdatedEvent(); - RegisterClockAndDateUpdateAsync(); + _ = RegisterClockAndDateUpdateAsync(); } private void RegisterViewUpdate() From 47d109cbe1bc1d5fdae4079b02c970e267553d77 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:14:53 +0800 Subject: [PATCH 08/10] Refactor toggle game mode logic --- Flow.Launcher/Helper/HotKeyMapper.cs | 6 ++--- Flow.Launcher/MainWindow.xaml | 4 ++++ Flow.Launcher/MainWindow.xaml.cs | 28 +++++------------------- Flow.Launcher/ViewModel/MainViewModel.cs | 11 +++++++--- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index b9ac6afb3..27c044c66 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.UserSettings; using System; using NHotkey; @@ -25,7 +25,7 @@ namespace Flow.Launcher.Helper internal static void OnToggleHotkey(object sender, HotkeyEventArgs args) { - if (!mainViewModel.ShouldIgnoreHotkeys() && !mainViewModel.GameModeStatus) + if (!mainViewModel.ShouldIgnoreHotkeys()) mainViewModel.ToggleFlowLauncher(); } @@ -74,7 +74,7 @@ namespace Flow.Launcher.Helper { SetHotkey(hotkey.Hotkey, (s, e) => { - if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.GameModeStatus) + if (mainViewModel.ShouldIgnoreHotkeys()) return; mainViewModel.Show(); diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 36a45da74..5ed9ba802 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -177,6 +177,10 @@ Command="{Binding OpenResultCommand}" CommandParameter="9" Modifiers="{Binding OpenResultCommandModifiers}" /> + diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 05e01a3f7..544958284 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -101,6 +101,7 @@ namespace Flow.Launcher // since the default main window visibility is visible // so we need set focus during startup QueryTextBox.Focus(); + _viewModel.PropertyChanged += (o, e) => { switch (e.PropertyName) @@ -169,9 +170,12 @@ namespace Flow.Launcher _viewModel.QueryTextCursorMovedToEnd = false; } break; - + case nameof(MainViewModel.GameModeStatus): + _notifyIcon.Icon = _viewModel.GameModeStatus ? Properties.Resources.gamemode : Properties.Resources.app; + break; } }; + _settings.PropertyChanged += (o, e) => { switch (e.PropertyName) @@ -286,7 +290,7 @@ namespace Flow.Launcher }; open.Click += (o, e) => _viewModel.ToggleFlowLauncher(); - gamemode.Click += (o, e) => ToggleGameMode(); + gamemode.Click += (o, e) => _viewModel.ToggleGameMode(); positionreset.Click += (o, e) => PositionReset(); settings.Click += (o, e) => App.API.OpenSettingDialog(); exit.Click += (o, e) => Close(); @@ -332,20 +336,6 @@ namespace Flow.Launcher WelcomeWindow.Show(); } - private void ToggleGameMode() - { - if (_viewModel.GameModeStatus) - { - _notifyIcon.Icon = Properties.Resources.app; - _viewModel.GameModeStatus = false; - } - else - { - _notifyIcon.Icon = Properties.Resources.gamemode; - _viewModel.GameModeStatus = true; - } - } - private async void PositionReset() { _viewModel.Show(); @@ -601,12 +591,6 @@ namespace Flow.Launcher e.Handled = true; } break; - case Key.F12: - if (specialKeyState.CtrlPressed) - { - ToggleGameMode(); - } - break; case Key.Back: if (specialKeyState.CtrlPressed) { diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 26ad89fff..c474e2a15 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -337,6 +337,12 @@ namespace Flow.Launcher.ViewModel } } + [RelayCommand] + public void ToggleGameMode() + { + GameModeStatus = !GameModeStatus; + } + #endregion #region ViewModel Properties @@ -365,7 +371,7 @@ namespace Flow.Launcher.ViewModel public ResultsViewModel History { get; private set; } - public bool GameModeStatus { get; set; } + public bool GameModeStatus { get; set; } = false; private string _queryText; public string QueryText @@ -379,7 +385,6 @@ namespace Flow.Launcher.ViewModel } } - [RelayCommand] private void IncreaseWidth() { @@ -942,7 +947,7 @@ namespace Flow.Launcher.ViewModel /// public bool ShouldIgnoreHotkeys() { - return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen(); + return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen() || GameModeStatus; } #endregion From 87597625d59b9d4fad70c1687c7ddcec42148f3b Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:58:13 +0800 Subject: [PATCH 09/10] Remove Segoe UI to fix Chinese font --- Flow.Launcher/CustomShortcutSetting.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher/CustomShortcutSetting.xaml b/Flow.Launcher/CustomShortcutSetting.xaml index bbf6ff9f2..5a40a77b1 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml +++ b/Flow.Launcher/CustomShortcutSetting.xaml @@ -64,7 +64,6 @@ Date: Fri, 23 Dec 2022 15:15:11 +0800 Subject: [PATCH 10/10] Fix hardcoded strings --- .../Languages/en.xaml | 5 +++++ .../Search/ResultManager.cs | 22 +++++-------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 94b46b230..265b26296 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -99,6 +99,11 @@ Remove from Quick Access Remove current result from Quick Access Show Windows Context Menu + + + {0} free of {1} + Open in Default File Manager + Use '>' to search in this directory, '*' to search for file extensions or '>*' to combine both searches. Failed to load Everything SDK diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 88bfecc14..214a779e4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -96,7 +96,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search var driveLetter = path[..1].ToUpper(); var driveName = driveLetter + ":\\"; DriveInfo drv = new DriveInfo(driveLetter); - var subtitle = ToReadableSize(drv.AvailableFreeSpace, 2) + " free of " + ToReadableSize(drv.TotalSize, 2); + var freespace = ToReadableSize(drv.AvailableFreeSpace, 2); + var totalspace = ToReadableSize(drv.TotalSize, 2); + var subtitle = string.Format(Context.API.GetTranslation("plugin_explorer_diskfreespace"), freespace, totalspace); double usingSize = (Convert.ToDouble(drv.TotalSize) - Convert.ToDouble(drv.AvailableFreeSpace)) / Convert.ToDouble(drv.TotalSize) * 100; int? progressValue = Convert.ToInt32(usingSize); @@ -170,25 +172,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search // Path passed from PathSearchAsync ends with Constants.DirectorySeperator ('\'), need to remove the seperator // so it's consistent with folder results returned by index search which does not end with one var folderPath = path.TrimEnd(Constants.DirectorySeperator); - - var folderName = folderPath.TrimEnd(Constants.DirectorySeperator).Split(new[] - { - Path.DirectorySeparatorChar - }, StringSplitOptions.None).Last(); - - var title = $"Open {folderName}"; - - var subtitleFolderName = folderName; - - // ie. max characters can be displayed without subtitle cutting off: "Program Files (x86)" - if (folderName.Length > 19) - subtitleFolderName = "the directory"; return new Result { - Title = title, - SubTitle = $"Use > to search within {subtitleFolderName}, " + - $"* to search for file extensions or >* to combine both searches.", + Title = Context.API.GetTranslation("plugin_explorer_openresultfolder"), + SubTitle = Context.API.GetTranslation("plugin_explorer_openresultfolder_subtitle"), AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder, actionKeyword), IcoPath = folderPath, Score = 500,