Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

/// <summary>
/// Reloads any Plugins that have the
/// IReloadable implemented. It refeshes

Check warning on line 69 in Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`refeshes` is not a recognized word. (unrecognized-spelling)
/// Plugin's in memory data with new content
/// added by user.
/// </summary>
Expand Down Expand Up @@ -245,7 +245,7 @@
Task<Stream> HttpGetStreamAsync(string url, CancellationToken token = default);

/// <summary>
/// Download the specific url to a cretain file path

Check warning on line 248 in Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`cretain` is not a recognized word. (unrecognized-spelling)
/// </summary>
/// <param name="url">URL to download file</param>
/// <param name="filePath">path to save downloaded file</param>
Expand Down Expand Up @@ -613,5 +613,17 @@
/// Invoked when the actual theme of the application has changed. Currently, the plugin will continue to be subscribed even if it is turned off.
/// </summary>
event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged;

/// <summary>
/// Get the data directory of Flow Launcher.
/// </summary>
/// <returns></returns>
string GetDataDirectory();

/// <summary>
/// Get the log directory of Flow Launcher.
/// </summary>
/// <returns></returns>
string GetLogDirectory();
}
}
4 changes: 4 additions & 0 deletions Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@ public event ActualApplicationThemeChangedEventHandler ActualApplicationThemeCha
remove => _mainVM.ActualApplicationThemeChanged -= value;
}

public string GetDataDirectory() => DataLocation.DataDirectory();

public string GetLogDirectory() => DataLocation.VersionLogDirectory;

#endregion

#region Private Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_restart_computer">Are you sure you want to restart the computer?</system:String>
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_restart_computer_advanced">Are you sure you want to restart the computer with Advanced Boot Options?</system:String>
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_logoff_computer">Are you sure you want to log off?</system:String>
<system:String x:Key="flowlauncher_plugin_sys_dlgtitle_error">Error</system:String>
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_empty_recycle_bin_failed">Failed to empty the recycle bin. This might happen if:{0}- Some items are currently in use{0}- Some items can't be deleted due to permission{0}Please close any applications that might be using these files and try again.</system:String>

<system:String x:Key="flowlauncher_plugin_sys_command_keyword_setting_window_title">Command Keyword Setting</system:String>
<system:String x:Key="flowlauncher_plugin_sys_custom_command_keyword">Custom Command Keyword</system:String>
Expand Down
32 changes: 16 additions & 16 deletions Plugins/Flow.Launcher.Plugin.Sys/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.UserSettings;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.Security;
Expand Down Expand Up @@ -52,6 +50,8 @@
private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER |
SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED;

private const string Documentation = "https://flowlauncher.com/docs/#/usage-tips";

private PluginInitContext _context;
private Settings _settings;
private ThemeSelector _themeSelector;
Expand Down Expand Up @@ -165,7 +165,7 @@
return false;
}

if (!PInvoke.LookupPrivilegeValue(null, PInvoke.SE_SHUTDOWN_NAME, out var luid))

Check warning on line 168 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)

Check warning on line 168 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)
{
return false;
}
Expand All @@ -176,7 +176,7 @@
Privileges = new() { e0 = new LUID_AND_ATTRIBUTES { Luid = luid, Attributes = TOKEN_PRIVILEGES_ATTRIBUTES.SE_PRIVILEGE_ENABLED } }
};

if (!PInvoke.AdjustTokenPrivileges(tokenHandle, false, &privileges, 0, null, null))

Check warning on line 179 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)
{
return false;
}
Expand Down Expand Up @@ -214,7 +214,7 @@

if (result == MessageBoxResult.Yes)
if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);

Check warning on line 217 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)
else
Process.Start("shutdown", "/s /t 0");

Expand Down Expand Up @@ -317,7 +317,7 @@
new Result
{
Title = "Index Option",
IcoPath = "Images\\indexoption.png",

Check warning on line 320 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`indexoption` is not a recognized word. (unrecognized-spelling)
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe773"),
Action = c =>
{
Expand All @@ -338,11 +338,9 @@
var result = PInvoke.SHEmptyRecycleBin(new(), string.Empty, 0);
if (result != HRESULT.S_OK && result != HRESULT.E_UNEXPECTED)
{
_context.API.ShowMsgBox("Failed to empty the recycle bin. This might happen if:\n" +
"- A file in the recycle bin is in use\n" +
"- You don't have permission to delete some items\n" +
"Please close any applications that might be using these files and try again.",
"Error",
_context.API.ShowMsgBox(
string.Format(_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_empty_recycle_bin_failed"), Environment.NewLine),
_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_error"),
MessageBoxButton.OK, MessageBoxImage.Error);
}

Expand All @@ -352,7 +350,7 @@
new Result
{
Title = "Open Recycle Bin",
IcoPath = "Images\\openrecyclebin.png",

Check warning on line 353 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`openrecyclebin` is not a recognized word. (unrecognized-spelling)
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe74d"),
CopyText = recycleBinFolder,
Action = c =>
Expand Down Expand Up @@ -381,7 +379,7 @@
Action = c =>
{
_context.API.SaveAppAllSettings();
_context.API.ShowMsg(_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_success"),

Check warning on line 382 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`dlgtitle` is not a recognized word. (unrecognized-spelling)
_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_all_settings_saved"));
return true;
}
Expand All @@ -404,6 +402,8 @@
IcoPath = "Images\\app.png",
Action = c =>
{
// Hide the window first then open setting dialog because main window can be topmost window which will still display on top of the setting dialog for a while
_context.API.HideMainWindow();
_context.API.OpenSettingDialog();
return true;
}
Expand All @@ -420,7 +420,7 @@

_ = _context.API.ReloadAllPluginData().ContinueWith(_ =>
_context.API.ShowMsg(
_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_success"),

Check warning on line 423 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`dlgtitle` is not a recognized word. (unrecognized-spelling)
_context.API.GetTranslation(
"flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded")),
System.Threading.Tasks.TaskScheduler.Current);
Expand All @@ -445,11 +445,11 @@
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"),
Title = "Open Log Location",
IcoPath = "Images\\app.png",
CopyText = DataLocation.VersionLogDirectory,
AutoCompleteText = DataLocation.VersionLogDirectory,
CopyText = _context.API.GetLogDirectory(),
AutoCompleteText = _context.API.GetLogDirectory(),
Action = c =>
{
_context.API.OpenDirectory(DataLocation.VersionLogDirectory);
_context.API.OpenDirectory(_context.API.GetLogDirectory());
return true;
}
},
Expand All @@ -458,11 +458,11 @@
Title = "Flow Launcher Tips",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe897"),
IcoPath = "Images\\app.png",
CopyText = Constant.Documentation,
AutoCompleteText = Constant.Documentation,
CopyText = Documentation,
AutoCompleteText = Documentation,
Action = c =>
{
_context.API.OpenUrl(Constant.Documentation);
_context.API.OpenUrl(Documentation);
return true;
}
},
Expand All @@ -471,11 +471,11 @@
Title = "Flow Launcher UserData Folder",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"),
IcoPath = "Images\\app.png",
CopyText = DataLocation.DataDirectory(),
AutoCompleteText = DataLocation.DataDirectory(),
CopyText = _context.API.GetDataDirectory(),
AutoCompleteText = _context.API.GetDataDirectory(),
Action = c =>
{
_context.API.OpenDirectory(DataLocation.DataDirectory());
_context.API.OpenDirectory(_context.API.GetDataDirectory());
return true;
}
},
Expand Down
Loading