Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 6271305

Browse files
committed
Merge branch 'master' into ShowContextMenu
2 parents 6b55518 + ae5956f commit 6271305

8 files changed

Lines changed: 133 additions & 143 deletions

File tree

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ $default-branch ]
6+
pull_request:
7+
branches: [ $default-branch ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: windows-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v1
18+
with:
19+
dotnet-version: 5.0.x
20+
- name: Restore dependencies
21+
run: dotnet restore
22+
- name: Build
23+
run: dotnet build --no-restore -c Release
24+
- name: Upload Artifact
25+
uses: actions/upload-artifact@v2
26+
with:
27+
name: Flow.Launcher.Plugin.Everything
28+
path: Output/Release/Flow.Launcher.Plugin.Everything
29+

EverythingSettings.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
ItemsSource="{Binding GetSortOptions, Mode=OneWay}"
8686
SelectedItem="{Binding SortOption}"
8787
SelectionChanged="onSelectionChange">
88+
ItemsSource="{Binding GetSortOptions, Mode=OneWay}"
8889
<ComboBox.ItemTemplate>
8990
<DataTemplate>
9091
<Grid>

Flow.Launcher.Plugin.Everything.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
</Content>
5353
</ItemGroup>
5454
<ItemGroup>
55-
<PackageReference Include="Flow.Launcher.Plugin" Version="2.0.0" />
55+
<PackageReference Include="Flow.Launcher.Plugin" Version="2.1.0" />
5656
<PackageReference Include="Droplex" Version="1.4.0" />
57-
<PackageReference Include="JetBrains.Annotations" Version="2021.2.0" />
57+
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
5858
<PackageReference Include="System.Runtime" Version="4.3.1" />
5959
</ItemGroup>
6060
<ItemGroup>

Helper/EnumNameConverter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace Flow.Launcher.Plugin.Everything.Helper
1111
{
1212
class EnumNameConverter : IValueConverter
1313
{
14-
private Dictionary<string, SortOption> translationRecord = new Dictionary<string, SortOption>();
15-
1614
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1715
{
1816
return value is SortOption option ? option.GetTranslatedName() : value;

Main.cs

Lines changed: 95 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public List<Result> Query(Query query)
5757
IcoPath = "Images\\warning.png",
5858
Action = _ =>
5959
{
60-
if (FilesFolders.FileExists(_settings.EverythingInstalledPath))
61-
FilesFolders.OpenPath(_settings.EverythingInstalledPath);
60+
if (_settings.EverythingInstalledPath.FileExists())
61+
_context.API.OpenDirectory(_settings.EverythingInstalledPath);
6262

6363
return true;
6464
}
@@ -109,23 +109,25 @@ private Result CreateResult(string keyword, SearchResult searchResult)
109109
case ResultType.Folder:
110110
if (!_settings.LaunchHidden)
111111
{
112-
Process.Start(_settings.ExplorerPath,
113-
_settings.ExplorerArgs.Replace(Settings.DirectoryPathPlaceHolder, $"\"{path}\""));
112+
_context.API.OpenDirectory(path);
114113
}
115114
else
116115
{
116+
// Launch hidden is no longer supported due to API change.
117+
// This the default behaviour kept
117118
ProcessStartInfo startInfo = new ProcessStartInfo();
118119
//Hide the process
119120
startInfo.UseShellExecute = false;
120121
startInfo.RedirectStandardOutput = true;
121122
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
122123
startInfo.CreateNoWindow = true;
123124
//Set file and args
124-
startInfo.FileName = _settings.ExplorerPath;
125-
startInfo.Arguments = _settings.ExplorerArgs.Replace(Settings.DirectoryPathPlaceHolder, $"\"{path}\"");
125+
startInfo.FileName = "explorer";
126+
startInfo.Arguments = $"\"{path}\"";
126127
//Start the process
127128
Process proc = Process.Start(startInfo);
128129
}
130+
129131
break;
130132
case ResultType.Volume:
131133
case ResultType.File:
@@ -158,34 +160,6 @@ private Result CreateResult(string keyword, SearchResult searchResult)
158160
return r;
159161
}
160162

161-
private List<ContextMenu> GetDefaultContextMenu()
162-
{
163-
List<ContextMenu> defaultContextMenus = new List<ContextMenu>();
164-
ContextMenu openFolderContextMenu = new ContextMenu
165-
{
166-
Name = _context.API.GetTranslation("flowlauncher_plugin_everything_open_containing_folder"),
167-
Command = _settings.ExplorerPath,
168-
Argument = $"{_settings.ExplorerArgs}",
169-
ImagePath = "Images\\folder.png"
170-
};
171-
172-
defaultContextMenus.Add(openFolderContextMenu);
173-
174-
string editorPath = string.IsNullOrEmpty(_settings.EditorPath) ? "notepad.exe" : _settings.EditorPath;
175-
176-
ContextMenu openWithEditorContextMenu = new ContextMenu
177-
{
178-
Name = string.Format(_context.API.GetTranslation("flowlauncher_plugin_everything_open_with_editor"), Path.GetFileNameWithoutExtension(editorPath)),
179-
Command = editorPath,
180-
Argument = $" {Settings.FilePathPlaceHolder}",
181-
ImagePath = editorPath
182-
};
183-
184-
defaultContextMenus.Add(openWithEditorContextMenu);
185-
186-
return defaultContextMenus;
187-
}
188-
189163
public void Init(PluginInitContext context)
190164
{
191165
_context = context;
@@ -279,103 +253,109 @@ public string GetTranslatedPluginDescription()
279253

280254
public List<Result> LoadContextMenus(Result selectedResult)
281255
{
282-
SearchResult record = selectedResult.ContextData as SearchResult;
283-
List<Result> contextMenus = new List<Result>();
284-
if (record == null) return contextMenus;
256+
if (selectedResult.ContextData is not SearchResult record)
257+
return new List<Result>();
285258

286-
List<ContextMenu> availableContextMenus = new List<ContextMenu>();
287-
availableContextMenus.AddRange(GetDefaultContextMenu());
288-
availableContextMenus.AddRange(_settings.ContextMenus);
259+
var icoPath = record.Type == ResultType.File ? "Images\\file.png" : "Images\\folder.png";
289260

290-
if (record.Type == ResultType.File)
261+
List<Result> contextMenus = new List<Result>
291262
{
292-
foreach (ContextMenu contextMenu in availableContextMenus)
263+
new()
293264
{
294-
var menu = contextMenu;
295-
contextMenus.Add(new Result
265+
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_open_containing_folder"),
266+
Action = _ =>
296267
{
297-
Title = contextMenu.Name,
298-
Action = _ =>
299-
{
300-
var parentPath = Directory.GetParent(record.FullPath);
301-
302-
if ((menu.Argument.Trim() == Settings.DirectoryPathPlaceHolder || string.IsNullOrWhiteSpace(menu.Argument)) && _settings.ExplorerPath.Trim() == Settings.Explorer)
303-
menu.Argument = Settings.DefaultExplorerArgsWithFilePath;
304-
305-
string argument = menu.Argument.Replace(Settings.FilePathPlaceHolder, '"' + record.FullPath + '"')
306-
.Replace(Settings.DirectoryPathPlaceHolder, '"' + parentPath.ToString() + '"');
307-
308-
309-
try
310-
{
311-
Process.Start(menu.Command, argument);
312-
}
313-
catch
314-
{
315-
_context.API.ShowMsg(string.Format(_context.API.GetTranslation("flowlauncher_plugin_everything_canot_start"), record.FullPath), string.Empty, string.Empty);
316-
return false;
317-
}
318-
return true;
319-
},
320-
IcoPath = contextMenu.ImagePath
321-
});
268+
_context.API.OpenDirectory(Path.GetDirectoryName(record.FullPath), record.FullPath);
269+
return true;
270+
},
271+
IcoPath = icoPath,
272+
Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue8de")
322273
}
323-
}
324-
325-
var icoPath = (record.Type == ResultType.File) ? "Images\\file.png" : "Images\\folder.png";
274+
};
326275

327-
if (_settings.ShowWindowsContextMenu)
276+
if (record.Type is ResultType.File)
328277
{
329-
contextMenus.Add(new Result
330-
{
331-
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_show_windows_context_menu"),
332-
Action = (context) =>
333-
{
334-
var fileInfos = new FileInfo[] { new(record.FullPath) };
335-
336-
var screenWithMouseCursor = System.Windows.Forms.Screen.FromPoint(System.Windows.Forms.Cursor.Position);
337-
var xOfScreenCenter = screenWithMouseCursor.WorkingArea.Left + screenWithMouseCursor.WorkingArea.Width / 2;
338-
var yOfScreenCenter = screenWithMouseCursor.WorkingArea.Top + screenWithMouseCursor.WorkingArea.Height / 2;
339-
var showPosition = new System.Drawing.Point(xOfScreenCenter, yOfScreenCenter);
340-
341-
new Peter.ShellContextMenu().ShowContextMenu(fileInfos, showPosition);
342-
343-
return true;
344-
},
345-
IcoPath = icoPath
346-
});
278+
var notepadPath = string.IsNullOrEmpty(_settings.EditorPath) ? "notepad.exe" : _settings.EditorPath;
279+
contextMenus.Add(new Result
280+
{
281+
Title = string.Format(
282+
_context.API.GetTranslation("flowlauncher_plugin_everything_open_with_editor"),
283+
Path.GetFileNameWithoutExtension(notepadPath)
284+
),
285+
Action = state =>
286+
{
287+
using var notepad = new Process();
288+
notepad.StartInfo = new ProcessStartInfo()
289+
{
290+
FileName = notepadPath,
291+
Arguments = record.FullPath
292+
};
293+
if (state.SpecialKeyState.CtrlPressed && state.SpecialKeyState.ShiftPressed)
294+
{
295+
notepad.StartInfo.Verb = "runAs";
296+
}
297+
Task.Run(() => notepad.Start());
298+
return true;
299+
},
300+
Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue932")
301+
});
347302
}
348303

349-
contextMenus.Add(new Result
304+
if (_settings.ShowWindowsContextMenu)
350305
{
351-
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_copy_path"),
352-
Action = (context) =>
306+
contextMenus.Add(new Result
353307
{
354-
Clipboard.SetDataObject(record.FullPath);
355-
return true;
356-
},
357-
IcoPath = icoPath
358-
});
308+
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_show_windows_context_menu"),
309+
Action = (context) =>
310+
{
311+
var fileInfos = new FileInfo[] { new(record.FullPath) };
359312

360-
contextMenus.Add(new Result
361-
{
362-
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_copy"),
363-
Action = (context) =>
313+
var screenWithMouseCursor = System.Windows.Forms.Screen.FromPoint(System.Windows.Forms.Cursor.Position);
314+
var xOfScreenCenter = screenWithMouseCursor.WorkingArea.Left + screenWithMouseCursor.WorkingArea.Width / 2;
315+
var yOfScreenCenter = screenWithMouseCursor.WorkingArea.Top + screenWithMouseCursor.WorkingArea.Height / 2;
316+
var showPosition = new System.Drawing.Point(xOfScreenCenter, yOfScreenCenter);
317+
318+
new Peter.ShellContextMenu().ShowContextMenu(fileInfos, showPosition);
319+
320+
return true;
321+
},
322+
IcoPath = icoPath
323+
});
324+
}
325+
326+
contextMenus.Add(
327+
new()
364328
{
365-
Clipboard.SetFileDropList(new System.Collections.Specialized.StringCollection
329+
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_copy_path"),
330+
Action = _ =>
366331
{
367-
record.FullPath
368-
});
369-
return true;
370-
},
371-
IcoPath = icoPath
372-
});
332+
Clipboard.SetDataObject(record.FullPath);
333+
return true;
334+
},
335+
IcoPath = icoPath,
336+
Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue8c8")
337+
});
338+
contextMenus.Add(
339+
new Result
340+
{
341+
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_copy"),
342+
Action = _ =>
343+
{
344+
Clipboard.SetFileDropList(new System.Collections.Specialized.StringCollection
345+
{
346+
record.FullPath
347+
});
348+
return true;
349+
},
350+
IcoPath = icoPath,
351+
Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue8c8")
352+
});
373353

374-
if (record.Type == ResultType.File || record.Type == ResultType.Folder)
354+
if (record.Type is ResultType.File or ResultType.Folder)
375355
contextMenus.Add(new Result
376356
{
377357
Title = _context.API.GetTranslation("flowlauncher_plugin_everything_delete"),
378-
Action = (context) =>
358+
Action = _ =>
379359
{
380360
try
381361
{
@@ -392,9 +372,9 @@ public List<Result> LoadContextMenus(Result selectedResult)
392372

393373
return true;
394374
},
395-
IcoPath = icoPath
375+
IcoPath = icoPath,
376+
Glyph = new("/Resources/#Segoe Fluent Icons", "\ue74d")
396377
});
397-
398378
return contextMenus;
399379
}
400380

@@ -403,4 +383,5 @@ public Control CreateSettingPanel()
403383
return new EverythingSettings(_settings, new SettingsViewModel(_api, _settings, _context));
404384
}
405385
}
386+
406387
}

Settings.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,6 @@ public class Settings
1111

1212
public string EditorPath { get; set; } = "";
1313

14-
internal const string Explorer = "explorer";
15-
16-
internal const string alternativeExplorerPath = "explorer.exe";
17-
18-
internal string explorerPath = Explorer;
19-
20-
public string ExplorerPath
21-
{
22-
get => explorerPath.Trim() switch
23-
{
24-
"" => Explorer,
25-
alternativeExplorerPath => Explorer,
26-
_ => explorerPath
27-
}; set => explorerPath = value;
28-
}
29-
public string ExplorerArgs { get; set; } = DirectoryPathPlaceHolder;
30-
31-
internal const string DirectoryPathPlaceHolder = "%s";
32-
33-
internal const string FilePathPlaceHolder = "%f";
34-
35-
internal const string DefaultExplorerArgsWithFilePath = "/select, %f";
36-
3714
public List<ContextMenu> ContextMenus = new List<ContextMenu>();
3815

3916
public int MaxSearchCount { get; set; } = DefaultMaxSearchCount;

crowdin.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
files:
2+
- source: Languages/en.xaml
3+
translation: /%original_path%/%two_letters_code%.xaml
4+
commit_message: '[ci skip]'

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"ActionKeyword": "*",
44
"Name": "Everything",
55
"Description": "Search Everything",
6-
"Author": "qianlifeng,orzfly",
7-
"Version": "1.5.6",
6+
"Author": "qianlifeng, orzfly",
7+
"Version": "1.6.0",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher.Plugin.Everything",
1010
"IcoPath": "Images\\find.png",

0 commit comments

Comments
 (0)