Skip to content

Commit a67c919

Browse files
committed
Add function
1 parent 4e424ef commit a67c919

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

Flow.Launcher/Resources/Pages/WelcomePageUserType.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,14 @@
158158
<StackPanel>
159159
<!-- CLI Radio -->
160160
<RadioButton
161+
Checked="OnStyleChecked"
161162
Content="{DynamicResource Welcome_Page_UserType_CLI_Title}"
162163
GroupName="UserTypeGroup"
163164
IsChecked="True"
164165
Style="{StaticResource RadioCardStyle}">
165166
<RadioButton.Tag>
166167
<local:RadioCardData
168+
Key="CLI"
167169
Bullet1="{StaticResource Welcome_Page_UserType_CLI_Sub1}"
168170
Bullet2="{StaticResource Welcome_Page_UserType_CLI_Sub2}"
169171
Description1="{StaticResource Welcome_Page_UserType_CLI_Desc}"
@@ -173,11 +175,13 @@
173175
<!-- GUI Radio -->
174176
<RadioButton
175177
Margin="0 12 0 0"
178+
Checked="OnStyleChecked"
176179
Content="{DynamicResource Welcome_Page_UserType_GUI_Title}"
177180
GroupName="UserTypeGroup"
178181
Style="{StaticResource RadioCardStyle}">
179182
<RadioButton.Tag>
180183
<local:RadioCardData
184+
Key="GUI"
181185
Bullet1="{StaticResource Welcome_Page_UserType_GUI_Sub1}"
182186
Bullet2="{StaticResource Welcome_Page_UserType_GUI_Sub2}"
183187
Bullet3="{StaticResource Welcome_Page_UserType_GUI_Sub3}"

Flow.Launcher/Resources/Pages/WelcomePageUserType.xaml.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
using Flow.Launcher.Helper;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Windows;
4+
using System.Windows.Controls;
5+
using Flow.Launcher.Helper;
26
using Flow.Launcher.Infrastructure.Hotkey;
37
using Flow.Launcher.Infrastructure.UserSettings;
48
using System.Windows.Navigation;
59
using CommunityToolkit.Mvvm.Input;
610
using Flow.Launcher.ViewModel;
711
using System.Windows.Media;
812
using CommunityToolkit.Mvvm.DependencyInjection;
13+
using Flow.Launcher.Core.Plugin;
14+
using Flow.Launcher.Infrastructure;
15+
using System.IO;
16+
using System.Text.Json;
917

1018
namespace Flow.Launcher.Resources.Pages;
1119

1220
public class RadioCardData
1321
{
22+
public string Key { get; set; }
1423
public string Icon { get; set; }
1524
public string Description1 { get; set; }
1625
public string Bullet1 { get; set; }
@@ -34,6 +43,41 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
3443
Ioc.Default.GetRequiredService<WelcomeViewModel>().PageNum = 3;
3544
InitializeComponent();
3645
}
46+
47+
private void OnStyleChecked(object sender, RoutedEventArgs e)
48+
{
49+
var rb = sender as RadioButton;
50+
if (rb?.Tag is not RadioCardData data) return;
51+
52+
var settings = Ioc.Default.GetRequiredService<Settings>();
53+
54+
var pluginDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", "Flow.Launcher.Plugin.Explorer");
55+
var explorerSettingsPath = Path.Combine(pluginDirectory, "Settings.json");
56+
57+
if (File.Exists(explorerSettingsPath))
58+
{
59+
var explorerSettingsJson = File.ReadAllText(explorerSettingsPath);
60+
var explorerSettings = JsonSerializer.Deserialize<Dictionary<string, object>>(explorerSettingsJson);
3761

62+
switch (data.Key)
63+
{
64+
case "CLI":
65+
if (explorerSettings != null)
66+
explorerSettings["UseLocationAsWorkingDir"] = false;
67+
settings.AutoCompleteHotkey = "Tab";
68+
break;
69+
70+
case "GUI":
71+
if (explorerSettings != null)
72+
explorerSettings["UseLocationAsWorkingDir"] = true;
73+
settings.AutoCompleteHotkey = $"{KeyConstant.Alt} + Right";
74+
break;
75+
}
76+
77+
File.WriteAllText(explorerSettingsPath, JsonSerializer.Serialize(explorerSettings, new JsonSerializerOptions { WriteIndented = true }));
78+
}
79+
80+
settings.Save();
81+
}
3882
}
3983

0 commit comments

Comments
 (0)