From abcea40bdd3dbedbae664bfb5a17887a66bb4df7 Mon Sep 17 00:00:00 2001 From: rampaa Date: Mon, 4 Dec 2023 21:44:03 +0300 Subject: [PATCH] Add an option to control whether or not popups should be hidden on text change --- JL.Windows/ConfigManager.cs | 7 ++++++- JL.Windows/GUI/MainWindow.xaml.cs | 5 ++++- JL.Windows/GUI/PreferencesWindow.xaml | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/JL.Windows/ConfigManager.cs b/JL.Windows/ConfigManager.cs index 51355317..38d72c37 100644 --- a/JL.Windows/ConfigManager.cs +++ b/JL.Windows/ConfigManager.cs @@ -67,6 +67,7 @@ internal static class ConfigManager public static bool EnableBacklog { get; private set; } = true; public static bool AutoSaveBacklogBeforeClosing { get; private set; } = false; public static bool TextToSpeechOnTextChange { get; private set; } = false; + public static bool HidePopupsOnTextChange { get; private set; } = true; public static bool AlwaysShowMainTextBoxCaret { get; set; } = false; #endregion @@ -322,6 +323,8 @@ public static void ApplyPreferences() TextToSpeechOnTextChange = GetValueFromConfig(config, TextToSpeechOnTextChange, nameof(TextToSpeechOnTextChange), bool.TryParse); + HidePopupsOnTextChange = GetValueFromConfig(config, HidePopupsOnTextChange, nameof(HidePopupsOnTextChange), bool.TryParse); + HideAllTitleBarButtonsWhenMouseIsNotOverTitleBar = GetValueFromConfig(config, HideAllTitleBarButtonsWhenMouseIsNotOverTitleBar, nameof(HideAllTitleBarButtonsWhenMouseIsNotOverTitleBar), bool.TryParse); mainWindow.ChangeVisibilityOfTitleBarButtons(); @@ -855,7 +858,7 @@ public static void LoadPreferences(PreferencesWindow preferenceWindow) preferenceWindow.EnableBacklogCheckBox.IsChecked = EnableBacklog; preferenceWindow.AutoSaveBacklogBeforeClosingCheckBox.IsChecked = AutoSaveBacklogBeforeClosing; preferenceWindow.TextToSpeechOnTextChangeCheckBox.IsChecked = TextToSpeechOnTextChange; - + preferenceWindow.HidePopupsOnTextChangeCheckBox.IsChecked = HidePopupsOnTextChange; preferenceWindow.ToggleHideAllTitleBarButtonsWhenMouseIsNotOverTitleBarCheckBox.IsChecked = HideAllTitleBarButtonsWhenMouseIsNotOverTitleBar; preferenceWindow.HorizontallyCenterMainWindowTextCheckBox.IsChecked = HorizontallyCenterMainWindowText; @@ -1069,6 +1072,8 @@ public static async Task SavePreferences(PreferencesWindow preferenceWindow) preferenceWindow.AutoSaveBacklogBeforeClosingCheckBox.IsChecked.ToString(); settings[nameof(TextToSpeechOnTextChange)].Value = preferenceWindow.TextToSpeechOnTextChangeCheckBox.IsChecked.ToString(); + settings[nameof(HidePopupsOnTextChange)].Value = + preferenceWindow.HidePopupsOnTextChangeCheckBox.IsChecked.ToString(); settings[nameof(HideAllTitleBarButtonsWhenMouseIsNotOverTitleBar)].Value = preferenceWindow.ToggleHideAllTitleBarButtonsWhenMouseIsNotOverTitleBarCheckBox.IsChecked.ToString(); settings[nameof(HorizontallyCenterMainWindowText)].Value = diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index 23c8ff95..46be1471 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -184,7 +184,10 @@ private void HandlePostCopy(string text) TitleBarContextMenu.IsOpen = false; MainTextBoxContextMenu.IsOpen = false; - PopupWindowUtils.HidePopups(FirstPopupWindow); + if (ConfigManager.HidePopupsOnTextChange) + { + PopupWindowUtils.HidePopups(FirstPopupWindow); + } }, DispatcherPriority.Send); if (ConfigManager.AlwaysOnTop diff --git a/JL.Windows/GUI/PreferencesWindow.xaml b/JL.Windows/GUI/PreferencesWindow.xaml index 52a30314..04e012fd 100644 --- a/JL.Windows/GUI/PreferencesWindow.xaml +++ b/JL.Windows/GUI/PreferencesWindow.xaml @@ -396,6 +396,14 @@ HorizontalAlignment="Right" /> + + + + +