mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #457 from Flow-Launcher/add_explorer_path
update to ExplorerPathActionkeyword branch
This commit is contained in:
commit
9d7ff0876e
10 changed files with 221 additions and 113 deletions
|
|
@ -274,7 +274,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// used to add action keyword for multiple action keyword plugin
|
||||
/// used to remove action keyword for multiple action keyword plugin
|
||||
/// e.g. web search
|
||||
/// </summary>
|
||||
public static void RemoveActionKeyword(string id, string oldActionkeyword)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
<system:String x:Key="plugin_explorer_actionkeywordview_search">Index Search Activation:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_path">Path Explore Activation:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_indexonlysearch">Index Only Search:</system:String>
|
||||
<system:String x:Key="plugin_explorer_actionkeywordview_brackets_disabled">(Disabled)</system:String>
|
||||
|
||||
<!--Plugin Infos-->
|
||||
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
private static PathEqualityComparator instance;
|
||||
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();
|
||||
|
||||
public bool Equals(Result x, Result y)
|
||||
{
|
||||
return x.SubTitle == y.SubTitle;
|
||||
|
|
@ -46,25 +47,39 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
var result = new HashSet<Result>(PathEqualityComparator.Instance);
|
||||
|
||||
if (ActionKeywordMatch(query, settings.PathSearchActionKeyword))
|
||||
if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) ||
|
||||
ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword))
|
||||
{
|
||||
result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (ActionKeywordMatch(query, settings.SearchActionKeyword) &&
|
||||
querySearch.Length > 0 &&
|
||||
!querySearch.IsLocationPathString())
|
||||
if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexOnlySearchActionKeyword) ||
|
||||
ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) &&
|
||||
querySearch.Length > 0 &&
|
||||
!querySearch.IsLocationPathString())
|
||||
{
|
||||
result.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
|
||||
result.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token)
|
||||
.ConfigureAwait(false));
|
||||
}
|
||||
|
||||
return result.ToList();
|
||||
}
|
||||
|
||||
private bool ActionKeywordMatch(Query query, string actionKeyword)
|
||||
private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword)
|
||||
{
|
||||
return query.ActionKeyword == actionKeyword ||
|
||||
query.ActionKeyword.Length == 0 && actionKeyword == Query.GlobalPluginWildcardSign;
|
||||
var keyword = query.ActionKeyword.Length == 0 ? "*" : query.ActionKeyword;
|
||||
|
||||
return allowedActionKeyword switch
|
||||
{
|
||||
Settings.ActionKeyword.SearchActionKeyword => settings.EnableSearchActionKeyword &&
|
||||
keyword == settings.SearchActionKeyword,
|
||||
Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword &&
|
||||
keyword == settings.PathSearchActionKeyword,
|
||||
Settings.ActionKeyword.FileContentSearchActionKeyword => keyword ==
|
||||
settings.FileContentSearchActionKeyword,
|
||||
Settings.ActionKeyword.IndexOnlySearchActionKeyword => settings.EnabledIndexOnlySearchKeyword &&
|
||||
keyword == settings.IndexOnlySearchActionKeyword
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)
|
||||
|
|
@ -118,7 +133,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return results.ToList();
|
||||
}
|
||||
|
||||
private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query, string querySearchString, CancellationToken token)
|
||||
private async Task<List<Result>> WindowsIndexFileContentSearchAsync(Query query, string querySearchString,
|
||||
CancellationToken token)
|
||||
{
|
||||
var queryConstructor = new QueryConstructor(settings);
|
||||
|
||||
|
|
@ -126,11 +142,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return new List<Result>();
|
||||
|
||||
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForFileContentSearch,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForFileContentSearch,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public bool IsFileContentSearch(string actionKeyword)
|
||||
|
|
@ -157,28 +173,30 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return await windowsIndexSearch(query, querySearchString, token);
|
||||
}
|
||||
|
||||
private async Task<List<Result>> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString, CancellationToken token)
|
||||
private async Task<List<Result>> WindowsIndexFilesAndFoldersSearchAsync(Query query, string querySearchString,
|
||||
CancellationToken token)
|
||||
{
|
||||
var queryConstructor = new QueryConstructor(settings);
|
||||
|
||||
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForAllFilesAndFolders,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForAllFilesAndFolders,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<List<Result>> WindowsIndexTopLevelFolderSearchAsync(Query query, string path, CancellationToken token)
|
||||
private async Task<List<Result>> WindowsIndexTopLevelFolderSearchAsync(Query query, string path,
|
||||
CancellationToken token)
|
||||
{
|
||||
var queryConstructor = new QueryConstructor(settings);
|
||||
|
||||
return await IndexSearch.WindowsIndexSearchAsync(path,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForTopLevelDirectorySearch,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForTopLevelDirectorySearch,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private bool UseWindowsIndexForDirectorySearch(string locationPath)
|
||||
|
|
@ -189,11 +207,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return false;
|
||||
|
||||
if (settings.IndexSearchExcludedSubdirectoryPaths
|
||||
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
|
||||
.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
|
||||
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
|
||||
.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
|
||||
return false;
|
||||
|
||||
return IndexSearch.PathIsIndexed(pathToDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
using Flow.Launcher.Plugin.Explorer.Search;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
||||
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer
|
||||
{
|
||||
|
|
@ -18,9 +21,57 @@ 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 string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
|
||||
|
||||
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||
|
||||
public bool EnabledPathSearchKeyword { get; set; }
|
||||
|
||||
public string IndexOnlySearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
|
||||
|
||||
public bool EnabledIndexOnlySearchKeyword { get; set; }
|
||||
|
||||
internal enum ActionKeyword
|
||||
{
|
||||
SearchActionKeyword,
|
||||
PathSearchActionKeyword,
|
||||
FileContentSearchActionKeyword,
|
||||
IndexOnlySearchActionKeyword
|
||||
}
|
||||
|
||||
internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch
|
||||
{
|
||||
ActionKeyword.SearchActionKeyword => SearchActionKeyword,
|
||||
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
|
||||
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
|
||||
ActionKeyword.IndexOnlySearchActionKeyword => IndexOnlySearchActionKeyword
|
||||
};
|
||||
|
||||
internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch
|
||||
{
|
||||
ActionKeyword.SearchActionKeyword => SearchActionKeyword = keyword,
|
||||
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword,
|
||||
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword,
|
||||
ActionKeyword.IndexOnlySearchActionKeyword => IndexOnlySearchActionKeyword = keyword,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
|
||||
};
|
||||
|
||||
internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch
|
||||
{
|
||||
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword,
|
||||
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword,
|
||||
ActionKeyword.IndexOnlySearchActionKeyword => EnabledIndexOnlySearchKeyword,
|
||||
_ => null
|
||||
};
|
||||
|
||||
internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch
|
||||
{
|
||||
ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword = enable,
|
||||
ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable,
|
||||
ActionKeyword.IndexOnlySearchActionKeyword => EnabledIndexOnlySearchKeyword = enable,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -41,24 +41,24 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|||
Process.Start(psi);
|
||||
}
|
||||
|
||||
internal void UpdateActionKeyword(ActionKeywordProperty modifiedActionKeyword, string newActionKeyword, string oldActionKeyword)
|
||||
internal void UpdateActionKeyword(Settings.ActionKeyword modifiedActionKeyword, string newActionKeyword, string oldActionKeyword)
|
||||
{
|
||||
if (Settings.SearchActionKeyword == Settings.PathSearchActionKeyword)
|
||||
PluginManager.AddActionKeyword(Context.CurrentPluginMetadata.ID, newActionKeyword);
|
||||
else
|
||||
PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword);
|
||||
PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword);
|
||||
|
||||
switch (modifiedActionKeyword)
|
||||
{
|
||||
case ActionKeywordProperty.SearchActionKeyword:
|
||||
case Settings.ActionKeyword.SearchActionKeyword:
|
||||
Settings.SearchActionKeyword = newActionKeyword;
|
||||
break;
|
||||
case ActionKeywordProperty.PathSearchActionKeyword:
|
||||
case Settings.ActionKeyword.PathSearchActionKeyword:
|
||||
Settings.PathSearchActionKeyword = newActionKeyword;
|
||||
break;
|
||||
case ActionKeywordProperty.FileContentSearchActionKeyword:
|
||||
case Settings.ActionKeyword.FileContentSearchActionKeyword:
|
||||
Settings.FileContentSearchActionKeyword = newActionKeyword;
|
||||
break;
|
||||
case Settings.ActionKeyword.IndexOnlySearchActionKeyword:
|
||||
Settings.IndexOnlySearchActionKeyword = newActionKeyword;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -66,11 +66,4 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
|||
|
||||
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
|
||||
}
|
||||
|
||||
public enum ActionKeywordProperty
|
||||
{
|
||||
SearchActionKeyword,
|
||||
PathSearchActionKeyword,
|
||||
FileContentSearchActionKeyword
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
mc:Ignorable="d"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
Title="Action Keyword Setting" Height="200" Width="500">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
|
@ -16,15 +17,20 @@
|
|||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="180" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Margin="20 10 10 10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left" Text="Current Action Keyword:" />
|
||||
<TextBox Name="txtCurrentActionKeyword"
|
||||
<TextBox Name="TxtCurrentActionKeyword"
|
||||
Margin="10" Grid.Row="0" Width="105" Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1">
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding CurrentActionKeyword.Keyword}" />
|
||||
<CheckBox Name="ChkActionKeywordEnabled" Margin="10" Grid.Row="0" Grid.Column="2" Content="Enabled"
|
||||
Width="auto"
|
||||
VerticalAlignment="Center" IsChecked="{Binding CurrentActionKeyword.Enabled}"
|
||||
Visibility="{Binding Visible}"/>
|
||||
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.ColumnSpan="2" Margin="100 92 0 0" Grid.RowSpan="2">
|
||||
<Button Click="OnConfirmButtonClick"
|
||||
Margin="10 0 10 0" Width="80" Height="35"
|
||||
Content="OK" />
|
||||
|
|
@ -33,4 +39,4 @@
|
|||
Content="Cancel" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
||||
|
|
@ -1,16 +1,7 @@
|
|||
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Views
|
||||
{
|
||||
|
|
@ -21,32 +12,43 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
{
|
||||
private SettingsViewModel settingsViewModel;
|
||||
|
||||
private ActionKeywordView currentActionKeyword;
|
||||
|
||||
public ActionKeywordView CurrentActionKeyword { get; set; }
|
||||
|
||||
private List<ActionKeywordView> actionKeywordListView;
|
||||
|
||||
public ActionKeywordSetting(SettingsViewModel settingsViewModel, List<ActionKeywordView> actionKeywordListView, ActionKeywordView selectedActionKeyword)
|
||||
{
|
||||
InitializeComponent();
|
||||
private Settings settings;
|
||||
|
||||
public Visibility Visible => CurrentActionKeyword.Enabled is not null ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
public ActionKeywordSetting(SettingsViewModel settingsViewModel,
|
||||
List<ActionKeywordView> actionKeywordListView,
|
||||
ActionKeywordView selectedActionKeyword, Settings settings)
|
||||
{
|
||||
this.settingsViewModel = settingsViewModel;
|
||||
|
||||
currentActionKeyword = selectedActionKeyword;
|
||||
this.settings = settings;
|
||||
|
||||
txtCurrentActionKeyword.Text = selectedActionKeyword.Keyword;
|
||||
CurrentActionKeyword = selectedActionKeyword;
|
||||
|
||||
this.actionKeywordListView = actionKeywordListView;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var newActionKeyword = txtCurrentActionKeyword.Text;
|
||||
var newActionKeyword = TxtCurrentActionKeyword.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(newActionKeyword))
|
||||
return;
|
||||
|
||||
if (newActionKeyword == currentActionKeyword.Keyword)
|
||||
// reset to global so it does not take up an action keyword when disabled
|
||||
if (!CurrentActionKeyword.Enabled is not null && newActionKeyword != Query.GlobalPluginWildcardSign)
|
||||
settingsViewModel.UpdateActionKeyword(CurrentActionKeyword.KeywordProperty,
|
||||
Query.GlobalPluginWildcardSign, CurrentActionKeyword.Keyword);
|
||||
|
||||
if (newActionKeyword == CurrentActionKeyword.Keyword)
|
||||
{
|
||||
Close();
|
||||
|
||||
|
|
@ -54,18 +56,30 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
}
|
||||
|
||||
if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword)
|
||||
&& currentActionKeyword.KeywordProperty == ActionKeywordProperty.FileContentSearchActionKeyword)
|
||||
&& CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword)
|
||||
{
|
||||
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
|
||||
MessageBox.Show(
|
||||
settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
|
||||
{
|
||||
settingsViewModel.UpdateActionKeyword(currentActionKeyword.KeywordProperty, newActionKeyword, currentActionKeyword.Keyword);
|
||||
settingsViewModel.UpdateActionKeyword(CurrentActionKeyword.KeywordProperty, newActionKeyword,
|
||||
CurrentActionKeyword.Keyword);
|
||||
|
||||
actionKeywordListView.FirstOrDefault(x => x.Description == currentActionKeyword.Description).Keyword = newActionKeyword;
|
||||
actionKeywordListView.FirstOrDefault(x => x.Description == CurrentActionKeyword.Description).Keyword =
|
||||
newActionKeyword;
|
||||
|
||||
// automatically help users set this to enabled if an action keyword is set and currently disabled
|
||||
if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.IndexOnlySearchActionKeyword
|
||||
&& !settings.EnabledIndexOnlySearchKeyword)
|
||||
settings.EnabledIndexOnlySearchKeyword = true;
|
||||
|
||||
if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.PathSearchActionKeyword
|
||||
&& !settings.EnabledPathSearchKeyword)
|
||||
settings.EnabledPathSearchKeyword = true;
|
||||
|
||||
Close();
|
||||
|
||||
|
|
@ -82,4 +96,4 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
|
||||
xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
|
|
@ -17,13 +18,16 @@
|
|||
Text="{Binding Path, Mode=OneTime}"
|
||||
Margin="0,5,0,5" />
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="ListViewActionKeywords">
|
||||
<DataTemplate x:Key="ListViewActionKeywords"
|
||||
DataType="views:ActionKeywordView">
|
||||
<Grid>
|
||||
<TextBlock
|
||||
Text="{Binding Description, Mode=OneTime}"
|
||||
Foreground="{Binding Color, Mode=OneWay}"
|
||||
Margin="0,5,0,0" />
|
||||
<TextBlock
|
||||
Text="{Binding Keyword, Mode=OneTime}"
|
||||
Foreground="{Binding Color, Mode=OneWay}"
|
||||
Margin="250,5,0,0" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
|
|
|||
|
|
@ -35,28 +35,20 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
actionKeywordsListView = new List<ActionKeywordView>
|
||||
{
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search"),
|
||||
Keyword = this.viewModel.Settings.SearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.SearchActionKeyword
|
||||
},
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"),
|
||||
Keyword = this.viewModel.Settings.FileContentSearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.FileContentSearchActionKeyword
|
||||
},
|
||||
new ()
|
||||
{
|
||||
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path"),
|
||||
Keyword = this.viewModel.Settings.PathSearchActionKeyword,
|
||||
KeywordProperty = ActionKeywordProperty.PathSearchActionKeyword
|
||||
}
|
||||
new(Settings.ActionKeyword.SearchActionKeyword,
|
||||
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search")),
|
||||
new(Settings.ActionKeyword.FileContentSearchActionKeyword,
|
||||
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch")),
|
||||
new(Settings.ActionKeyword.PathSearchActionKeyword,
|
||||
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path")),
|
||||
new(Settings.ActionKeyword.IndexOnlySearchActionKeyword,
|
||||
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch"))
|
||||
};
|
||||
|
||||
lbxActionKeywords.ItemsSource = actionKeywordsListView;
|
||||
|
||||
ActionKeywordView.Init(viewModel.Settings, viewModel.Context.API);
|
||||
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
|
|
@ -80,8 +72,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
btnEdit.Visibility = Visibility.Visible;
|
||||
|
||||
if (lbxAccessLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0
|
||||
&& btnDelete.Visibility == Visibility.Visible
|
||||
&& btnEdit.Visibility == Visibility.Visible)
|
||||
&& btnDelete.Visibility == Visibility.Visible
|
||||
&& btnEdit.Visibility == Visibility.Visible)
|
||||
{
|
||||
btnDelete.Visibility = Visibility.Hidden;
|
||||
btnEdit.Visibility = Visibility.Hidden;
|
||||
|
|
@ -173,7 +165,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
if (selectedRow != null)
|
||||
{
|
||||
string msg = string.Format(viewModel.Context.API.GetTranslation("plugin_explorer_delete_folder_link"), selectedRow.Path);
|
||||
string msg = string.Format(viewModel.Context.API.GetTranslation("plugin_explorer_delete_folder_link"),
|
||||
selectedRow.Path);
|
||||
|
||||
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
|
|
@ -199,7 +192,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
{
|
||||
var selectedActionKeyword = lbxActionKeywords.SelectedItem as ActionKeywordView;
|
||||
|
||||
var actionKeywordWindow = new ActionKeywordSetting(viewModel, actionKeywordsListView, selectedActionKeyword);
|
||||
var actionKeywordWindow = new ActionKeywordSetting(viewModel, actionKeywordsListView,
|
||||
selectedActionKeyword, viewModel.Settings);
|
||||
|
||||
actionKeywordWindow.ShowDialog();
|
||||
|
||||
|
|
@ -207,7 +201,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
}
|
||||
else
|
||||
{
|
||||
var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ?? lbxExcludedPaths.SelectedItem as AccessLink;
|
||||
var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ??
|
||||
lbxExcludedPaths.SelectedItem as AccessLink;
|
||||
|
||||
if (selectedRow != null)
|
||||
{
|
||||
|
|
@ -223,7 +218,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
if (expExcludedPaths.IsExpanded)
|
||||
{
|
||||
var link = viewModel.Settings.IndexSearchExcludedSubdirectoryPaths.First(x => x.Path == selectedRow.Path);
|
||||
var link = viewModel.Settings.IndexSearchExcludedSubdirectoryPaths.First(x =>
|
||||
x.Path == selectedRow.Path);
|
||||
link.Path = folderBrowserDialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
|
@ -243,10 +239,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
var folderBrowserDialog = new FolderBrowserDialog();
|
||||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var newAccessLink = new AccessLink
|
||||
{
|
||||
Path = folderBrowserDialog.SelectedPath
|
||||
};
|
||||
var newAccessLink = new AccessLink {Path = folderBrowserDialog.SelectedPath};
|
||||
|
||||
AddAccessLink(newAccessLink);
|
||||
}
|
||||
|
|
@ -267,10 +260,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
{
|
||||
if (Directory.Exists(s))
|
||||
{
|
||||
var newFolderLink = new AccessLink
|
||||
{
|
||||
Path = s
|
||||
};
|
||||
var newFolderLink = new AccessLink {Path = s};
|
||||
|
||||
AddAccessLink(newFolderLink);
|
||||
}
|
||||
|
|
@ -283,7 +273,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
private void AddAccessLink(AccessLink newAccessLink)
|
||||
{
|
||||
if (expAccessLinks.IsExpanded
|
||||
&& !viewModel.Settings.QuickAccessLinks.Any(x => x.Path == newAccessLink.Path))
|
||||
&& !viewModel.Settings.QuickAccessLinks.Any(x => x.Path == newAccessLink.Path))
|
||||
{
|
||||
if (viewModel.Settings.QuickAccessLinks == null)
|
||||
viewModel.Settings.QuickAccessLinks = new List<AccessLink>();
|
||||
|
|
@ -321,9 +311,37 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
public class ActionKeywordView
|
||||
{
|
||||
public string Description { get; set; }
|
||||
private static Settings _settings;
|
||||
private static IPublicAPI _api;
|
||||
|
||||
public ActionKeywordProperty KeywordProperty { get; init; }
|
||||
public string Keyword { get; set; }
|
||||
public static void Init(Settings settings, IPublicAPI api)
|
||||
{
|
||||
_settings = settings;
|
||||
_api = api;
|
||||
}
|
||||
|
||||
internal ActionKeywordView(Settings.ActionKeyword actionKeyword, string description)
|
||||
{
|
||||
KeywordProperty = actionKeyword;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public string Description { get; private init; }
|
||||
public string Color => Enabled ?? true ? "Black" : "Gray";
|
||||
|
||||
internal Settings.ActionKeyword KeywordProperty { get; }
|
||||
|
||||
public string Keyword
|
||||
{
|
||||
get => _settings.GetActionKeyword(KeywordProperty);
|
||||
set => _settings.SetActionKeyword(KeywordProperty, value);
|
||||
}
|
||||
|
||||
public bool? Enabled
|
||||
{
|
||||
get => _settings.GetActionKeywordEnable(KeywordProperty);
|
||||
set => _settings.SetActionKeywordEnable(KeywordProperty,
|
||||
value ?? throw new ArgumentException("Unexpected null value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
"ID": "572be03c74c642baae319fc283e561a8",
|
||||
"ActionKeywords": [
|
||||
"*",
|
||||
"doc:"
|
||||
"*",
|
||||
"doc:",
|
||||
"*",
|
||||
"*"
|
||||
],
|
||||
"Name": "Explorer",
|
||||
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
|
||||
|
|
|
|||
Loading…
Reference in a new issue