-
-
Notifications
You must be signed in to change notification settings - Fork 456
Add Flow Launcher Theme Selector to Sys plugin #2448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jack251970
merged 19 commits into
Flow-Launcher:dev
from
Odotocodot:flow-theme-selector-plugin
Mar 13, 2025
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1b31e9c
Create Flow Launcher Theme Selector plugin
Odotocodot 5e69bd7
Merge branch 'dev' into flow-theme-selector-plugin
taooceros 49a71d7
Move Theme Selector into Sys plugin
Odotocodot 7a0be2c
Remove Reloadable from theme selector
Odotocodot 874a785
cache keywordIndex
jjw24 4005054
implement the complete IDisposable pattern
jjw24 fe8bb6b
Merge branch 'dev' into flow-theme-selector-plugin
jjw24 fce3b3a
Fix crash on theme search
Odotocodot a2372d8
Merge branch 'dev' into flow-theme-selector-plugin
Jack251970 b2dc128
Use dependency injection to fix issue
Jack251970 59fbef1
Use public current theme
Jack251970 9395b89
Make default score larger
Jack251970 468c0b2
Change ico & glyph
Jack251970 bad304b
Query themes every time
Jack251970 94774b2
Requery and do not close window
Jack251970 d099a39
Fix theme change drop shadow effect issue & Add theme description
Jack251970 b2f8ad9
Fix null exception
Odotocodot 84cd1a8
Remove extra code
Odotocodot f503e41
Merge branch 'dev' into flow-theme-selector-plugin
Odotocodot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using Flow.Launcher.Core.Resource; | ||
|
|
||
| namespace Flow.Launcher.Plugin.Sys | ||
| { | ||
| public class ThemeSelector : IDisposable | ||
| { | ||
| public const string Keyword = "fltheme"; | ||
|
|
||
| private readonly PluginInitContext context; | ||
| private IEnumerable<string> themes; | ||
|
|
||
| public ThemeSelector(PluginInitContext context) | ||
| { | ||
| this.context = context; | ||
| context.API.VisibilityChanged += OnVisibilityChanged; | ||
Jack251970 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
jjw24 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public List<Result> Query(Query query) | ||
| { | ||
| if (query.IsReQuery) | ||
| { | ||
| LoadThemes(); | ||
| } | ||
|
|
||
| string search = query.Search[(query.Search.IndexOf(Keyword, StringComparison.Ordinal) + Keyword.Length + 1)..]; | ||
|
|
||
| if (string.IsNullOrWhiteSpace(search)) | ||
| { | ||
| return themes.Select(CreateThemeResult) | ||
| .OrderBy(x => x.Title) | ||
| .ToList(); | ||
| } | ||
|
|
||
| return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(search, theme))) | ||
| .Where(x => x.matchResult.IsSearchPrecisionScoreMet()) | ||
| .Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData)) | ||
| .OrderBy(x => x.Title) | ||
| .ToList(); | ||
| } | ||
jjw24 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private void OnVisibilityChanged(object sender, VisibilityChangedEventArgs args) | ||
| { | ||
| if (args.IsVisible && !context.CurrentPluginMetadata.Disabled) | ||
| { | ||
| LoadThemes(); | ||
| } | ||
| } | ||
|
|
||
| private void LoadThemes() | ||
| => themes = ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension); | ||
Jack251970 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Odotocodot marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private static Result CreateThemeResult(string theme) => CreateThemeResult(theme, 0, null); | ||
|
|
||
| private static Result CreateThemeResult(string theme, int score, IList<int> highlightData) | ||
| { | ||
| string title; | ||
| if (theme == ThemeManager.Instance.Settings.Theme) | ||
| { | ||
| title = $"{theme} ★"; | ||
| score = 2000; | ||
| } | ||
| else | ||
| { | ||
| title = theme; | ||
| } | ||
|
|
||
| return new Result | ||
| { | ||
| Title = title, | ||
| TitleHighlightData = highlightData, | ||
| Glyph = new GlyphInfo("/Resources/#Segoe Fluent Icons", "\ue790"), | ||
| Score = score, | ||
| Action = c => | ||
| { | ||
| ThemeManager.Instance.ChangeTheme(theme); | ||
| return true; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| if (context != null && context.API != null) | ||
| { | ||
| context.API.VisibilityChanged -= OnVisibilityChanged; | ||
| } | ||
| } | ||
jjw24 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.