Skip to content

Commit 1cec01c

Browse files
committed
Merge branch 'delete_clipboard_jsonrpc' of https://github.com/Jack251970/Flow.Launcher into delete_clipboard_jsonrpc
2 parents 68e1aad + 96eb673 commit 1cec01c

File tree

13 files changed

+258
-80
lines changed

13 files changed

+258
-80
lines changed

Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6767
</PackageReference>
6868
<PackageReference Include="NLog" Version="4.7.10" />
69-
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
69+
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0">
70+
<PrivateAssets>all</PrivateAssets>
71+
</PackageReference>
7072
<PackageReference Include="SharpVectors.Wpf" Version="1.8.4.2" />
7173
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
7274
<!--ToolGood.Words.Pinyin v3.0.2.6 results in high memory usage when search with pinyin is enabled-->

Flow.Launcher.Plugin/AllowedLanguage.cs

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,42 @@ public static class AllowedLanguage
6565
public static bool IsDotNet(string language)
6666
{
6767
return language.Equals(CSharp, StringComparison.OrdinalIgnoreCase)
68-
|| language.Equals(FSharp, StringComparison.OrdinalIgnoreCase);
68+
|| language.Equals(FSharp, StringComparison.OrdinalIgnoreCase);
69+
}
70+
71+
/// <summary>
72+
/// Determines if this language is a Python language
73+
/// </summary>
74+
/// <param name="language"></param>
75+
/// <returns></returns>
76+
public static bool IsPython(string language)
77+
{
78+
return language.Equals(Python, StringComparison.OrdinalIgnoreCase)
79+
|| language.Equals(PythonV2, StringComparison.OrdinalIgnoreCase);
80+
}
81+
82+
/// <summary>
83+
/// Determines if this language is a Node.js language
84+
/// </summary>
85+
/// <param name="language"></param>
86+
/// <returns></returns>
87+
public static bool IsNodeJs(string language)
88+
{
89+
return language.Equals(TypeScript, StringComparison.OrdinalIgnoreCase)
90+
|| language.Equals(TypeScriptV2, StringComparison.OrdinalIgnoreCase)
91+
|| language.Equals(JavaScript, StringComparison.OrdinalIgnoreCase)
92+
|| language.Equals(JavaScriptV2, StringComparison.OrdinalIgnoreCase);
93+
}
94+
95+
/// <summary>
96+
/// Determines if this language is a executable language
97+
/// </summary>
98+
/// <param name="language"></param>
99+
/// <returns></returns>
100+
public static bool IsExecutable(string language)
101+
{
102+
return language.Equals(Executable, StringComparison.OrdinalIgnoreCase)
103+
|| language.Equals(ExecutableV2, StringComparison.OrdinalIgnoreCase);
69104
}
70105

71106
/// <summary>
@@ -76,15 +111,9 @@ public static bool IsDotNet(string language)
76111
public static bool IsAllowed(string language)
77112
{
78113
return IsDotNet(language)
79-
|| language.Equals(Python, StringComparison.OrdinalIgnoreCase)
80-
|| language.Equals(PythonV2, StringComparison.OrdinalIgnoreCase)
81-
|| language.Equals(Executable, StringComparison.OrdinalIgnoreCase)
82-
|| language.Equals(TypeScript, StringComparison.OrdinalIgnoreCase)
83-
|| language.Equals(JavaScript, StringComparison.OrdinalIgnoreCase)
84-
|| language.Equals(ExecutableV2, StringComparison.OrdinalIgnoreCase)
85-
|| language.Equals(TypeScriptV2, StringComparison.OrdinalIgnoreCase)
86-
|| language.Equals(JavaScriptV2, StringComparison.OrdinalIgnoreCase);
87-
;
114+
|| IsPython(language)
115+
|| IsNodeJs(language)
116+
|| IsExecutable(language);
88117
}
89118
}
90119
}

Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
<PrivateAssets>all</PrivateAssets>
7777
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7878
</PackageReference>
79-
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
79+
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0">
80+
<PrivateAssets>all</PrivateAssets>
81+
</PackageReference>
8082
</ItemGroup>
8183

8284
</Project>

Flow.Launcher/ActionKeywords.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void ReplaceActionKeyword(string id, IReadOnlyList<string> removedAction
8080
}
8181

8282
// Update action keywords text and close window
83-
_pluginViewModel.OnActionKeywordsChanged();
83+
_pluginViewModel.OnActionKeywordsTextChanged();
8484
Close();
8585
}
8686
}

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@
9898
<!-- https://github.com/Flow-Launcher/Flow.Launcher/issues/1772#issuecomment-1502440801 -->
9999
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
100100
<PackageReference Include="NHotkey.Wpf" Version="3.0.0" />
101-
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
101+
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0">
102+
<PrivateAssets>all</PrivateAssets>
103+
</PackageReference>
102104
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
103105
<PackageReference Include="TaskScheduler" Version="2.12.1" />
104106
<PackageReference Include="VirtualizingWrapPanel" Version="2.1.1" />

Flow.Launcher/Images/EXE.png

-2.12 KB
Binary file not shown.

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@
345345
<system:String x:Key="logfolder">Log Folder</system:String>
346346
<system:String x:Key="clearlogfolder">Clear Logs</system:String>
347347
<system:String x:Key="clearlogfolderMessage">Are you sure you want to delete all logs?</system:String>
348+
<system:String x:Key="cachefolder">Cache Folder</system:String>
348349
<system:String x:Key="clearcachefolder">Clear Caches</system:String>
349350
<system:String x:Key="clearcachefolderMessage">Are you sure you want to delete all caches?</system:String>
350351
<system:String x:Key="clearfolderfailMessage">Failed to clear part of folders and files. Please see log file for more information</system:String>

Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ private void OpenParentOfSettingsFolder(object parameter)
144144
App.API.OpenDirectory(parentFolderPath);
145145
}
146146

147+
[RelayCommand]
148+
private void OpenCacheFolder()
149+
{
150+
App.API.OpenDirectory(DataLocation.CacheDirectory);
151+
}
152+
147153
[RelayCommand]
148154
private void OpenLogsFolder()
149155
{
@@ -180,7 +186,8 @@ private bool ClearLogFolder()
180186
{
181187
try
182188
{
183-
dir.Delete(true);
189+
// Log folders are the last level of folders
190+
dir.Delete(recursive: false);
184191
}
185192
catch (Exception e)
186193
{
@@ -208,6 +215,7 @@ private bool ClearCacheFolder()
208215
{
209216
var success = true;
210217
var cacheDirectory = GetCacheDir();
218+
var pluginCacheDirectory = GetPluginCacheDir();
211219
var cacheFiles = GetCacheFiles();
212220

213221
cacheFiles.ForEach(f =>
@@ -223,13 +231,15 @@ private bool ClearCacheFolder()
223231
}
224232
});
225233

226-
cacheDirectory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
234+
// Firstly, delete plugin cache directories
235+
pluginCacheDirectory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
227236
.ToList()
228237
.ForEach(dir =>
229238
{
230239
try
231240
{
232-
dir.Delete(true);
241+
// Plugin may create directories in its cache directory
242+
dir.Delete(recursive: true);
233243
}
234244
catch (Exception e)
235245
{
@@ -238,6 +248,18 @@ private bool ClearCacheFolder()
238248
}
239249
});
240250

251+
// Then, delete plugin directory
252+
var dir = GetPluginCacheDir();
253+
try
254+
{
255+
dir.Delete(recursive: false);
256+
}
257+
catch (Exception e)
258+
{
259+
App.API.LogException(ClassName, $"Failed to delete cache directory: {dir.Name}", e);
260+
success = false;
261+
}
262+
241263
OnPropertyChanged(nameof(CacheFolderSize));
242264

243265
return success;
@@ -248,6 +270,11 @@ private static DirectoryInfo GetCacheDir()
248270
return new DirectoryInfo(DataLocation.CacheDirectory);
249271
}
250272

273+
private static DirectoryInfo GetPluginCacheDir()
274+
{
275+
return new DirectoryInfo(DataLocation.PluginCacheDirectory);
276+
}
277+
251278
private static List<FileInfo> GetCacheFiles()
252279
{
253280
return GetCacheDir().EnumerateFiles("*", SearchOption.AllDirectories).ToList();

Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginStoreViewModel.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,62 @@ public string FilterText
2323
}
2424
}
2525

26+
private bool showDotNet = true;
27+
public bool ShowDotNet
28+
{
29+
get => showDotNet;
30+
set
31+
{
32+
if (showDotNet != value)
33+
{
34+
showDotNet = value;
35+
OnPropertyChanged();
36+
}
37+
}
38+
}
39+
40+
private bool showPython = true;
41+
public bool ShowPython
42+
{
43+
get => showPython;
44+
set
45+
{
46+
if (showPython != value)
47+
{
48+
showPython = value;
49+
OnPropertyChanged();
50+
}
51+
}
52+
}
53+
54+
private bool showNodeJs = true;
55+
public bool ShowNodeJs
56+
{
57+
get => showNodeJs;
58+
set
59+
{
60+
if (showNodeJs != value)
61+
{
62+
showNodeJs = value;
63+
OnPropertyChanged();
64+
}
65+
}
66+
}
67+
68+
private bool showExecutable = true;
69+
public bool ShowExecutable
70+
{
71+
get => showExecutable;
72+
set
73+
{
74+
if (showExecutable != value)
75+
{
76+
showExecutable = value;
77+
OnPropertyChanged();
78+
}
79+
}
80+
}
81+
2682
public IList<PluginStoreItemViewModel> ExternalPlugins => App.API.GetPluginManifest()?
2783
.Select(p => new PluginStoreItemViewModel(p))
2884
.OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease)
@@ -42,6 +98,27 @@ private async Task RefreshExternalPluginsAsync()
4298

4399
public bool SatisfiesFilter(PluginStoreItemViewModel plugin)
44100
{
101+
// Check plugin language
102+
var pluginShown = false;
103+
if (AllowedLanguage.IsDotNet(plugin.Language))
104+
{
105+
pluginShown = ShowDotNet;
106+
}
107+
else if (AllowedLanguage.IsPython(plugin.Language))
108+
{
109+
pluginShown = ShowPython;
110+
}
111+
else if (AllowedLanguage.IsNodeJs(plugin.Language))
112+
{
113+
pluginShown = ShowNodeJs;
114+
}
115+
else if (AllowedLanguage.IsExecutable(plugin.Language))
116+
{
117+
pluginShown = ShowExecutable;
118+
}
119+
if (!pluginShown) return false;
120+
121+
// Check plugin name & description
45122
return string.IsNullOrEmpty(FilterText) ||
46123
App.API.FuzzySearch(FilterText, plugin.Name).IsSearchPrecisionScoreMet() ||
47124
App.API.FuzzySearch(FilterText, plugin.Description).IsSearchPrecisionScoreMet();

Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
<ui:FontIcon Glyph="&#xe8b7;" />
125125
</MenuItem.Icon>
126126
</MenuItem>
127+
128+
<MenuItem Command="{Binding OpenCacheFolderCommand}" Header="{DynamicResource cachefolder}">
129+
<MenuItem.Icon>
130+
<ui:FontIcon Glyph="&#xe8b7;" />
131+
</MenuItem.Icon>
132+
</MenuItem>
127133
</ui:MenuFlyout>
128134
</ui:FlyoutService.Flyout>
129135
</Button>

0 commit comments

Comments
 (0)