From 97817537566417936692e0ac03233d8ac7aa9f2e Mon Sep 17 00:00:00 2001 From: GabrielDuf Date: Thu, 23 Jul 2026 14:07:01 -0400 Subject: [PATCH] Confirm before resetting settings to defaults --- src/Languages/lang_en.json | 1 + .../Pages/SettingsPages/GeneralViewModel.cs | 7 ++- .../DialogPages/ResetSettingsDialog.axaml | 47 +++++++++++++++++++ .../DialogPages/ResetSettingsDialog.axaml.cs | 23 +++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/UniGetUI.Avalonia/Views/DialogPages/ResetSettingsDialog.axaml create mode 100644 src/UniGetUI.Avalonia/Views/DialogPages/ResetSettingsDialog.axaml.cs diff --git a/src/Languages/lang_en.json b/src/Languages/lang_en.json index 4114be383e..70d044f631 100644 --- a/src/Languages/lang_en.json +++ b/src/Languages/lang_en.json @@ -84,6 +84,7 @@ "Show UniGetUI": "Show UniGetUI", "Quit": "Quit", "Are you sure?": "Are you sure?", + "Do you really want to reset UniGetUI to its default settings? This action cannot be undone.": "Do you really want to reset UniGetUI to its default settings? This action cannot be undone.", "Do you really want to uninstall {0}?": "Do you really want to uninstall {0}?", "Do you really want to uninstall the following {0} packages?": "Do you really want to uninstall the following {0} packages?", "No": "No", diff --git a/src/UniGetUI.Avalonia/ViewModels/Pages/SettingsPages/GeneralViewModel.cs b/src/UniGetUI.Avalonia/ViewModels/Pages/SettingsPages/GeneralViewModel.cs index c33dad3027..58250b5b09 100644 --- a/src/UniGetUI.Avalonia/ViewModels/Pages/SettingsPages/GeneralViewModel.cs +++ b/src/UniGetUI.Avalonia/ViewModels/Pages/SettingsPages/GeneralViewModel.cs @@ -69,8 +69,13 @@ private static async Task ExportSettings(Visual? visual) } [RelayCommand] - private void ResetSettings(Visual? _) + private async Task ResetSettings(Visual? visual) { + if (visual is null || TopLevel.GetTopLevel(visual) is not Window owner) return; + var dialog = new ResetSettingsDialog(); + await dialog.ShowDialog(owner); + if (!dialog.Confirmed) return; + try { CoreSettings.ResetSettings(); } catch (Exception ex) { Logger.Error(ex); } AccessibilityAnnouncementService.Announce( diff --git a/src/UniGetUI.Avalonia/Views/DialogPages/ResetSettingsDialog.axaml b/src/UniGetUI.Avalonia/Views/DialogPages/ResetSettingsDialog.axaml new file mode 100644 index 0000000000..6b83d6531c --- /dev/null +++ b/src/UniGetUI.Avalonia/Views/DialogPages/ResetSettingsDialog.axaml @@ -0,0 +1,47 @@ + + + + + + + + + +