Ask user for API token when no one was set
This commit is contained in:
parent
882c2bba2b
commit
58e0d86d52
@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
public static class Version
|
public static class Version
|
||||||
{
|
{
|
||||||
public static string Text => $"v0.8.4 (2023-02-12), .NET {Environment.Version}";
|
public static string Text => $"v0.8.5 (2023-02-12), .NET {Environment.Version}";
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
using Processor;
|
using DataModel.Database;
|
||||||
|
using Processor;
|
||||||
|
using UI_WinForms.Dialogs;
|
||||||
|
|
||||||
namespace UI_WinForms.Components;
|
namespace UI_WinForms.Components;
|
||||||
|
|
||||||
@ -11,6 +13,31 @@ public partial class Main : UserControl
|
|||||||
|
|
||||||
// Register the something changed event to trigger the export:
|
// Register the something changed event to trigger the export:
|
||||||
AppEvents.WhenSomethingChanged += async (_, _) => await ExportProcessor.TriggerExport();
|
AppEvents.WhenSomethingChanged += async (_, _) => await ExportProcessor.TriggerExport();
|
||||||
|
|
||||||
|
// Check, if the DeepL integration is enabled, but no API key is set:
|
||||||
|
this.Load += async (sender, args) =>
|
||||||
|
{
|
||||||
|
var deepLAPIKey = await AppSettings.GetDeepLAPIKey();
|
||||||
|
var deepLMode = await AppSettings.GetDeepLMode();
|
||||||
|
if (deepLMode is not SettingDeepLMode.DISABLED && string.IsNullOrWhiteSpace(deepLAPIKey))
|
||||||
|
{
|
||||||
|
// Show the input dialog to ask the user for the DeepL API key:
|
||||||
|
var inputDialog = InputDialog.Show(new InputDialog.Options
|
||||||
|
{
|
||||||
|
Title = "I18NCommander - DeepL API Key",
|
||||||
|
Message = "The DeepL integration is enabled, but there is no API key set. Do you want to set one now?",
|
||||||
|
OkButtonText = "Set API key",
|
||||||
|
CancelButtonText = "No, thanks",
|
||||||
|
ShowQuestionCheckbox = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (inputDialog.DialogResult == DialogResult.OK)
|
||||||
|
{
|
||||||
|
await AppSettings.SetDeepLAPIKey(inputDialog.Text);
|
||||||
|
AppEvents.SettingsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
|
private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user