From 35ac969790d0a52a57fe005de62240d49fbde7f7 Mon Sep 17 00:00:00 2001 From: rampaa Date: Sat, 14 Dec 2024 19:40:05 +0300 Subject: [PATCH] Remove kanji mode --- JL.Core/Config/CoreConfigManager.cs | 2 - JL.Core/Lookup/LookupUtils.cs | 68 ------------------------ JL.Windows/ConfigManager.cs | 8 --- JL.Windows/GUI/MainWindow.xaml.cs | 9 ---- JL.Windows/GUI/PopupWindow.xaml.cs | 19 ------- JL.Windows/GUI/PreferencesWindow.xaml | 18 ------- JL.Windows/Utilities/KeyGestureUtils.cs | 1 - JL.Windows/Utilities/PopupWindowUtils.cs | 6 --- 8 files changed, 131 deletions(-) diff --git a/JL.Core/Config/CoreConfigManager.cs b/JL.Core/Config/CoreConfigManager.cs index cd6e029a..4c4e5e4c 100644 --- a/JL.Core/Config/CoreConfigManager.cs +++ b/JL.Core/Config/CoreConfigManager.cs @@ -11,7 +11,6 @@ public sealed class CoreConfigManager public static CoreConfigManager Instance { get; private set; } = new(); public Uri AnkiConnectUri { get; set; } = new("http://127.0.0.1:8765"); - public bool KanjiMode { get; set; } // = false; public bool AnkiIntegration { get; set; } // = false; public bool ForceSyncAnki { get; private set; } // = false; public bool AllowDuplicateCards { get; private set; } // = false; @@ -91,7 +90,6 @@ public void ApplyPreferences(SqliteConnection connection) WebSocketUtils.HandleWebSocket(); } - KanjiMode = ConfigDBManager.GetValueFromConfig(connection, KanjiMode, nameof(KanjiMode), bool.TryParse); AnkiIntegration = ConfigDBManager.GetValueFromConfig(connection, AnkiIntegration, nameof(AnkiIntegration), bool.TryParse); ForceSyncAnki = ConfigDBManager.GetValueFromConfig(connection, ForceSyncAnki, nameof(ForceSyncAnki), bool.TryParse); AllowDuplicateCards = ConfigDBManager.GetValueFromConfig(connection, AllowDuplicateCards, nameof(AllowDuplicateCards), bool.TryParse); diff --git a/JL.Core/Lookup/LookupUtils.cs b/JL.Core/Lookup/LookupUtils.cs index fadde9df..0e0242bf 100644 --- a/JL.Core/Lookup/LookupUtils.cs +++ b/JL.Core/Lookup/LookupUtils.cs @@ -48,74 +48,6 @@ public static class LookupUtils .ToList(); kanji = text.EnumerateRunes().First().ToString(); - if (coreConfigManager.KanjiMode) - { - _ = Parallel.ForEach(DictUtils.Dicts.Values.ToArray(), dict => - { - bool useDB = dict.Options.UseDB.Value && dict.Ready; - if (!dict.Active) - { - return; - } - - if (dict.Type is DictType.Kanjidic) - { - Dictionary? results = useDB - ? GetKanjiResultsFromDB(kanji, dict, KanjidicDBManager.GetRecordsFromDB) - : GetKanjiResults(kanji, dict); - - if (results?.Count > 0) - { - lookupResults.AddRange(BuildKanjidicResult(results, useDBForPitchDict, pitchDict, kanjiFreqs)); - } - } - - else if (dict.Type is DictType.NonspecificKanjiWithWordSchemaYomichan) - { - Dictionary? results = useDB - ? GetKanjiResultsFromDB(kanji, dict, EpwingYomichanDBManager.GetRecordsFromDB) - : GetKanjiResults(kanji, dict); - - if (results?.Count > 0) - { - lookupResults.AddRange(BuildEpwingYomichanResult(results, kanjiFreqs, dbKanjiFreqs, useDBForPitchDict, pitchDict, dict.Type)); - } - } - - else if (dict.Type is DictType.NonspecificKanjiYomichan) - { - Dictionary? results = useDB - ? GetKanjiResultsFromDB(kanji, dict, EpwingYomichanDBManager.GetRecordsFromDB) - : GetKanjiResults(kanji, dict); - - if (results?.Count > 0) - { - lookupResults.AddRange(BuildYomichanKanjiResult(results, useDBForPitchDict, pitchDict, kanjiFreqs)); - } - } - - else if (dict.Type is DictType.NonspecificKanjiNazeka) - { - Dictionary? results = useDB - ? GetKanjiResultsFromDB(kanji, dict, EpwingNazekaDBManager.GetRecordsFromDB) - : GetKanjiResults(kanji, dict); - - if (results?.Count > 0) - { - lookupResults.AddRange(BuildEpwingNazekaResult(results, kanjiFreqs, dbKanjiFreqs, useDBForPitchDict, pitchDict, dict.Type)); - } - } - }); - - return lookupResults.IsEmpty - ? null - : SortLookupResults(lookupResults); - } - } - - else if (coreConfigManager.KanjiMode) - { - return null; } List wordFreqs = FreqUtils.FreqDicts.Values diff --git a/JL.Windows/ConfigManager.cs b/JL.Windows/ConfigManager.cs index 05a315c5..d2d70790 100644 --- a/JL.Windows/ConfigManager.cs +++ b/JL.Windows/ConfigManager.cs @@ -140,7 +140,6 @@ internal sealed class ConfigManager public KeyGesture DisableHotkeysKeyGesture { get; private set; } = new(Key.Pause, ModifierKeys.Alt); public KeyGesture MiningModeKeyGesture { get; private set; } = new(Key.M, ModifierKeys.Alt); public KeyGesture PlayAudioKeyGesture { get; private set; } = new(Key.P, ModifierKeys.Alt); - public KeyGesture KanjiModeKeyGesture { get; private set; } = new(Key.K, ModifierKeys.Alt); public KeyGesture ShowManageDictionariesWindowKeyGesture { get; private set; } = new(Key.D, ModifierKeys.Alt); public KeyGesture ShowManageFrequenciesWindowKeyGesture { get; private set; } = new(Key.F, ModifierKeys.Alt); public KeyGesture ShowPreferencesWindowKeyGesture { get; private set; } = new(Key.L, ModifierKeys.Alt); @@ -511,7 +510,6 @@ public void ApplyPreferences(SqliteConnection connection) DisableHotkeysKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(DisableHotkeysKeyGesture), DisableHotkeysKeyGesture); MiningModeKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(MiningModeKeyGesture), MiningModeKeyGesture); PlayAudioKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(PlayAudioKeyGesture), PlayAudioKeyGesture); - KanjiModeKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(KanjiModeKeyGesture), KanjiModeKeyGesture); LookupKeyKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(LookupKeyKeyGesture), LookupKeyKeyGesture); ClosePopupKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(ClosePopupKeyGesture), ClosePopupKeyGesture); ShowStatsKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(ShowStatsKeyGesture), ShowStatsKeyGesture); @@ -736,7 +734,6 @@ public void LoadPreferenceWindow(PreferencesWindow preferenceWindow) preferenceWindow.DisableHotkeysKeyGestureTextBox.Text = DisableHotkeysKeyGesture.ToFormattedString(); preferenceWindow.MiningModeKeyGestureTextBox.Text = MiningModeKeyGesture.ToFormattedString(); preferenceWindow.PlayAudioKeyGestureTextBox.Text = PlayAudioKeyGesture.ToFormattedString(); - preferenceWindow.KanjiModeKeyGestureTextBox.Text = KanjiModeKeyGesture.ToFormattedString(); preferenceWindow.LookupKeyKeyGestureTextBox.Text = LookupKeyKeyGesture.ToFormattedString(); preferenceWindow.ShowManageDictionariesWindowKeyGestureTextBox.Text = @@ -837,7 +834,6 @@ public void LoadPreferenceWindow(PreferencesWindow preferenceWindow) preferenceWindow.ForceSyncAnkiCheckBox.IsChecked = coreConfigManager.ForceSyncAnki; preferenceWindow.AllowDuplicateCardsCheckBox.IsChecked = coreConfigManager.AllowDuplicateCards; preferenceWindow.CheckForDuplicateCardsCheckBox.IsChecked = coreConfigManager.CheckForDuplicateCards; - preferenceWindow.KanjiModeCheckBox.IsChecked = coreConfigManager.KanjiMode; preferenceWindow.AutoAdjustFontSizesOnResolutionChangeCheckBox.IsChecked = AutoAdjustFontSizesOnResolutionChange; preferenceWindow.HighlightLongestMatchCheckBox.IsChecked = HighlightLongestMatch; preferenceWindow.AutoPlayAudioCheckBox.IsChecked = AutoPlayAudio; @@ -988,7 +984,6 @@ public async Task SavePreferences(PreferencesWindow preferenceWindow) KeyGestureUtils.UpdateKeyGesture(connection, nameof(DisableHotkeysKeyGesture), preferenceWindow.DisableHotkeysKeyGestureTextBox.Text); KeyGestureUtils.UpdateKeyGesture(connection, nameof(MiningModeKeyGesture), preferenceWindow.MiningModeKeyGestureTextBox.Text); KeyGestureUtils.UpdateKeyGesture(connection, nameof(PlayAudioKeyGesture), preferenceWindow.PlayAudioKeyGestureTextBox.Text); - KeyGestureUtils.UpdateKeyGesture(connection, nameof(KanjiModeKeyGesture), preferenceWindow.KanjiModeKeyGestureTextBox.Text); KeyGestureUtils.UpdateKeyGesture(connection, nameof(LookupKeyKeyGesture), preferenceWindow.LookupKeyKeyGestureTextBox.Text); KeyGestureUtils.UpdateKeyGesture(connection, nameof(ShowManageDictionariesWindowKeyGesture), @@ -1195,9 +1190,6 @@ public async Task SavePreferences(PreferencesWindow preferenceWindow) ConfigDBManager.UpdateSetting(connection, nameof(PopupFont), preferenceWindow.PopupFontComboBox.SelectedValue.ToString()!); - ConfigDBManager.UpdateSetting(connection, nameof(CoreConfigManager.KanjiMode), - preferenceWindow.KanjiModeCheckBox.IsChecked.ToString()!); - ConfigDBManager.UpdateSetting(connection, nameof(CoreConfigManager.ForceSyncAnki), preferenceWindow.ForceSyncAnkiCheckBox.IsChecked.ToString()!); diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index 3dbe8559..b0e62fcb 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -558,15 +558,6 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e) } } - else if (keyGesture.IsEqual(configManager.KanjiModeKeyGesture)) - { - handled = true; - - coreConfigManager.KanjiMode = !coreConfigManager.KanjiMode; - FirstPopupWindow.LastText = ""; - MainTextBox_MouseMove(null, null); - } - else if (keyGesture.IsEqual(configManager.ShowAddNameWindowKeyGesture)) { handled = true; diff --git a/JL.Windows/GUI/PopupWindow.xaml.cs b/JL.Windows/GUI/PopupWindow.xaml.cs index aa8b787c..088f23ee 100644 --- a/JL.Windows/GUI/PopupWindow.xaml.cs +++ b/JL.Windows/GUI/PopupWindow.xaml.cs @@ -1334,7 +1334,6 @@ private void SelectPreviousLookupResult() public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e) { ConfigManager configManager = ConfigManager.Instance; - CoreConfigManager coreConfigManager = CoreConfigManager.Instance; MainWindow mainWindow = MainWindow.Instance; bool handled = false; if (keyGesture.IsEqual(configManager.DisableHotkeysKeyGesture)) @@ -1405,24 +1404,6 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e) HidePopup(); } - else if (keyGesture.IsEqual(configManager.KanjiModeKeyGesture)) - { - handled = true; - - coreConfigManager.KanjiMode = !coreConfigManager.KanjiMode; - LastText = ""; - - if (this != mainWindow.FirstPopupWindow) - { - await HandleTextBoxMouseMove(_previousTextBox!, null).ConfigureAwait(false); - } - - else - { - await mainWindow.HandleMouseMove(null).ConfigureAwait(false); - } - } - else if (keyGesture.IsEqual(configManager.ShowAddNameWindowKeyGesture)) { handled = true; diff --git a/JL.Windows/GUI/PreferencesWindow.xaml b/JL.Windows/GUI/PreferencesWindow.xaml index aba35d74..ef2556ec 100644 --- a/JL.Windows/GUI/PreferencesWindow.xaml +++ b/JL.Windows/GUI/PreferencesWindow.xaml @@ -1342,17 +1342,6 @@ VerticalAlignment="Center" /> - -