Skip to content

Commit

Permalink
Add an option to control whether or not popups should be hidden on te…
Browse files Browse the repository at this point in the history
…xt change
  • Loading branch information
rampaa committed Dec 4, 2023
1 parent 05b16ef commit abcea40
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion JL.Windows/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 =
Expand Down
5 changes: 4 additions & 1 deletion JL.Windows/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions JL.Windows/GUI/PreferencesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@
HorizontalAlignment="Right" />
</DockPanel>

<DockPanel>
<TextBlock HorizontalAlignment="Left" Text="Hide popups on text change"
Style="{StaticResource TextBlockDefault}"
TextWrapping="Wrap" VerticalAlignment="Center" />
<CheckBox x:Name="HidePopupsOnTextChangeCheckBox"
HorizontalAlignment="Right" />
</DockPanel>

<DockPanel>
<TextBlock HorizontalAlignment="Left" Text="Read only"
Style="{StaticResource TextBlockDefault}"
Expand Down

0 comments on commit abcea40

Please sign in to comment.