Merge branch 'dev' into code_quality

This commit is contained in:
VictoriousRaptor 2025-07-22 14:32:29 +08:00 committed by GitHub
commit 08f17c4f05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 65 additions and 29 deletions

View file

@ -613,5 +613,17 @@ namespace Flow.Launcher.Plugin
/// Invoked when the actual theme of the application has changed. Currently, the plugin will continue to be subscribed even if it is turned off. /// 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> /// </summary>
event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged; event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged;
/// <summary>
/// Get the user data directory of Flow Launcher.
/// </summary>
/// <returns></returns>
string GetDataDirectory();
/// <summary>
/// Get the log directory of Flow Launcher.
/// </summary>
/// <returns></returns>
string GetLogDirectory();
} }
} }

View file

@ -599,6 +599,10 @@ namespace Flow.Launcher
remove => _mainVM.ActualApplicationThemeChanged -= value; remove => _mainVM.ActualApplicationThemeChanged -= value;
} }
public string GetDataDirectory() => DataLocation.DataDirectory();
public string GetLogDirectory() => DataLocation.VersionLogDirectory;
#endregion #endregion
#region Private Methods #region Private Methods

View file

@ -1,15 +1,15 @@
using Flow.Launcher.Core.ExternalPlugins; using System;
using System;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Text;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Helper; using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin.SharedCommands;
namespace Flow.Launcher namespace Flow.Launcher
{ {
@ -44,7 +44,7 @@ namespace Flow.Launcher
var websiteUrl = exception switch var websiteUrl = exception switch
{ {
FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website), FlowPluginException pluginException => GetIssuesUrl(pluginException.Metadata.Website),
_ => Constant.IssuesUrl _ => Constant.IssuesUrl
}; };
@ -73,17 +73,36 @@ namespace Flow.Launcher
Margin = new Thickness(0) Margin = new Thickness(0)
}; };
var link = new Hyperlink Hyperlink link = null;
try
{ {
IsEnabled = true var uri = new Uri(url);
};
link.Inlines.Add(url); link = new Hyperlink
link.NavigateUri = new Uri(url); {
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); IsEnabled = true
};
link.Inlines.Add(url);
link.NavigateUri = uri;
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);
}
catch (Exception)
{
// Leave link as null if the URL is invalid
}
paragraph.Inlines.Add(textBeforeUrl); paragraph.Inlines.Add(textBeforeUrl);
paragraph.Inlines.Add(" "); paragraph.Inlines.Add(" ");
paragraph.Inlines.Add(link); if (link is null)
{
// Add the URL as plain text if it is invalid
paragraph.Inlines.Add(url);
}
else
{
// Add the hyperlink if it is valid
paragraph.Inlines.Add(link);
}
paragraph.Inlines.Add("\n"); paragraph.Inlines.Add("\n");
return paragraph; return paragraph;

View file

@ -37,7 +37,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" /> <ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup> </ItemGroup>

View file

@ -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">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_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_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 permissions{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_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> <system:String x:Key="flowlauncher_plugin_sys_custom_command_keyword">Custom Command Keyword</system:String>

View file

@ -5,8 +5,6 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.UserSettings;
using Windows.Win32; using Windows.Win32;
using Windows.Win32.Foundation; using Windows.Win32.Foundation;
using Windows.Win32.Security; using Windows.Win32.Security;
@ -52,6 +50,8 @@ namespace Flow.Launcher.Plugin.Sys
private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER | private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER |
SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED; SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED;
private const string Documentation = "https://flowlauncher.com/docs/#/usage-tips";
private PluginInitContext _context; private PluginInitContext _context;
private Settings _settings; private Settings _settings;
private ThemeSelector _themeSelector; private ThemeSelector _themeSelector;
@ -338,11 +338,9 @@ namespace Flow.Launcher.Plugin.Sys
var result = PInvoke.SHEmptyRecycleBin(new(), string.Empty, 0); var result = PInvoke.SHEmptyRecycleBin(new(), string.Empty, 0);
if (result != HRESULT.S_OK && result != HRESULT.E_UNEXPECTED) if (result != HRESULT.S_OK && result != HRESULT.E_UNEXPECTED)
{ {
_context.API.ShowMsgBox("Failed to empty the recycle bin. This might happen if:\n" + _context.API.ShowMsgBox(
"- A file in the recycle bin is in use\n" + string.Format(_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_empty_recycle_bin_failed"), Environment.NewLine),
"- You don't have permission to delete some items\n" + _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_error"),
"Please close any applications that might be using these files and try again.",
"Error",
MessageBoxButton.OK, MessageBoxImage.Error); MessageBoxButton.OK, MessageBoxImage.Error);
} }
@ -404,6 +402,8 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\app.png", IcoPath = "Images\\app.png",
Action = c => 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(); _context.API.OpenSettingDialog();
return true; return true;
} }
@ -445,11 +445,11 @@ namespace Flow.Launcher.Plugin.Sys
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"), Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"),
Title = "Open Log Location", Title = "Open Log Location",
IcoPath = "Images\\app.png", IcoPath = "Images\\app.png",
CopyText = DataLocation.VersionLogDirectory, CopyText = _context.API.GetLogDirectory(),
AutoCompleteText = DataLocation.VersionLogDirectory, AutoCompleteText = _context.API.GetLogDirectory(),
Action = c => Action = c =>
{ {
_context.API.OpenDirectory(DataLocation.VersionLogDirectory); _context.API.OpenDirectory(_context.API.GetLogDirectory());
return true; return true;
} }
}, },
@ -458,11 +458,11 @@ namespace Flow.Launcher.Plugin.Sys
Title = "Flow Launcher Tips", Title = "Flow Launcher Tips",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe897"), Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe897"),
IcoPath = "Images\\app.png", IcoPath = "Images\\app.png",
CopyText = Constant.Documentation, CopyText = Documentation,
AutoCompleteText = Constant.Documentation, AutoCompleteText = Documentation,
Action = c => Action = c =>
{ {
_context.API.OpenUrl(Constant.Documentation); _context.API.OpenUrl(Documentation);
return true; return true;
} }
}, },
@ -471,11 +471,11 @@ namespace Flow.Launcher.Plugin.Sys
Title = "Flow Launcher UserData Folder", Title = "Flow Launcher UserData Folder",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"), Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"),
IcoPath = "Images\\app.png", IcoPath = "Images\\app.png",
CopyText = DataLocation.DataDirectory(), CopyText = _context.API.GetDataDirectory(),
AutoCompleteText = DataLocation.DataDirectory(), AutoCompleteText = _context.API.GetDataDirectory(),
Action = c => Action = c =>
{ {
_context.API.OpenDirectory(DataLocation.DataDirectory()); _context.API.OpenDirectory(_context.API.GetDataDirectory());
return true; return true;
} }
}, },