Skip to content

Commit 35ac969

Browse files
committed
Remove kanji mode
1 parent 68cdcbd commit 35ac969

8 files changed

+0
-131
lines changed

JL.Core/Config/CoreConfigManager.cs

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public sealed class CoreConfigManager
1111
public static CoreConfigManager Instance { get; private set; } = new();
1212

1313
public Uri AnkiConnectUri { get; set; } = new("http://127.0.0.1:8765");
14-
public bool KanjiMode { get; set; } // = false;
1514
public bool AnkiIntegration { get; set; } // = false;
1615
public bool ForceSyncAnki { get; private set; } // = false;
1716
public bool AllowDuplicateCards { get; private set; } // = false;
@@ -91,7 +90,6 @@ public void ApplyPreferences(SqliteConnection connection)
9190
WebSocketUtils.HandleWebSocket();
9291
}
9392

94-
KanjiMode = ConfigDBManager.GetValueFromConfig(connection, KanjiMode, nameof(KanjiMode), bool.TryParse);
9593
AnkiIntegration = ConfigDBManager.GetValueFromConfig(connection, AnkiIntegration, nameof(AnkiIntegration), bool.TryParse);
9694
ForceSyncAnki = ConfigDBManager.GetValueFromConfig(connection, ForceSyncAnki, nameof(ForceSyncAnki), bool.TryParse);
9795
AllowDuplicateCards = ConfigDBManager.GetValueFromConfig(connection, AllowDuplicateCards, nameof(AllowDuplicateCards), bool.TryParse);

JL.Core/Lookup/LookupUtils.cs

-68
Original file line numberDiff line numberDiff line change
@@ -48,74 +48,6 @@ public static class LookupUtils
4848
.ToList();
4949

5050
kanji = text.EnumerateRunes().First().ToString();
51-
if (coreConfigManager.KanjiMode)
52-
{
53-
_ = Parallel.ForEach(DictUtils.Dicts.Values.ToArray(), dict =>
54-
{
55-
bool useDB = dict.Options.UseDB.Value && dict.Ready;
56-
if (!dict.Active)
57-
{
58-
return;
59-
}
60-
61-
if (dict.Type is DictType.Kanjidic)
62-
{
63-
Dictionary<string, IntermediaryResult>? results = useDB
64-
? GetKanjiResultsFromDB(kanji, dict, KanjidicDBManager.GetRecordsFromDB)
65-
: GetKanjiResults(kanji, dict);
66-
67-
if (results?.Count > 0)
68-
{
69-
lookupResults.AddRange(BuildKanjidicResult(results, useDBForPitchDict, pitchDict, kanjiFreqs));
70-
}
71-
}
72-
73-
else if (dict.Type is DictType.NonspecificKanjiWithWordSchemaYomichan)
74-
{
75-
Dictionary<string, IntermediaryResult>? results = useDB
76-
? GetKanjiResultsFromDB(kanji, dict, EpwingYomichanDBManager.GetRecordsFromDB)
77-
: GetKanjiResults(kanji, dict);
78-
79-
if (results?.Count > 0)
80-
{
81-
lookupResults.AddRange(BuildEpwingYomichanResult(results, kanjiFreqs, dbKanjiFreqs, useDBForPitchDict, pitchDict, dict.Type));
82-
}
83-
}
84-
85-
else if (dict.Type is DictType.NonspecificKanjiYomichan)
86-
{
87-
Dictionary<string, IntermediaryResult>? results = useDB
88-
? GetKanjiResultsFromDB(kanji, dict, EpwingYomichanDBManager.GetRecordsFromDB)
89-
: GetKanjiResults(kanji, dict);
90-
91-
if (results?.Count > 0)
92-
{
93-
lookupResults.AddRange(BuildYomichanKanjiResult(results, useDBForPitchDict, pitchDict, kanjiFreqs));
94-
}
95-
}
96-
97-
else if (dict.Type is DictType.NonspecificKanjiNazeka)
98-
{
99-
Dictionary<string, IntermediaryResult>? results = useDB
100-
? GetKanjiResultsFromDB(kanji, dict, EpwingNazekaDBManager.GetRecordsFromDB)
101-
: GetKanjiResults(kanji, dict);
102-
103-
if (results?.Count > 0)
104-
{
105-
lookupResults.AddRange(BuildEpwingNazekaResult(results, kanjiFreqs, dbKanjiFreqs, useDBForPitchDict, pitchDict, dict.Type));
106-
}
107-
}
108-
});
109-
110-
return lookupResults.IsEmpty
111-
? null
112-
: SortLookupResults(lookupResults);
113-
}
114-
}
115-
116-
else if (coreConfigManager.KanjiMode)
117-
{
118-
return null;
11951
}
12052

12153
List<Freq> wordFreqs = FreqUtils.FreqDicts.Values

JL.Windows/ConfigManager.cs

-8
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ internal sealed class ConfigManager
140140
public KeyGesture DisableHotkeysKeyGesture { get; private set; } = new(Key.Pause, ModifierKeys.Alt);
141141
public KeyGesture MiningModeKeyGesture { get; private set; } = new(Key.M, ModifierKeys.Alt);
142142
public KeyGesture PlayAudioKeyGesture { get; private set; } = new(Key.P, ModifierKeys.Alt);
143-
public KeyGesture KanjiModeKeyGesture { get; private set; } = new(Key.K, ModifierKeys.Alt);
144143
public KeyGesture ShowManageDictionariesWindowKeyGesture { get; private set; } = new(Key.D, ModifierKeys.Alt);
145144
public KeyGesture ShowManageFrequenciesWindowKeyGesture { get; private set; } = new(Key.F, ModifierKeys.Alt);
146145
public KeyGesture ShowPreferencesWindowKeyGesture { get; private set; } = new(Key.L, ModifierKeys.Alt);
@@ -511,7 +510,6 @@ public void ApplyPreferences(SqliteConnection connection)
511510
DisableHotkeysKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(DisableHotkeysKeyGesture), DisableHotkeysKeyGesture);
512511
MiningModeKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(MiningModeKeyGesture), MiningModeKeyGesture);
513512
PlayAudioKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(PlayAudioKeyGesture), PlayAudioKeyGesture);
514-
KanjiModeKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(KanjiModeKeyGesture), KanjiModeKeyGesture);
515513
LookupKeyKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(LookupKeyKeyGesture), LookupKeyKeyGesture);
516514
ClosePopupKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(ClosePopupKeyGesture), ClosePopupKeyGesture);
517515
ShowStatsKeyGesture = KeyGestureUtils.GetKeyGestureFromConfig(connection, nameof(ShowStatsKeyGesture), ShowStatsKeyGesture);
@@ -736,7 +734,6 @@ public void LoadPreferenceWindow(PreferencesWindow preferenceWindow)
736734
preferenceWindow.DisableHotkeysKeyGestureTextBox.Text = DisableHotkeysKeyGesture.ToFormattedString();
737735
preferenceWindow.MiningModeKeyGestureTextBox.Text = MiningModeKeyGesture.ToFormattedString();
738736
preferenceWindow.PlayAudioKeyGestureTextBox.Text = PlayAudioKeyGesture.ToFormattedString();
739-
preferenceWindow.KanjiModeKeyGestureTextBox.Text = KanjiModeKeyGesture.ToFormattedString();
740737
preferenceWindow.LookupKeyKeyGestureTextBox.Text = LookupKeyKeyGesture.ToFormattedString();
741738

742739
preferenceWindow.ShowManageDictionariesWindowKeyGestureTextBox.Text =
@@ -837,7 +834,6 @@ public void LoadPreferenceWindow(PreferencesWindow preferenceWindow)
837834
preferenceWindow.ForceSyncAnkiCheckBox.IsChecked = coreConfigManager.ForceSyncAnki;
838835
preferenceWindow.AllowDuplicateCardsCheckBox.IsChecked = coreConfigManager.AllowDuplicateCards;
839836
preferenceWindow.CheckForDuplicateCardsCheckBox.IsChecked = coreConfigManager.CheckForDuplicateCards;
840-
preferenceWindow.KanjiModeCheckBox.IsChecked = coreConfigManager.KanjiMode;
841837
preferenceWindow.AutoAdjustFontSizesOnResolutionChangeCheckBox.IsChecked = AutoAdjustFontSizesOnResolutionChange;
842838
preferenceWindow.HighlightLongestMatchCheckBox.IsChecked = HighlightLongestMatch;
843839
preferenceWindow.AutoPlayAudioCheckBox.IsChecked = AutoPlayAudio;
@@ -988,7 +984,6 @@ public async Task SavePreferences(PreferencesWindow preferenceWindow)
988984
KeyGestureUtils.UpdateKeyGesture(connection, nameof(DisableHotkeysKeyGesture), preferenceWindow.DisableHotkeysKeyGestureTextBox.Text);
989985
KeyGestureUtils.UpdateKeyGesture(connection, nameof(MiningModeKeyGesture), preferenceWindow.MiningModeKeyGestureTextBox.Text);
990986
KeyGestureUtils.UpdateKeyGesture(connection, nameof(PlayAudioKeyGesture), preferenceWindow.PlayAudioKeyGestureTextBox.Text);
991-
KeyGestureUtils.UpdateKeyGesture(connection, nameof(KanjiModeKeyGesture), preferenceWindow.KanjiModeKeyGestureTextBox.Text);
992987
KeyGestureUtils.UpdateKeyGesture(connection, nameof(LookupKeyKeyGesture), preferenceWindow.LookupKeyKeyGestureTextBox.Text);
993988

994989
KeyGestureUtils.UpdateKeyGesture(connection, nameof(ShowManageDictionariesWindowKeyGesture),
@@ -1195,9 +1190,6 @@ public async Task SavePreferences(PreferencesWindow preferenceWindow)
11951190

11961191
ConfigDBManager.UpdateSetting(connection, nameof(PopupFont), preferenceWindow.PopupFontComboBox.SelectedValue.ToString()!);
11971192

1198-
ConfigDBManager.UpdateSetting(connection, nameof(CoreConfigManager.KanjiMode),
1199-
preferenceWindow.KanjiModeCheckBox.IsChecked.ToString()!);
1200-
12011193
ConfigDBManager.UpdateSetting(connection, nameof(CoreConfigManager.ForceSyncAnki),
12021194
preferenceWindow.ForceSyncAnkiCheckBox.IsChecked.ToString()!);
12031195

JL.Windows/GUI/MainWindow.xaml.cs

-9
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,6 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e)
558558
}
559559
}
560560

561-
else if (keyGesture.IsEqual(configManager.KanjiModeKeyGesture))
562-
{
563-
handled = true;
564-
565-
coreConfigManager.KanjiMode = !coreConfigManager.KanjiMode;
566-
FirstPopupWindow.LastText = "";
567-
MainTextBox_MouseMove(null, null);
568-
}
569-
570561
else if (keyGesture.IsEqual(configManager.ShowAddNameWindowKeyGesture))
571562
{
572563
handled = true;

JL.Windows/GUI/PopupWindow.xaml.cs

-19
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,6 @@ private void SelectPreviousLookupResult()
13341334
public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e)
13351335
{
13361336
ConfigManager configManager = ConfigManager.Instance;
1337-
CoreConfigManager coreConfigManager = CoreConfigManager.Instance;
13381337
MainWindow mainWindow = MainWindow.Instance;
13391338
bool handled = false;
13401339
if (keyGesture.IsEqual(configManager.DisableHotkeysKeyGesture))
@@ -1405,24 +1404,6 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e)
14051404
HidePopup();
14061405
}
14071406

1408-
else if (keyGesture.IsEqual(configManager.KanjiModeKeyGesture))
1409-
{
1410-
handled = true;
1411-
1412-
coreConfigManager.KanjiMode = !coreConfigManager.KanjiMode;
1413-
LastText = "";
1414-
1415-
if (this != mainWindow.FirstPopupWindow)
1416-
{
1417-
await HandleTextBoxMouseMove(_previousTextBox!, null).ConfigureAwait(false);
1418-
}
1419-
1420-
else
1421-
{
1422-
await mainWindow.HandleMouseMove(null).ConfigureAwait(false);
1423-
}
1424-
}
1425-
14261407
else if (keyGesture.IsEqual(configManager.ShowAddNameWindowKeyGesture))
14271408
{
14281409
handled = true;

JL.Windows/GUI/PreferencesWindow.xaml

-18
Original file line numberDiff line numberDiff line change
@@ -1342,17 +1342,6 @@
13421342
VerticalAlignment="Center" />
13431343
</DockPanel>
13441344

1345-
<DockPanel>
1346-
<Button Content="Clear" Width="Auto" DockPanel.Dock="Right" FontSize="9" Height="24"
1347-
Click="ClearKeyGestureButton_Click" />
1348-
<TextBox x:Name="KanjiModeKeyGestureTextBox"
1349-
PreviewKeyDown="KeyGestureToText" CaretBrush="#00000000" Width="250"
1350-
HorizontalAlignment="Right" DockPanel.Dock="Right" Margin="0,0,5,0" />
1351-
<TextBlock Text="Toggle kanji mode" TextWrapping="Wrap" HorizontalAlignment="Left"
1352-
Style="{StaticResource TextBlockDefault}"
1353-
VerticalAlignment="Center" />
1354-
</DockPanel>
1355-
13561345
<DockPanel>
13571346
<Button Content="Clear" Width="Auto" DockPanel.Dock="Right" FontSize="9" Height="24"
13581347
Click="ClearKeyGestureButton_Click" />
@@ -1676,13 +1665,6 @@
16761665
HorizontalAlignment="Right" />
16771666
</DockPanel>
16781667

1679-
<DockPanel>
1680-
<TextBlock HorizontalAlignment="Left" Text="Kanji mode"
1681-
Style="{StaticResource TextBlockDefault}"
1682-
TextWrapping="Wrap" VerticalAlignment="Center" />
1683-
<CheckBox x:Name="KanjiModeCheckBox" HorizontalAlignment="Right" />
1684-
</DockPanel>
1685-
16861668
<DockPanel>
16871669
<TextBlock HorizontalAlignment="Left" Text="Disable hotkeys"
16881670
Style="{StaticResource TextBlockDefault}"

JL.Windows/Utilities/KeyGestureUtils.cs

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ internal static class KeyGestureUtils
5454
nameof(ConfigManager.CaptureTextFromClipboardKeyGesture),
5555
nameof(ConfigManager.CaptureTextFromWebSocketKeyGesture),
5656
nameof(ConfigManager.ReconnectToWebSocketServerKeyGesture),
57-
nameof(ConfigManager.KanjiModeKeyGesture),
5857
nameof(ConfigManager.ShowAddNameWindowKeyGesture),
5958
nameof(ConfigManager.ShowAddWordWindowKeyGesture)
6059
];

JL.Windows/Utilities/PopupWindowUtils.cs

-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Windows.Media;
66
using System.Windows.Shapes;
77
using JL.Core.Audio;
8-
using JL.Core.Config;
98
using JL.Core.Dicts;
109
using JL.Core.Dicts.PitchAccent;
1110
using JL.Core.Utilities;
@@ -279,11 +278,6 @@ public static int GetIndexOfListViewItemFromStackPanel(StackPanel stackPanel)
279278

280279
public static bool NoAllDictFilter(object item)
281280
{
282-
if (CoreConfigManager.Instance.KanjiMode)
283-
{
284-
return true;
285-
}
286-
287281
Dict dict = (Dict)((StackPanel)item).Tag;
288282
return !dict.Options.NoAll.Value;
289283
}

0 commit comments

Comments
 (0)