Skip to content

Commit

Permalink
Remove kanji mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Dec 14, 2024
1 parent 68cdcbd commit 35ac969
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 131 deletions.
2 changes: 0 additions & 2 deletions JL.Core/Config/CoreConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
68 changes: 0 additions & 68 deletions JL.Core/Lookup/LookupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, IntermediaryResult>? 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<string, IntermediaryResult>? 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<string, IntermediaryResult>? 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<string, IntermediaryResult>? 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<Freq> wordFreqs = FreqUtils.FreqDicts.Values
Expand Down
8 changes: 0 additions & 8 deletions JL.Windows/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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()!);

Expand Down
9 changes: 0 additions & 9 deletions JL.Windows/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 0 additions & 19 deletions JL.Windows/GUI/PopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 0 additions & 18 deletions JL.Windows/GUI/PreferencesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1342,17 +1342,6 @@
VerticalAlignment="Center" />
</DockPanel>

<DockPanel>
<Button Content="Clear" Width="Auto" DockPanel.Dock="Right" FontSize="9" Height="24"
Click="ClearKeyGestureButton_Click" />
<TextBox x:Name="KanjiModeKeyGestureTextBox"
PreviewKeyDown="KeyGestureToText" CaretBrush="#00000000" Width="250"
HorizontalAlignment="Right" DockPanel.Dock="Right" Margin="0,0,5,0" />
<TextBlock Text="Toggle kanji mode" TextWrapping="Wrap" HorizontalAlignment="Left"
Style="{StaticResource TextBlockDefault}"
VerticalAlignment="Center" />
</DockPanel>

<DockPanel>
<Button Content="Clear" Width="Auto" DockPanel.Dock="Right" FontSize="9" Height="24"
Click="ClearKeyGestureButton_Click" />
Expand Down Expand Up @@ -1676,13 +1665,6 @@
HorizontalAlignment="Right" />
</DockPanel>

<DockPanel>
<TextBlock HorizontalAlignment="Left" Text="Kanji mode"
Style="{StaticResource TextBlockDefault}"
TextWrapping="Wrap" VerticalAlignment="Center" />
<CheckBox x:Name="KanjiModeCheckBox" HorizontalAlignment="Right" />
</DockPanel>

<DockPanel>
<TextBlock HorizontalAlignment="Left" Text="Disable hotkeys"
Style="{StaticResource TextBlockDefault}"
Expand Down
1 change: 0 additions & 1 deletion JL.Windows/Utilities/KeyGestureUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ internal static class KeyGestureUtils
nameof(ConfigManager.CaptureTextFromClipboardKeyGesture),
nameof(ConfigManager.CaptureTextFromWebSocketKeyGesture),
nameof(ConfigManager.ReconnectToWebSocketServerKeyGesture),
nameof(ConfigManager.KanjiModeKeyGesture),
nameof(ConfigManager.ShowAddNameWindowKeyGesture),
nameof(ConfigManager.ShowAddWordWindowKeyGesture)
];
Expand Down
6 changes: 0 additions & 6 deletions JL.Windows/Utilities/PopupWindowUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Windows.Media;
using System.Windows.Shapes;
using JL.Core.Audio;
using JL.Core.Config;
using JL.Core.Dicts;
using JL.Core.Dicts.PitchAccent;
using JL.Core.Utilities;
Expand Down Expand Up @@ -279,11 +278,6 @@ public static int GetIndexOfListViewItemFromStackPanel(StackPanel stackPanel)

public static bool NoAllDictFilter(object item)
{
if (CoreConfigManager.Instance.KanjiMode)
{
return true;
}

Dict dict = (Dict)((StackPanel)item).Tag;
return !dict.Options.NoAll.Value;
}
Expand Down

0 comments on commit 35ac969

Please sign in to comment.