mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge remote-tracking branch 'upstream/dev' into JsonRPCUnitTest
This commit is contained in:
commit
dd8cbbb54d
12 changed files with 77 additions and 37 deletions
|
|
@ -18,6 +18,7 @@
|
|||
Height="600" Width="900"
|
||||
MinWidth="850"
|
||||
MinHeight="500"
|
||||
Loaded="OnLoaded"
|
||||
Closed="OnClosed"
|
||||
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
|
||||
<Window.InputBindings>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Win32;
|
||||
using NHotkey;
|
||||
|
|
@ -35,6 +36,14 @@ namespace Flow.Launcher
|
|||
}
|
||||
|
||||
#region General
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Fix (workaround) for the window freezes after lock screen (Win+L)
|
||||
// https://stackoverflow.com/questions/4951058/software-rendering-mode-wpf
|
||||
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
|
||||
HwndTarget hwndTarget = hwndSource.CompositionTarget;
|
||||
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
|
||||
}
|
||||
|
||||
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
|
||||
contextMenu = new ContextMenu(Context, Settings, viewModel);
|
||||
searchManager = new SearchManager(Settings, Context);
|
||||
ResultManager.Init(Context);
|
||||
ResultManager.Init(Context, Settings);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
public static class ResultManager
|
||||
{
|
||||
private static PluginInitContext Context;
|
||||
private static Settings Settings { get; set; }
|
||||
|
||||
public static void Init(PluginInitContext context)
|
||||
public static void Init(PluginInitContext context, Settings settings)
|
||||
{
|
||||
Context = context;
|
||||
Settings = settings;
|
||||
}
|
||||
|
||||
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 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
|
||||
Action = c =>
|
||||
{
|
||||
if (c.SpecialKeyState.CtrlPressed)
|
||||
if (c.SpecialKeyState.CtrlPressed || (!Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -39,17 +41,25 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return false;
|
||||
}
|
||||
}
|
||||
// one of it is enabled
|
||||
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;
|
||||
|
||||
keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
|
||||
|
||||
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
|
||||
Context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ?
|
||||
changeTo :
|
||||
query.ActionKeyword + " " + changeTo);
|
||||
Context.API.ChangeQuery($"{keyword}{changeTo}");
|
||||
return false;
|
||||
},
|
||||
Score = score,
|
||||
TitleToolTip = Constants.ToolTipOpenDirectory,
|
||||
SubTitleToolTip = Constants.ToolTipOpenDirectory,
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
|
||||
ContextData = new SearchResult
|
||||
{
|
||||
Type = ResultType.Folder,
|
||||
FullPath = path,
|
||||
ShowIndexState = showIndexState,
|
||||
WindowsIndexed = windowsIndexed
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +67,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
|
||||
|
||||
var folderName = retrievedDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
|
||||
var folderName = retrievedDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[]
|
||||
{
|
||||
Path.DirectorySeparatorChar
|
||||
}, StringSplitOptions.None).Last();
|
||||
|
||||
if (retrievedDirectoryPath.EndsWith(":\\"))
|
||||
{
|
||||
|
|
@ -81,7 +94,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
Title = title,
|
||||
SubTitle = $"Use > to search within {subtitleFolderName}, " +
|
||||
$"* to search for file extensions or >* to combine both searches.",
|
||||
$"* to search for file extensions or >* to combine both searches.",
|
||||
IcoPath = retrievedDirectoryPath,
|
||||
Score = 500,
|
||||
Action = c =>
|
||||
|
|
@ -91,7 +104,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
},
|
||||
TitleToolTip = retrievedDirectoryPath,
|
||||
SubTitleToolTip = retrievedDirectoryPath,
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = retrievedDirectoryPath, ShowIndexState = true, WindowsIndexed = windowsIndexed }
|
||||
ContextData = new SearchResult
|
||||
{
|
||||
Type = ResultType.Folder,
|
||||
FullPath = retrievedDirectoryPath,
|
||||
ShowIndexState = true,
|
||||
WindowsIndexed = windowsIndexed
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +145,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
},
|
||||
TitleToolTip = Constants.ToolTipOpenContainingFolder,
|
||||
SubTitleToolTip = Constants.ToolTipOpenContainingFolder,
|
||||
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
|
||||
ContextData = new SearchResult
|
||||
{
|
||||
Type = ResultType.File,
|
||||
FullPath = filePath,
|
||||
ShowIndexState = showIndexState,
|
||||
WindowsIndexed = windowsIndexed
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
|
@ -148,4 +173,4 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
Folder,
|
||||
File
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,13 +71,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
return allowedActionKeyword switch
|
||||
{
|
||||
Settings.ActionKeyword.SearchActionKeyword => settings.EnableSearchActionKeyword &&
|
||||
Settings.ActionKeyword.SearchActionKeyword => settings.SearchActionKeywordEnabled &&
|
||||
keyword == settings.SearchActionKeyword,
|
||||
Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword &&
|
||||
Settings.ActionKeyword.PathSearchActionKeyword => settings.PathSearchKeywordEnabled &&
|
||||
keyword == settings.PathSearchActionKeyword,
|
||||
Settings.ActionKeyword.FileContentSearchActionKeyword => keyword ==
|
||||
settings.FileContentSearchActionKeyword,
|
||||
Settings.ActionKeyword.IndexSearchActionKeyword => settings.EnabledIndexOnlySearchKeyword &&
|
||||
Settings.ActionKeyword.IndexSearchActionKeyword => settings.IndexOnlySearchKeywordEnabled &&
|
||||
keyword == settings.IndexSearchActionKeyword
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,17 +21,17 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
|
||||
|
||||
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||
public bool EnableSearchActionKeyword { get; set; } = true;
|
||||
public bool SearchActionKeywordEnabled { get; set; } = true;
|
||||
|
||||
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
|
||||
|
||||
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||
|
||||
public bool EnabledPathSearchKeyword { get; set; }
|
||||
public bool PathSearchKeywordEnabled { get; set; }
|
||||
|
||||
public string IndexSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||
|
||||
public bool EnabledIndexOnlySearchKeyword { get; set; }
|
||||
public bool IndexOnlySearchKeywordEnabled { get; set; }
|
||||
|
||||
internal enum ActionKeyword
|
||||
{
|
||||
|
|
@ -58,19 +58,19 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
|
||||
};
|
||||
|
||||
internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch
|
||||
internal bool? GetActionKeywordEnabled(ActionKeyword actionKeyword) => actionKeyword switch
|
||||
{
|
||||
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword,
|
||||
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword,
|
||||
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword,
|
||||
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled,
|
||||
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled,
|
||||
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled,
|
||||
_ => null
|
||||
};
|
||||
|
||||
internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
|
||||
internal void SetActionKeywordEnabled(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
|
||||
{
|
||||
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword = enable,
|
||||
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable,
|
||||
ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable,
|
||||
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable,
|
||||
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable,
|
||||
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled = enable,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,8 +337,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
public bool? Enabled
|
||||
{
|
||||
get => _settings.GetActionKeywordEnable(KeywordProperty);
|
||||
set => _settings.SetActionKeywordEnable(KeywordProperty,
|
||||
get => _settings.GetActionKeywordEnabled(KeywordProperty);
|
||||
set => _settings.SetActionKeywordEnabled(KeywordProperty,
|
||||
value ?? throw new ArgumentException("Unexpected null value"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
<system:String x:Key="plugin_pluginsmanager_update_title">Plugin Update</system:String>
|
||||
<system:String x:Key="plugin_pluginsmanager_update_exists">This plugin has an update, would you like to see it?</system:String>
|
||||
<system:String x:Key="plugin_pluginsmanager_update_alreadyexists">This plugin is already installed</system:String>
|
||||
<system:String x:Key="plugin_pluginsmanager_update_failed_title">Plugin Manifest Download Failed</system:String>
|
||||
<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>
|
||||
|
||||
<!--Controls-->
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
viewModel = new SettingsViewModel(context, Settings);
|
||||
contextMenu = new ContextMenu(Context);
|
||||
pluginManager = new PluginsManager(Context, Settings);
|
||||
_ = pluginManager.UpdateManifest().ContinueWith(_ =>
|
||||
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(_ =>
|
||||
{
|
||||
lastUpdateTime = DateTime.Now;
|
||||
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
|
|
@ -50,6 +50,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
{
|
||||
return contextMenu.LoadContextMenus(selectedResult);
|
||||
}
|
||||
|
||||
private Task _manifestUpdateTask = Task.CompletedTask;
|
||||
|
||||
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
|
||||
{
|
||||
|
|
@ -58,9 +60,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
if (string.IsNullOrWhiteSpace(search))
|
||||
return pluginManager.GetDefaultHotKeys();
|
||||
|
||||
if ((DateTime.Now - lastUpdateTime).TotalHours > 12) // 12 hours
|
||||
if ((DateTime.Now - lastUpdateTime).TotalHours > 12 && _manifestUpdateTask.IsCompleted) // 12 hours
|
||||
{
|
||||
_ = pluginManager.UpdateManifest().ContinueWith(t =>
|
||||
_manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(t =>
|
||||
{
|
||||
lastUpdateTime = DateTime.Now;
|
||||
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
|
|
|
|||
|
|
@ -59,11 +59,12 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
}
|
||||
else
|
||||
{
|
||||
return _downloadManifestTask = pluginsManifest.DownloadManifest().ContinueWith(t =>
|
||||
Context.API.ShowMsg("Plugin Manifest Download Fail.",
|
||||
"Please check if you can connect to github.com. " +
|
||||
"This error means you may not be able to Install and Update Plugin.", icoPath, false),
|
||||
_downloadManifestTask = pluginsManifest.DownloadManifest();
|
||||
_downloadManifestTask.ContinueWith(_ =>
|
||||
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"),
|
||||
Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false),
|
||||
TaskContinuationOptions.OnlyOnFaulted);
|
||||
return _downloadManifestTask;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"Name": "Plugins Manager",
|
||||
"Description": "Management of installing, uninstalling or updating Flow Launcher plugins",
|
||||
"Author": "Jeremy Wu",
|
||||
"Version": "1.8.1",
|
||||
"Version": "1.8.2",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||
"ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll",
|
||||
|
|
|
|||
|
|
@ -565,7 +565,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
}
|
||||
else
|
||||
{
|
||||
ProgramLogger.LogException($"|UWP|ImageFromPath|{path}" +
|
||||
ProgramLogger.LogException($"|UWP|ImageFromPath|{(string.IsNullOrEmpty(path) ? "Not Avaliable" : path)}" +
|
||||
$"|Unable to get logo for {UserModelId} from {path} and" +
|
||||
$" located in {Package.Location}", new FileNotFoundException());
|
||||
return new BitmapImage(new Uri(Constant.MissingImgIcon));
|
||||
|
|
|
|||
Loading…
Reference in a new issue