Skip to content

Commit 990159e

Browse files
authored
Merge branch 'dev' into ChannelSelect
2 parents 35594be + 424b575 commit 990159e

File tree

11 files changed

+180
-40
lines changed

11 files changed

+180
-40
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Flow.Launcher.Infrastructure;
1313
using Flow.Launcher.Infrastructure.Logger;
1414
using Flow.Launcher.Infrastructure.UserSettings;
15-
using CommunityToolkit.Mvvm.DependencyInjection;
1615
using Flow.Launcher.Plugin;
1716

1817
namespace Flow.Launcher.Core.Resource
@@ -35,6 +34,8 @@ public class Theme
3534
private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
3635
private string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);
3736

37+
public string CurrentTheme => _settings.Theme;
38+
3839
public bool BlurEnabled { get; set; }
3940

4041
private double mainWindowWidth;

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@
104104
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
105105
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
106106
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
107-
<system:String x:Key="logLevel">Log level</system:String>
108-
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
109-
<system:String x:Key="LogLevelINFO">Info</system:String>
110107

111108
<!-- Setting Plugin -->
112109
<system:String x:Key="searchplugin">Search Plugin</system:String>
@@ -306,6 +303,9 @@
306303
<system:String x:Key="userdatapath">User Data Location</system:String>
307304
<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>
308305
<system:String x:Key="userdatapathButton">Open Folder</system:String>
306+
<system:String x:Key="logLevel">Log Level</system:String>
307+
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
308+
<system:String x:Key="LogLevelINFO">Info</system:String>
309309

310310
<!-- FileManager Setting Dialog -->
311311
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>

Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Flow.Launcher.Core;
99
using Flow.Launcher.Core.Resource;
1010
using Flow.Launcher.Infrastructure;
11+
using Flow.Launcher.Infrastructure.Logger;
1112
using Flow.Launcher.Infrastructure.UserSettings;
1213
using Flow.Launcher.Plugin;
1314

@@ -44,7 +45,7 @@ public string LogFolderSize
4445
InternationalizationManager.Instance.GetTranslation("about_activate_times"),
4546
_settings.ActivateTimes
4647
);
47-
48+
4849
public int PrereleaseSelectedIndex
4950
{
5051
get => _settings.PrereleaseUpdateSource ? 1 : 0;
@@ -54,11 +55,36 @@ public int PrereleaseSelectedIndex
5455
OnPropertyChanged();
5556
}
5657
}
58+
59+
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
60+
61+
public List<LogLevelData> LogLevels { get; } =
62+
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
63+
64+
public LOGLEVEL LogLevel
65+
{
66+
get => _settings.LogLevel;
67+
set
68+
{
69+
if (_settings.LogLevel != value)
70+
{
71+
_settings.LogLevel = value;
72+
73+
Log.SetLogLevel(value);
74+
}
75+
}
76+
}
5777

5878
public SettingsPaneAboutViewModel(Settings settings, Updater updater)
5979
{
6080
_settings = settings;
6181
_updater = updater;
82+
UpdateEnumDropdownLocalizations();
83+
}
84+
85+
private void UpdateEnumDropdownLocalizations()
86+
{
87+
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
6288
}
6389

6490
[RelayCommand]
@@ -148,5 +174,4 @@ private static string BytesToReadableString(long bytes)
148174

149175
return "0 B";
150176
}
151-
152177
}

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using System.Windows.Forms;
54
using CommunityToolkit.Mvvm.Input;
65
using Flow.Launcher.Core;
76
using Flow.Launcher.Core.Configuration;
87
using Flow.Launcher.Core.Resource;
98
using Flow.Launcher.Helper;
10-
using Flow.Launcher.Infrastructure.Logger;
119
using Flow.Launcher.Infrastructure.UserSettings;
1210
using Flow.Launcher.Plugin;
1311
using Flow.Launcher.Plugin.SharedModels;
@@ -32,7 +30,6 @@ public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> {
3230
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
3331
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
3432
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
35-
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
3633

3734
public bool StartFlowLauncherOnSystemStartup
3835
{
@@ -145,16 +142,12 @@ public bool PortableMode
145142
public List<LastQueryModeData> LastQueryModes { get; } =
146143
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
147144

148-
public List<LogLevelData> LogLevels { get; } =
149-
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
150-
151145
private void UpdateEnumDropdownLocalizations()
152146
{
153147
DropdownDataGeneric<SearchWindowScreens>.UpdateLabels(SearchWindowScreens);
154148
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
155149
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
156150
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
157-
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
158151
}
159152

160153
public string Language
@@ -222,22 +215,6 @@ public bool AutoUpdates
222215
}
223216
}
224217

225-
public LOGLEVEL LogLevel
226-
{
227-
get => Settings.LogLevel;
228-
set
229-
{
230-
if (Settings.LogLevel != value)
231-
{
232-
Settings.LogLevel = value;
233-
234-
Log.SetLogLevel(value);
235-
236-
UpdateEnumDropdownLocalizations();
237-
}
238-
}
239-
}
240-
241218
[RelayCommand]
242219
private void SelectPython()
243220
{

Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@
129129
</StackPanel>
130130
</cc:Card>
131131

132+
<cc:Card Title="{DynamicResource logLevel}" Icon="&#xE749;">
133+
<ComboBox
134+
DisplayMemberPath="Display"
135+
ItemsSource="{Binding LogLevels}"
136+
SelectedValue="{Binding LogLevel}"
137+
SelectedValuePath="Value" />
138+
</cc:Card>
139+
132140
<TextBlock
133141
Margin="14 20 0 0"
134142
HorizontalAlignment="Center"

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,6 @@
278278
SelectedValue="{Binding Language}"
279279
SelectedValuePath="LanguageCode" />
280280
</cc:Card>
281-
282-
<cc:Card Title="{DynamicResource logLevel}" Margin="0 14 0 0">
283-
<ComboBox
284-
DisplayMemberPath="Display"
285-
ItemsSource="{Binding LogLevels}"
286-
SelectedValue="{Binding LogLevel}"
287-
SelectedValuePath="Value" />
288-
</cc:Card>
289281
</VirtualizingStackPanel>
290282
</ScrollViewer>
291283
</ui:Page>

Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<ItemGroup>
4040
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
4141
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
42+
<ProjectReference Include="..\..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />
4243
</ItemGroup>
4344

4445
<ItemGroup>
6.47 KB
Loading

Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<system:String x:Key="flowlauncher_plugin_sys_open_docs_tips_cmd">Flow Launcher Tips</system:String>
2828
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location_cmd">Flow Launcher UserData Folder</system:String>
2929
<system:String x:Key="flowlauncher_plugin_sys_toggle_game_mode_cmd">Toggle Game Mode</system:String>
30+
<system:String x:Key="flowlauncher_plugin_sys_theme_selector_cmd">Set the Flow Launcher Theme</system:String>
3031

3132
<!-- Command Descriptions -->
3233
<system:String x:Key="flowlauncher_plugin_sys_shutdown_computer">Shutdown Computer</system:String>
@@ -49,8 +50,9 @@
4950
<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>
5051
<system:String x:Key="flowlauncher_plugin_sys_open_userdata_location">Open the location where Flow Launcher's settings are stored</system:String>
5152
<system:String x:Key="flowlauncher_plugin_sys_toggle_game_mode">Toggle Game Mode</system:String>
53+
<system:String x:Key="flowlauncher_plugin_sys_theme_selector">Quickly change the Flow Launcher theme</system:String>
5254

53-
<!-- Dialogs -->
55+
<!-- Dialogs -->
5456
<system:String x:Key="flowlauncher_plugin_sys_dlgtitle_success">Success</system:String>
5557
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_settings_saved">All Flow Launcher settings saved</system:String>
5658
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded">Reloaded all applicable plugin data</system:String>

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Flow.Launcher.Infrastructure;
88
using Flow.Launcher.Infrastructure.Logger;
99
using Flow.Launcher.Infrastructure.UserSettings;
10-
using Flow.Launcher.Plugin.SharedCommands;
1110
using Windows.Win32;
1211
using Windows.Win32.Foundation;
1312
using Windows.Win32.Security;
@@ -20,6 +19,7 @@ namespace Flow.Launcher.Plugin.Sys
2019
public class Main : IPlugin, ISettingProvider, IPluginI18n
2120
{
2221
private PluginInitContext context;
22+
private ThemeSelector themeSelector;
2323
private Dictionary<string, string> KeywordTitleMappings = new Dictionary<string, string>();
2424

2525
// 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 @@ public Control CreateSettingPanel()
3434

3535
public List<Result> Query(Query query)
3636
{
37+
if(query.Search.StartsWith(ThemeSelector.Keyword))
38+
{
39+
return themeSelector.Query(query);
40+
}
41+
3742
var commands = Commands();
3843
var results = new List<Result>();
3944
foreach (var c in commands)
@@ -82,6 +87,7 @@ private string GetDynamicTitle(Query query, Result result)
8287
public void Init(PluginInitContext context)
8388
{
8489
this.context = context;
90+
themeSelector = new ThemeSelector(context);
8591
KeywordTitleMappings = new Dictionary<string, string>{
8692
{"Shutdown", "flowlauncher_plugin_sys_shutdown_computer_cmd"},
8793
{"Restart", "flowlauncher_plugin_sys_restart_computer_cmd"},
@@ -102,7 +108,8 @@ public void Init(PluginInitContext context)
102108
{"Open Log Location", "flowlauncher_plugin_sys_open_log_location_cmd"},
103109
{"Flow Launcher Tips", "flowlauncher_plugin_sys_open_docs_tips_cmd"},
104110
{"Flow Launcher UserData Folder", "flowlauncher_plugin_sys_open_userdata_location_cmd"},
105-
{"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"}
111+
{"Toggle Game Mode", "flowlauncher_plugin_sys_toggle_game_mode_cmd"},
112+
{"Set Flow Launcher Theme", "flowlauncher_plugin_sys_theme_selector_cmd"}
106113
};
107114
}
108115

@@ -451,6 +458,18 @@ private List<Result> Commands()
451458
context.API.ToggleGameMode();
452459
return true;
453460
}
461+
},
462+
new Result
463+
{
464+
Title = "Set Flow Launcher Theme",
465+
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_theme_selector"),
466+
IcoPath = "Images\\app.png",
467+
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\ue7fc"),
468+
Action = c =>
469+
{
470+
context.API.ChangeQuery($"{ThemeSelector.Keyword} ");
471+
return false;
472+
}
454473
}
455474
});
456475

0 commit comments

Comments
 (0)