From 02cad0bd2ba0e5a531305c22f472e756f1fcb5be Mon Sep 17 00:00:00 2001 From: Chernykh Aleksandr Date: Thu, 23 Apr 2026 01:22:43 +0300 Subject: [PATCH 1/6] commit --- src/KeyKeeper/App.axaml.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/KeyKeeper/App.axaml.cs b/src/KeyKeeper/App.axaml.cs index a55380a..701b73c 100644 --- a/src/KeyKeeper/App.axaml.cs +++ b/src/KeyKeeper/App.axaml.cs @@ -19,6 +19,7 @@ public partial class App : Application public override void OnFrameworkInitializationCompleted() { + AppSettings.Load(); if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { // Avoid duplicate validations from both Avalonia and the CommunityToolkit. From 7306c20fff551ce753376bcc2873eed21ca4d231 Mon Sep 17 00:00:00 2001 From: Chernykh Aleksandr Date: Thu, 23 Apr 2026 01:22:50 +0300 Subject: [PATCH 2/6] commit --- src/KeyKeeper/SettingsWindow.cs | 64 +++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/src/KeyKeeper/SettingsWindow.cs b/src/KeyKeeper/SettingsWindow.cs index 3f0911f..bf08122 100644 --- a/src/KeyKeeper/SettingsWindow.cs +++ b/src/KeyKeeper/SettingsWindow.cs @@ -1,25 +1,61 @@ -using Avalonia.Controls; -using Avalonia.Controls.Shapes; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Layout; using Avalonia.Media; namespace KeyKeeper.Views; + public class SettingsWindow : Window { public SettingsWindow() { - this.Title = "Settings"; - this.MinWidth = 500; - this.MinHeight = 400; - this.Width = 400; - this.Height = 300; - var textBlock = new TextBlock + // Базовые параметры окна + this.Title = "Настройки"; + this.Width = 450; + this.Height = 250; + this.MinWidth = 450; + this.MinHeight = 250; + this.WindowStartupLocation = WindowStartupLocation.CenterOwner; + this.Padding = new Thickness(25); + + // Контейнер, который выравнивает элементы по вертикали + var mainStack = new StackPanel { - Text = "Settings window", - HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center, - VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center, - FontSize = 16 + Spacing = 15, + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Top }; - this.Content = textBlock; + // Заголовок окна + var titleText = new TextBlock + { + Text = "Настройки приложения", + FontSize = 20, + FontWeight = FontWeight.Bold, + Margin = new Thickness(0, 0, 0, 10) + }; + + // Чекбокс (Галочка) + var exitOnCloseCheckBox = new CheckBox + { + Content = "Завершение работы KeyKeeper при закрытии хранилища", + FontSize = 14, + // Подгружаем сохраненное состояние из статического класса + IsChecked = AppSettings.ExitOnRepositoryClose + }; + + // Событие: когда пользователь щелкает по галочке, данные сразу улетают в AppSettings + exitOnCloseCheckBox.IsCheckedChanged += (s, e) => + { + AppSettings.ExitOnRepositoryClose = exitOnCloseCheckBox.IsChecked ?? false; + AppSettings.Save(); + }; + + // Добавляем элементы в стек + mainStack.Children.Add(titleText); + mainStack.Children.Add(exitOnCloseCheckBox); + + // Назначаем стек основным контентом окна + this.Content = mainStack; } -} +} \ No newline at end of file From 226c0105ba39258f894c53cbc56bc4060bae143e Mon Sep 17 00:00:00 2001 From: Chernykh Aleksandr Date: Thu, 23 Apr 2026 01:22:54 +0300 Subject: [PATCH 3/6] commit --- src/KeyKeeper/Views/AppSettings.cs | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/KeyKeeper/Views/AppSettings.cs diff --git a/src/KeyKeeper/Views/AppSettings.cs b/src/KeyKeeper/Views/AppSettings.cs new file mode 100644 index 0000000..e658f18 --- /dev/null +++ b/src/KeyKeeper/Views/AppSettings.cs @@ -0,0 +1,42 @@ +using System.IO; +using System.Text.Json; + +namespace KeyKeeper; + +public static class AppSettings +{ + private static readonly string FilePath = "settings.json"; + + public static bool ExitOnRepositoryClose { get; set; } = false; + + // Сохранение в файл + public static void Save() + { + var data = new { ExitOnRepositoryClose }; + string json = JsonSerializer.Serialize(data); + File.WriteAllText(FilePath, json); + } + + // Загрузка из файла + public static void Load() + { + if (File.Exists(FilePath)) + { + try + { + string json = File.ReadAllText(FilePath); + var data = JsonSerializer.Deserialize(json); + if (data != null) + { + ExitOnRepositoryClose = data.ExitOnRepositoryClose; + } + } + catch { /* Если файл поврежден, просто используем значения по умолчанию */ } + } + } + + private class SettingsData + { + public bool ExitOnRepositoryClose { get; set; } + } +} \ No newline at end of file From fea00294295595a1405708ac8953925d0f0221ec Mon Sep 17 00:00:00 2001 From: Chernykh Aleksandr Date: Thu, 23 Apr 2026 01:22:59 +0300 Subject: [PATCH 4/6] commit --- src/KeyKeeper/Views/MainWindow.axaml.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/KeyKeeper/Views/MainWindow.axaml.cs b/src/KeyKeeper/Views/MainWindow.axaml.cs index 3e0a731..7ac09d4 100644 --- a/src/KeyKeeper/Views/MainWindow.axaml.cs +++ b/src/KeyKeeper/Views/MainWindow.axaml.cs @@ -82,9 +82,19 @@ namespace KeyKeeper.Views { WindowStartupLocation = WindowStartupLocation.CenterScreen }; - repositoryWindow.Closed += (s, e) => this.Close(); + repositoryWindow.Closed += (s, e) => + { + if (AppSettings.ExitOnRepositoryClose) + { + this.Close(); + } + else + { + this.Show(); + } + }; repositoryWindow.Show(); - this.Hide(); + this.Hide(); } } } From b4429354c3147f7bdbb80cfb49b0e9b5f30619cc Mon Sep 17 00:00:00 2001 From: Slavasil Date: Sun, 26 Apr 2026 21:40:39 +0300 Subject: [PATCH 5/6] translate settings window to English --- src/KeyKeeper/{Views => }/AppSettings.cs | 0 src/KeyKeeper/SettingsWindow.cs | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/KeyKeeper/{Views => }/AppSettings.cs (100%) diff --git a/src/KeyKeeper/Views/AppSettings.cs b/src/KeyKeeper/AppSettings.cs similarity index 100% rename from src/KeyKeeper/Views/AppSettings.cs rename to src/KeyKeeper/AppSettings.cs diff --git a/src/KeyKeeper/SettingsWindow.cs b/src/KeyKeeper/SettingsWindow.cs index bf08122..6f38710 100644 --- a/src/KeyKeeper/SettingsWindow.cs +++ b/src/KeyKeeper/SettingsWindow.cs @@ -10,7 +10,7 @@ public class SettingsWindow : Window public SettingsWindow() { // Базовые параметры окна - this.Title = "Настройки"; + this.Title = "Settings"; this.Width = 450; this.Height = 250; this.MinWidth = 450; @@ -29,7 +29,7 @@ public class SettingsWindow : Window // Заголовок окна var titleText = new TextBlock { - Text = "Настройки приложения", + Text = "App Settings", FontSize = 20, FontWeight = FontWeight.Bold, Margin = new Thickness(0, 0, 0, 10) @@ -38,7 +38,7 @@ public class SettingsWindow : Window // Чекбокс (Галочка) var exitOnCloseCheckBox = new CheckBox { - Content = "Завершение работы KeyKeeper при закрытии хранилища", + Content = "Exit KeyKeeper when closing vault", FontSize = 14, // Подгружаем сохраненное состояние из статического класса IsChecked = AppSettings.ExitOnRepositoryClose @@ -58,4 +58,4 @@ public class SettingsWindow : Window // Назначаем стек основным контентом окна this.Content = mainStack; } -} \ No newline at end of file +} From 339766bdc394363a4dd621084582fa20e84d596b Mon Sep 17 00:00:00 2001 From: Slavasil Date: Sun, 26 Apr 2026 21:41:05 +0300 Subject: [PATCH 6/6] change settings.json path to the standard one --- src/KeyKeeper/AppSettings.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/KeyKeeper/AppSettings.cs b/src/KeyKeeper/AppSettings.cs index e658f18..24af0f8 100644 --- a/src/KeyKeeper/AppSettings.cs +++ b/src/KeyKeeper/AppSettings.cs @@ -1,17 +1,22 @@ -using System.IO; +using System; +using System.IO; using System.Text.Json; namespace KeyKeeper; public static class AppSettings { - private static readonly string FilePath = "settings.json"; + private static readonly string FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "KeyKeeper", "settings.json"); public static bool ExitOnRepositoryClose { get; set; } = false; // Сохранение в файл public static void Save() { + var directory = Path.GetDirectoryName(FilePath); + if (!string.IsNullOrEmpty(directory)) + Directory.CreateDirectory(directory); + var data = new { ExitOnRepositoryClose }; string json = JsonSerializer.Serialize(data); File.WriteAllText(FilePath, json); @@ -39,4 +44,4 @@ public static class AppSettings { public bool ExitOnRepositoryClose { get; set; } } -} \ No newline at end of file +}