Skip to content

Commit dd8cbbb

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into JsonRPCUnitTest
2 parents d34ad66 + f160f3c commit dd8cbbb

File tree

12 files changed

+77
-37
lines changed

12 files changed

+77
-37
lines changed

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Height="600" Width="900"
1919
MinWidth="850"
2020
MinHeight="500"
21+
Loaded="OnLoaded"
2122
Closed="OnClosed"
2223
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
2324
<Window.InputBindings>

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Windows;
44
using System.Windows.Input;
5+
using System.Windows.Interop;
56
using System.Windows.Navigation;
67
using Microsoft.Win32;
78
using NHotkey;
@@ -35,6 +36,14 @@ public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
3536
}
3637

3738
#region General
39+
private void OnLoaded(object sender, RoutedEventArgs e)
40+
{
41+
// Fix (workaround) for the window freezes after lock screen (Win+L)
42+
// https://stackoverflow.com/questions/4951058/software-rendering-mode-wpf
43+
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
44+
HwndTarget hwndTarget = hwndSource.CompositionTarget;
45+
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
46+
}
3847

3948
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
4049
{

Plugins/Flow.Launcher.Plugin.Explorer/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Task InitAsync(PluginInitContext context)
4646

4747
contextMenu = new ContextMenu(Context, Settings, viewModel);
4848
searchManager = new SearchManager(Settings, Context);
49-
ResultManager.Init(Context);
49+
ResultManager.Init(Context, Settings);
5050

5151
return Task.CompletedTask;
5252
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
1010
public static class ResultManager
1111
{
1212
private static PluginInitContext Context;
13+
private static Settings Settings { get; set; }
1314

14-
public static void Init(PluginInitContext context)
15+
public static void Init(PluginInitContext context, Settings settings)
1516
{
1617
Context = context;
18+
Settings = settings;
1719
}
1820

1921
internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, int score = 0, bool showIndexState = false, bool windowsIndexed = false)
@@ -26,7 +28,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
2628
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
2729
Action = c =>
2830
{
29-
if (c.SpecialKeyState.CtrlPressed)
31+
if (c.SpecialKeyState.CtrlPressed || (!Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled))
3032
{
3133
try
3234
{
@@ -39,25 +41,36 @@ internal static Result CreateFolderResult(string title, string subtitle, string
3941
return false;
4042
}
4143
}
44+
// one of it is enabled
45+
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;
46+
47+
keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
4248

4349
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
44-
Context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ?
45-
changeTo :
46-
query.ActionKeyword + " " + changeTo);
50+
Context.API.ChangeQuery($"{keyword}{changeTo}");
4751
return false;
4852
},
4953
Score = score,
5054
TitleToolTip = Constants.ToolTipOpenDirectory,
5155
SubTitleToolTip = Constants.ToolTipOpenDirectory,
52-
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
56+
ContextData = new SearchResult
57+
{
58+
Type = ResultType.Folder,
59+
FullPath = path,
60+
ShowIndexState = showIndexState,
61+
WindowsIndexed = windowsIndexed
62+
}
5363
};
5464
}
5565

5666
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
5767
{
5868
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
5969

60-
var folderName = retrievedDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
70+
var folderName = retrievedDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[]
71+
{
72+
Path.DirectorySeparatorChar
73+
}, StringSplitOptions.None).Last();
6174

6275
if (retrievedDirectoryPath.EndsWith(":\\"))
6376
{
@@ -81,7 +94,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
8194
{
8295
Title = title,
8396
SubTitle = $"Use > to search within {subtitleFolderName}, " +
84-
$"* to search for file extensions or >* to combine both searches.",
97+
$"* to search for file extensions or >* to combine both searches.",
8598
IcoPath = retrievedDirectoryPath,
8699
Score = 500,
87100
Action = c =>
@@ -91,7 +104,13 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
91104
},
92105
TitleToolTip = retrievedDirectoryPath,
93106
SubTitleToolTip = retrievedDirectoryPath,
94-
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = retrievedDirectoryPath, ShowIndexState = true, WindowsIndexed = windowsIndexed }
107+
ContextData = new SearchResult
108+
{
109+
Type = ResultType.Folder,
110+
FullPath = retrievedDirectoryPath,
111+
ShowIndexState = true,
112+
WindowsIndexed = windowsIndexed
113+
}
95114
};
96115
}
97116

@@ -126,7 +145,13 @@ internal static Result CreateFileResult(string filePath, Query query, int score
126145
},
127146
TitleToolTip = Constants.ToolTipOpenContainingFolder,
128147
SubTitleToolTip = Constants.ToolTipOpenContainingFolder,
129-
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
148+
ContextData = new SearchResult
149+
{
150+
Type = ResultType.File,
151+
FullPath = filePath,
152+
ShowIndexState = showIndexState,
153+
WindowsIndexed = windowsIndexed
154+
}
130155
};
131156
return result;
132157
}
@@ -148,4 +173,4 @@ public enum ResultType
148173
Folder,
149174
File
150175
}
151-
}
176+
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActio
7171

7272
return allowedActionKeyword switch
7373
{
74-
Settings.ActionKeyword.SearchActionKeyword => settings.EnableSearchActionKeyword &&
74+
Settings.ActionKeyword.SearchActionKeyword => settings.SearchActionKeywordEnabled &&
7575
keyword == settings.SearchActionKeyword,
76-
Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword &&
76+
Settings.ActionKeyword.PathSearchActionKeyword => settings.PathSearchKeywordEnabled &&
7777
keyword == settings.PathSearchActionKeyword,
7878
Settings.ActionKeyword.FileContentSearchActionKeyword => keyword ==
7979
settings.FileContentSearchActionKeyword,
80-
Settings.ActionKeyword.IndexSearchActionKeyword => settings.EnabledIndexOnlySearchKeyword &&
80+
Settings.ActionKeyword.IndexSearchActionKeyword => settings.IndexOnlySearchKeywordEnabled &&
8181
keyword == settings.IndexSearchActionKeyword
8282
};
8383
}

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ public class Settings
2121
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
2222

2323
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
24-
public bool EnableSearchActionKeyword { get; set; } = true;
24+
public bool SearchActionKeywordEnabled { get; set; } = true;
2525

2626
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
2727

2828
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
2929

30-
public bool EnabledPathSearchKeyword { get; set; }
30+
public bool PathSearchKeywordEnabled { get; set; }
3131

3232
public string IndexSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
3333

34-
public bool EnabledIndexOnlySearchKeyword { get; set; }
34+
public bool IndexOnlySearchKeywordEnabled { get; set; }
3535

3636
internal enum ActionKeyword
3737
{
@@ -58,19 +58,19 @@ internal enum ActionKeyword
5858
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
5959
};
6060

61-
internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch
61+
internal bool? GetActionKeywordEnabled(ActionKeyword actionKeyword) => actionKeyword switch
6262
{
63-
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword,
64-
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword,
65-
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword,
63+
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled,
64+
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled,
65+
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled,
6666
_ => null
6767
};
6868

69-
internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
69+
internal void SetActionKeywordEnabled(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
7070
{
71-
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword = enable,
72-
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable,
73-
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable,
71+
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable,
72+
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable,
73+
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled = enable,
7474
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
7575
};
7676
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ public string Keyword
337337

338338
public bool? Enabled
339339
{
340-
get => _settings.GetActionKeywordEnable(KeywordProperty);
341-
set => _settings.SetActionKeywordEnable(KeywordProperty,
340+
get => _settings.GetActionKeywordEnabled(KeywordProperty);
341+
set => _settings.SetActionKeywordEnabled(KeywordProperty,
342342
value ?? throw new ArgumentException("Unexpected null value"));
343343
}
344344
}

Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<system:String x:Key="plugin_pluginsmanager_update_title">Plugin Update</system:String>
2020
<system:String x:Key="plugin_pluginsmanager_update_exists">This plugin has an update, would you like to see it?</system:String>
2121
<system:String x:Key="plugin_pluginsmanager_update_alreadyexists">This plugin is already installed</system:String>
22+
<system:String x:Key="plugin_pluginsmanager_update_failed_title">Plugin Manifest Download Failed</system:String>
23+
<system:String x:Key="plugin_pluginsmanager_update_failed_subtitle">Please check if you can connect to github.com. This error means you may not be able to install or update plugins.</system:String>
2224

2325
<!--Controls-->
2426

Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Task InitAsync(PluginInitContext context)
3838
viewModel = new SettingsViewModel(context, Settings);
3939
contextMenu = new ContextMenu(Context);
4040
pluginManager = new PluginsManager(Context, Settings);
41-
_ = pluginManager.UpdateManifest().ContinueWith(_ =>
41+
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(_ =>
4242
{
4343
lastUpdateTime = DateTime.Now;
4444
}, TaskContinuationOptions.OnlyOnRanToCompletion);
@@ -50,6 +50,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
5050
{
5151
return contextMenu.LoadContextMenus(selectedResult);
5252
}
53+
54+
private Task _manifestUpdateTask = Task.CompletedTask;
5355

5456
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
5557
{
@@ -58,9 +60,9 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
5860
if (string.IsNullOrWhiteSpace(search))
5961
return pluginManager.GetDefaultHotKeys();
6062

61-
if ((DateTime.Now - lastUpdateTime).TotalHours > 12) // 12 hours
63+
if ((DateTime.Now - lastUpdateTime).TotalHours > 12 && _manifestUpdateTask.IsCompleted) // 12 hours
6264
{
63-
_ = pluginManager.UpdateManifest().ContinueWith(t =>
65+
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(t =>
6466
{
6567
lastUpdateTime = DateTime.Now;
6668
}, TaskContinuationOptions.OnlyOnRanToCompletion);

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ internal Task UpdateManifest()
5959
}
6060
else
6161
{
62-
return _downloadManifestTask = pluginsManifest.DownloadManifest().ContinueWith(t =>
63-
Context.API.ShowMsg("Plugin Manifest Download Fail.",
64-
"Please check if you can connect to github.com. " +
65-
"This error means you may not be able to Install and Update Plugin.", icoPath, false),
62+
_downloadManifestTask = pluginsManifest.DownloadManifest();
63+
_downloadManifestTask.ContinueWith(_ =>
64+
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"),
65+
Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false),
6666
TaskContinuationOptions.OnlyOnFaulted);
67+
return _downloadManifestTask;
6768
}
6869
}
6970

0 commit comments

Comments
 (0)