mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into welcome_backspace_issue
This commit is contained in:
commit
7868703e08
24 changed files with 257 additions and 26 deletions
3
.github/dependabot.yml
vendored
3
.github/dependabot.yml
vendored
|
|
@ -8,7 +8,8 @@ updates:
|
|||
- package-ecosystem: "nuget" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
interval: "daily"
|
||||
open-pull-requests-limit: 3
|
||||
ignore:
|
||||
- dependency-name: "squirrel-windows"
|
||||
reviewers:
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Droplex" Version="1.7.0" />
|
||||
<PackageReference Include="FSharp.Core" Version="9.0.101" />
|
||||
<PackageReference Include="FSharp.Core" Version="9.0.201" />
|
||||
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.4.0" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
|
||||
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
|
||||
<PackageReference Include="StreamJsonRpc" Version="2.20.20" />
|
||||
<PackageReference Include="StreamJsonRpc" Version="2.21.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
/// Represent the plugin that using JsonPRC
|
||||
/// every JsonRPC plugin should has its own plugin instance
|
||||
/// </summary>
|
||||
internal abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
|
||||
public abstract class JsonRPCPluginBase : IAsyncPlugin, IContextMenu, ISettingProvider, ISavable
|
||||
{
|
||||
protected PluginInitContext Context;
|
||||
public const string JsonRPC = "JsonRPC";
|
||||
|
|
@ -157,6 +157,11 @@ namespace Flow.Launcher.Core.Plugin
|
|||
Settings?.Save();
|
||||
}
|
||||
|
||||
public bool NeedCreateSettingPanel()
|
||||
{
|
||||
return Settings.NeedCreateSettingPanel();
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
return Settings.CreateSettingPanel();
|
||||
|
|
|
|||
|
|
@ -109,10 +109,15 @@ namespace Flow.Launcher.Core.Plugin
|
|||
_storage.Save();
|
||||
}
|
||||
|
||||
public bool NeedCreateSettingPanel()
|
||||
{
|
||||
// If there are no settings or the settings configuration is empty, return null
|
||||
return Settings != null && Configuration != null && Configuration.Body.Count != 0;
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
if (Settings == null || Settings.Count == 0)
|
||||
return null;
|
||||
// No need to check if NeedCreateSettingPanel is true because CreateSettingPanel will only be called if it's true
|
||||
|
||||
var settingWindow = new UserControl();
|
||||
var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center };
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ using System.Windows.Shell;
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
namespace Flow.Launcher.Core.Resource
|
||||
|
|
@ -35,6 +34,8 @@ namespace Flow.Launcher.Core.Resource
|
|||
private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
|
||||
private string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);
|
||||
|
||||
public string CurrentTheme => _settings.Theme;
|
||||
|
||||
public bool BlurEnabled { get; set; }
|
||||
|
||||
private double mainWindowWidth;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MemoryPack" Version="1.21.3" />
|
||||
<PackageReference Include="MemoryPack" Version="1.21.4" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.12.19" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
|||
|
|
@ -48,17 +48,45 @@ namespace Flow.Launcher.Infrastructure.Logger
|
|||
configuration.AddTarget("file", fileTargetASyncWrapper);
|
||||
configuration.AddTarget("debug", debugTarget);
|
||||
|
||||
var fileRule = new LoggingRule("*", LogLevel.Debug, fileTargetASyncWrapper)
|
||||
{
|
||||
RuleName = "file"
|
||||
};
|
||||
#if DEBUG
|
||||
var fileRule = new LoggingRule("*", LogLevel.Debug, fileTargetASyncWrapper);
|
||||
var debugRule = new LoggingRule("*", LogLevel.Debug, debugTarget);
|
||||
var debugRule = new LoggingRule("*", LogLevel.Debug, debugTarget)
|
||||
{
|
||||
RuleName = "debug"
|
||||
};
|
||||
configuration.LoggingRules.Add(debugRule);
|
||||
#else
|
||||
var fileRule = new LoggingRule("*", LogLevel.Info, fileTargetASyncWrapper);
|
||||
#endif
|
||||
configuration.LoggingRules.Add(fileRule);
|
||||
LogManager.Configuration = configuration;
|
||||
}
|
||||
|
||||
public static void SetLogLevel(LOGLEVEL level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case LOGLEVEL.DEBUG:
|
||||
UseDebugLogLevel();
|
||||
break;
|
||||
default:
|
||||
UseInfoLogLevel();
|
||||
break;
|
||||
}
|
||||
Info(nameof(Logger), $"Using log level: {level}.");
|
||||
}
|
||||
|
||||
private static void UseDebugLogLevel()
|
||||
{
|
||||
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
|
||||
}
|
||||
|
||||
private static void UseInfoLogLevel()
|
||||
{
|
||||
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
|
||||
}
|
||||
|
||||
private static void LogFaultyFormat(string message)
|
||||
{
|
||||
var logger = LogManager.GetLogger("FaultyLogger");
|
||||
|
|
@ -206,4 +234,10 @@ namespace Flow.Launcher.Infrastructure.Logger
|
|||
LogInternal(message, LogLevel.Warn);
|
||||
}
|
||||
}
|
||||
|
||||
public enum LOGLEVEL
|
||||
{
|
||||
DEBUG,
|
||||
INFO
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Text.Json.Serialization;
|
|||
using System.Windows;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.Storage;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
|
|
@ -199,6 +200,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
}
|
||||
};
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public LOGLEVEL LogLevel { get; set; } = LOGLEVEL.INFO;
|
||||
|
||||
/// <summary>
|
||||
/// when false Alphabet static service will always return empty results
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ namespace Flow.Launcher
|
|||
{
|
||||
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
|
||||
{
|
||||
Log.SetLogLevel(_settings.LogLevel);
|
||||
|
||||
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
|
||||
|
||||
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@
|
|||
<PackageReference Include="NHotkey.Wpf" Version="3.0.0" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
|
||||
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
|
||||
<PackageReference Include="Jack251970.TaskScheduler" Version="2.12.1" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.12.1" />
|
||||
<PackageReference Include="VirtualizingWrapPanel" Version="2.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -300,6 +300,9 @@
|
|||
<system:String x:Key="userdatapath">User Data Location</system:String>
|
||||
<system:String x:Key="userdatapathToolTip">User settings and installed plugins are saved in the user data folder. This location may vary depending on whether it's in portable mode or not.</system:String>
|
||||
<system:String x:Key="userdatapathButton">Open Folder</system:String>
|
||||
<system:String x:Key="logLevel">Log Level</system:String>
|
||||
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
|
||||
<system:String x:Key="LogLevelINFO">Info</system:String>
|
||||
|
||||
<!-- FileManager Setting Dialog -->
|
||||
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using CommunityToolkit.Mvvm.Input;
|
|||
using Flow.Launcher.Core;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
|
|
@ -45,10 +46,35 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
_settings.ActivateTimes
|
||||
);
|
||||
|
||||
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
|
||||
|
||||
public List<LogLevelData> LogLevels { get; } =
|
||||
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
|
||||
|
||||
public LOGLEVEL LogLevel
|
||||
{
|
||||
get => _settings.LogLevel;
|
||||
set
|
||||
{
|
||||
if (_settings.LogLevel != value)
|
||||
{
|
||||
_settings.LogLevel = value;
|
||||
|
||||
Log.SetLogLevel(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsPaneAboutViewModel(Settings settings, Updater updater)
|
||||
{
|
||||
_settings = settings;
|
||||
_updater = updater;
|
||||
UpdateEnumDropdownLocalizations();
|
||||
}
|
||||
|
||||
private void UpdateEnumDropdownLocalizations()
|
||||
{
|
||||
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
|
@ -138,5 +164,4 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
|
||||
return "0 B";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Flow.Launcher.Core;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,14 @@
|
|||
</StackPanel>
|
||||
</cc:Card>
|
||||
|
||||
<cc:Card Title="{DynamicResource logLevel}" Icon="">
|
||||
<ComboBox
|
||||
DisplayMemberPath="Display"
|
||||
ItemsSource="{Binding LogLevels}"
|
||||
SelectedValue="{Binding LogLevel}"
|
||||
SelectedValuePath="Value" />
|
||||
</cc:Card>
|
||||
|
||||
<TextBlock
|
||||
Margin="14 20 0 0"
|
||||
HorizontalAlignment="Center"
|
||||
|
|
|
|||
|
|
@ -90,13 +90,13 @@ namespace Flow.Launcher.ViewModel
|
|||
private Control _bottomPart2;
|
||||
public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null;
|
||||
|
||||
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider settingProvider && settingProvider.CreateSettingPanel() != null;
|
||||
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider && (PluginPair.Plugin is not JsonRPCPluginBase jsonRPCPluginBase || jsonRPCPluginBase.NeedCreateSettingPanel());
|
||||
public Control SettingControl
|
||||
=> IsExpanded
|
||||
? _settingControl
|
||||
??= PluginPair.Plugin is not ISettingProvider settingProvider
|
||||
? null
|
||||
: settingProvider.CreateSettingPanel()
|
||||
??= HasSettingControl
|
||||
? ((ISettingProvider)PluginPair.Plugin).CreateSettingPanel()
|
||||
: null
|
||||
: null;
|
||||
private ImageSource _image = ImageLoader.MissingImage;
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.1" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Do not upgrade System.Data.OleDb since we are .Net7.0 -->
|
||||
<PackageReference Include="System.Data.OleDb" Version="8.0.1" />
|
||||
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
|
||||
<PackageReference Include="tlbimp-Microsoft.Search.Interop" Version="1.0.0" />
|
||||
|
|
|
|||
|
|
@ -593,7 +593,10 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
var constructedUrlPart = string.Format("{0}/{1}/", acceptedSource, author);
|
||||
|
||||
return url.StartsWith(acceptedSource) &&
|
||||
Context.API.GetAllPlugins().Any(x => x.Metadata.Website.StartsWith(constructedUrlPart));
|
||||
Context.API.GetAllPlugins().Any(x =>
|
||||
!string.IsNullOrEmpty(x.Metadata.Website) &&
|
||||
x.Metadata.Website.StartsWith(constructedUrlPart)
|
||||
);
|
||||
}
|
||||
|
||||
internal async ValueTask<List<Result>> RequestInstallOrUpdateAsync(string search, CancellationToken token,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
|
||||
<ProjectReference Include="..\..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
BIN
Plugins/Flow.Launcher.Plugin.Sys/Images/theme_selector.png
Normal file
BIN
Plugins/Flow.Launcher.Plugin.Sys/Images/theme_selector.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
|
|
@ -27,6 +27,7 @@
|
|||
<system:String x:Key="flowlauncher_plugin_sys_open_docs_tips_cmd">Flow Launcher Tips</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location_cmd">Flow Launcher UserData Folder</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_toggle_game_mode_cmd">Toggle Game Mode</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_theme_selector_cmd">Set the Flow Launcher Theme</system:String>
|
||||
|
||||
<!-- Command Descriptions -->
|
||||
<system:String x:Key="flowlauncher_plugin_sys_shutdown_computer">Shutdown Computer</system:String>
|
||||
|
|
@ -49,8 +50,9 @@
|
|||
<system:String x:Key="flowlauncher_plugin_sys_open_docs_tips">Visit Flow Launcher's documentation for more help and how to use tips</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location">Open the location where Flow Launcher's settings are stored</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_toggle_game_mode">Toggle Game Mode</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_theme_selector">Quickly change the Flow Launcher theme</system:String>
|
||||
|
||||
<!-- Dialogs -->
|
||||
<!-- Dialogs -->
|
||||
<system:String x:Key="flowlauncher_plugin_sys_dlgtitle_success">Success</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_settings_saved">All Flow Launcher settings saved</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded">Reloaded all applicable plugin data</system:String>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.Windows;
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Security;
|
||||
|
|
@ -20,6 +19,7 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
public class Main : IPlugin, ISettingProvider, IPluginI18n
|
||||
{
|
||||
private PluginInitContext context;
|
||||
private ThemeSelector themeSelector;
|
||||
private Dictionary<string, string> KeywordTitleMappings = new Dictionary<string, string>();
|
||||
|
||||
// SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure, software updates, or other predefined reasons.
|
||||
|
|
@ -34,6 +34,11 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
if(query.Search.StartsWith(ThemeSelector.Keyword))
|
||||
{
|
||||
return themeSelector.Query(query);
|
||||
}
|
||||
|
||||
var commands = Commands();
|
||||
var results = new List<Result>();
|
||||
foreach (var c in commands)
|
||||
|
|
@ -82,6 +87,7 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
public void Init(PluginInitContext context)
|
||||
{
|
||||
this.context = context;
|
||||
themeSelector = new ThemeSelector(context);
|
||||
KeywordTitleMappings = new Dictionary<string, string>{
|
||||
{"Shutdown", "flowlauncher_plugin_sys_shutdown_computer_cmd"},
|
||||
{"Restart", "flowlauncher_plugin_sys_restart_computer_cmd"},
|
||||
|
|
@ -102,7 +108,8 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
{"Open Log Location", "flowlauncher_plugin_sys_open_log_location_cmd"},
|
||||
{"Flow Launcher Tips", "flowlauncher_plugin_sys_open_docs_tips_cmd"},
|
||||
{"Flow Launcher UserData Folder", "flowlauncher_plugin_sys_open_userdata_location_cmd"},
|
||||
{"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"}
|
||||
{"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"},
|
||||
{"Set Flow Launcher Theme", "flowlauncher_plugin_sys_theme_selector_cmd"}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -451,6 +458,18 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
context.API.ToggleGameMode();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Set Flow Launcher Theme",
|
||||
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_theme_selector"),
|
||||
IcoPath = "Images\\app.png",
|
||||
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\ue7fc"),
|
||||
Action = c =>
|
||||
{
|
||||
context.API.ChangeQuery($"{ThemeSelector.Keyword} ");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
115
Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs
Normal file
115
Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Sys
|
||||
{
|
||||
public class ThemeSelector
|
||||
{
|
||||
public const string Keyword = "fltheme";
|
||||
|
||||
private readonly Settings _settings;
|
||||
private readonly Theme _theme;
|
||||
private readonly PluginInitContext _context;
|
||||
|
||||
#region Theme Selection
|
||||
|
||||
// Theme select codes simplified from SettingsPaneThemeViewModel.cs
|
||||
|
||||
private Theme.ThemeData _selectedTheme;
|
||||
private Theme.ThemeData SelectedTheme
|
||||
{
|
||||
get => _selectedTheme ??= Themes.Find(v => v.FileNameWithoutExtension == _theme.CurrentTheme);
|
||||
set
|
||||
{
|
||||
_selectedTheme = value;
|
||||
_theme.ChangeTheme(value.FileNameWithoutExtension);
|
||||
|
||||
if (_theme.BlurEnabled && _settings.UseDropShadowEffect)
|
||||
{
|
||||
_theme.RemoveDropShadowEffectFromCurrentTheme();
|
||||
_settings.UseDropShadowEffect = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Theme.ThemeData> Themes => _theme.LoadAvailableThemes();
|
||||
|
||||
#endregion
|
||||
|
||||
public ThemeSelector(PluginInitContext context)
|
||||
{
|
||||
_context = context;
|
||||
_theme = Ioc.Default.GetRequiredService<Theme>();
|
||||
_settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
}
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
var search = query.SecondToEndSearch;
|
||||
if (string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
return Themes.Select(CreateThemeResult)
|
||||
.OrderBy(x => x.Title)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return Themes.Select(theme => (theme, matchResult: _context.API.FuzzySearch(search, theme.Name)))
|
||||
.Where(x => x.matchResult.IsSearchPrecisionScoreMet())
|
||||
.Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData))
|
||||
.OrderBy(x => x.Title)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private Result CreateThemeResult(Theme.ThemeData theme) => CreateThemeResult(theme, 0, null);
|
||||
|
||||
private Result CreateThemeResult(Theme.ThemeData theme, int score, IList<int> highlightData)
|
||||
{
|
||||
string themeName = theme.Name;
|
||||
string title;
|
||||
if (theme == SelectedTheme)
|
||||
{
|
||||
title = $"{theme.Name} ★";
|
||||
// Set current theme to the top
|
||||
score = 2000;
|
||||
}
|
||||
else
|
||||
{
|
||||
title = theme.Name;
|
||||
// Set them to 1000 so that they are higher than other non-theme records
|
||||
score = 1000;
|
||||
}
|
||||
|
||||
string description = string.Empty;
|
||||
if (theme.IsDark == true)
|
||||
{
|
||||
description += _context.API.GetTranslation("TypeIsDarkToolTip");
|
||||
}
|
||||
|
||||
if (theme.HasBlur == true)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(description))
|
||||
description += " ";
|
||||
description += _context.API.GetTranslation("TypeHasBlurToolTip");
|
||||
}
|
||||
|
||||
return new Result
|
||||
{
|
||||
Title = title,
|
||||
TitleHighlightData = highlightData,
|
||||
SubTitle = description,
|
||||
IcoPath = "Images\\theme_selector.png",
|
||||
Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue790"),
|
||||
Score = score,
|
||||
Action = c =>
|
||||
{
|
||||
SelectedTheme = theme;
|
||||
_context.API.ReQuery();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -334,11 +334,14 @@ Or download the [early access version](https://github.com/Flow-Launcher/Prerelea
|
|||
<a href="https://coderabbit.ai/">
|
||||
<img src="https://github.com/Flow-Launcher/Flow.Launcher/assets/6903107/7c996d74-0c69-4011-922f-a95ca7e874b0" width="30%" alt="Coderabbit Logo" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://github.com/TheBestPessimist">
|
||||
<img src='https://avatars.githubusercontent.com/u/4482210?v=4' width="10%"/>
|
||||
</a>
|
||||
<a href="https://github.com/AjmalParkar006">
|
||||
<img src='https://avatars.githubusercontent.com/u/76547256?v=4' width="10%"/>
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://appwrite.io">
|
||||
|
|
|
|||
Loading…
Reference in a new issue