Added DeepL API key setting

This commit is contained in:
tsommer committed 2022-07-30 15:59:09 +02:00
1 parent d97b5cd0c1
commit 87c12de066
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();
}
}