Added DeepL API key setting
This commit is contained in:
3 files changed
+83
-2
No files matched your search
@@ -45,7 +45,7 @@ public partial class Setting : UserControl
|
||||
Func<Control> SetupDataControl
|
||||
);
|
||||
|
||||
private static async Task<Setting> ShowDeepLSettingAsync()
|
||||
private static async Task<Setting> ShowDeepLModeSettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetDeepLMode();
|
||||
var settingData = new SettingUIData(
|
||||
@@ -91,8 +91,32 @@ public partial class Setting : UserControl
|
||||
};
|
||||
}
|
||||
|
||||
private static async Task<Setting> ShowDeepLAPIKeySettingAsync()
|
||||
{
|
||||
var currentSetting = await AppSettings.GetDeepLAPIKey();
|
||||
var settingData = new SettingUIData(
|
||||
Icon: Icons.icons8_key_512,
|
||||
SettingName: () => "DeepL API Key",
|
||||
SettingExplanation: () => "The API key is required to use the DeepL translation service. You can find your API key on the DeepL website.",
|
||||
SetupDataControl: () =>
|
||||
{
|
||||
var textbox = new TextBox();
|
||||
textbox.Text = currentSetting;
|
||||
textbox.TextChanged += async (sender, args) => await AppSettings.SetDeepLAPIKey(textbox.Text);
|
||||
textbox.Dock = DockStyle.Fill;
|
||||
return textbox;
|
||||
}
|
||||
);
|
||||
|
||||
return new Setting(settingData)
|
||||
{
|
||||
Dock = DockStyle.Top,
|
||||
};
|
||||
}
|
||||
|
||||
public static IEnumerable<Task<Setting>> GetAllSettings()
|
||||
{
|
||||
yield return ShowDeepLSettingAsync();
|
||||
yield return ShowDeepLAPIKeySettingAsync();
|
||||
yield return ShowDeepLModeSettingAsync();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user