mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add UI for double pinyin options
This commit is contained in:
parent
ebcd7d5915
commit
130202108c
5 changed files with 97 additions and 27 deletions
|
|
@ -45,7 +45,8 @@ namespace Flow.Launcher.Infrastructure
|
|||
private void CreateDoublePinyinTableFromStream(Stream jsonStream)
|
||||
{
|
||||
Dictionary<string, Dictionary<string, string>> table = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(jsonStream);
|
||||
if (!table.TryGetValue(_settings.DoublePinyinSchema, out var value))
|
||||
string schemaKey = _settings.DoublePinyinSchema.ToString(); // Convert enum to string
|
||||
if (!table.TryGetValue(schemaKey, out var value))
|
||||
{
|
||||
throw new InvalidOperationException("DoublePinyinSchema is invalid or double pinyin table is broken.");
|
||||
}
|
||||
|
|
@ -104,18 +105,13 @@ namespace Flow.Launcher.Infrastructure
|
|||
if (content[i] >= 0x3400 && content[i] <= 0x9FD5)
|
||||
{
|
||||
string translated = _settings.UseDoublePinyin ? ToDoublePin(resultList[i]) : resultList[i];
|
||||
if (previousIsChinese)
|
||||
if (i > 0)
|
||||
{
|
||||
resultBuilder.Append(' ');
|
||||
map.AddNewIndex(resultBuilder.Length, translated.Length);
|
||||
resultBuilder.Append(translated);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.AddNewIndex(resultBuilder.Length, translated.Length);
|
||||
resultBuilder.Append(translated);
|
||||
previousIsChinese = true;
|
||||
}
|
||||
map.AddNewIndex(resultBuilder.Length, translated.Length);
|
||||
resultBuilder.Append(translated);
|
||||
previousIsChinese = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
}
|
||||
}
|
||||
public bool UseDropShadowEffect { get; set; } = true;
|
||||
public BackdropTypes BackdropType{ get; set; } = BackdropTypes.None;
|
||||
public BackdropTypes BackdropType { get; set; } = BackdropTypes.None;
|
||||
public string ReleaseNotesVersion { get; set; } = string.Empty;
|
||||
|
||||
/* Appearance Settings. It should be separated from the setting later.*/
|
||||
|
|
@ -200,7 +200,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int MaxHistoryResultsToShowForHomePage { get; set; } = 5;
|
||||
|
||||
public int CustomExplorerIndex { get; set; } = 0;
|
||||
|
|
@ -313,8 +313,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
}
|
||||
}
|
||||
|
||||
private string _doublePinyinSchema = "XiaoHe";
|
||||
public string DoublePinyinSchema
|
||||
private DoublePinyinSchemas _doublePinyinSchema = DoublePinyinSchemas.XiaoHe;
|
||||
|
||||
[JsonInclude, JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public DoublePinyinSchemas DoublePinyinSchema
|
||||
{
|
||||
get => _doublePinyinSchema;
|
||||
set
|
||||
|
|
@ -489,7 +491,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
if (!string.IsNullOrEmpty(SettingWindowHotkey))
|
||||
list.Add(new(SettingWindowHotkey, "SettingWindowHotkey", () => SettingWindowHotkey = ""));
|
||||
if (!string.IsNullOrEmpty(OpenHistoryHotkey))
|
||||
list.Add(new(OpenHistoryHotkey, "OpenHistoryHotkey", () => OpenHistoryHotkey = ""));
|
||||
list.Add(new(OpenHistoryHotkey, "OpenHistoryHotkey", () => OpenHistoryHotkey = ""));
|
||||
if (!string.IsNullOrEmpty(OpenContextMenuHotkey))
|
||||
list.Add(new(OpenContextMenuHotkey, "OpenContextMenuHotkey", () => OpenContextMenuHotkey = ""));
|
||||
if (!string.IsNullOrEmpty(SelectNextPageHotkey))
|
||||
|
|
@ -595,9 +597,22 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
|
||||
public enum BackdropTypes
|
||||
{
|
||||
None,
|
||||
None,
|
||||
Acrylic,
|
||||
Mica,
|
||||
MicaAlt
|
||||
}
|
||||
|
||||
public enum DoublePinyinSchemas
|
||||
{
|
||||
XiaoHe,
|
||||
ZiRanMa,
|
||||
WeiRuan,
|
||||
ZhiNengABC,
|
||||
ZiGuangPinYin,
|
||||
PinYinJiaJia,
|
||||
XingKongJianDao,
|
||||
DaNiu,
|
||||
XiaoLang
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,19 @@
|
|||
<system:String x:Key="SearchPrecisionRegular">Regular</system:String>
|
||||
<system:String x:Key="ShouldUsePinyin">Search with Pinyin</system:String>
|
||||
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese.</system:String>
|
||||
<system:String x:Key="ShouldUseDoublePinyin">Use Double Pinyin</system:String>
|
||||
<system:String x:Key="ShouldUseDoublePinyinToolTip">Allows using Double Pinyin to search. Double Pinyin is a variation of Pinyin that uses two characters.</system:String>
|
||||
<system:String x:Key="DoublePinyinSchema">Double Pinyin Schema</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasXiaoHe">Xiao He</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasZiRanMa">Zi Ran Ma</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasWeiRuan">Wei Ruan</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasZhiNengABC">Zhi Neng ABC</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasZiGuangPinYin">Zi Guang Pin Yin</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasPinYinJiaJia">Pin Yin Jia Jia</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasXingKongJianDao">Xing Kong Jian Dao</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasDaNiu">Da Niu</system:String>
|
||||
<system:String x:Key="DoublePinyinSchemasXiaoLang">Xiao Lang</system:String>
|
||||
|
||||
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
|
||||
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
|
||||
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
|
||||
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
|
||||
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
|
||||
public class DoublePinyinSchemaData : DropdownDataGeneric<DoublePinyinSchemas> { }
|
||||
|
||||
public bool StartFlowLauncherOnSystemStartup
|
||||
{
|
||||
|
|
@ -177,6 +178,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
|
||||
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
|
||||
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
|
||||
DropdownDataGeneric<DoublePinyinSchemas>.UpdateLabels(DoublePinyinSchemas);
|
||||
// Since we are using Binding instead of DynamicResource, we need to manually trigger the update
|
||||
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
|
||||
}
|
||||
|
|
@ -262,9 +264,25 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
public bool ShouldUsePinyin
|
||||
{
|
||||
get => Settings.ShouldUsePinyin;
|
||||
set => Settings.ShouldUsePinyin = value;
|
||||
set
|
||||
{
|
||||
if (value == false && UseDoublePinyin == true)
|
||||
{
|
||||
UseDoublePinyin = false;
|
||||
}
|
||||
Settings.ShouldUsePinyin = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseDoublePinyin
|
||||
{
|
||||
set => Settings.UseDoublePinyin = value;
|
||||
get => Settings.UseDoublePinyin;
|
||||
}
|
||||
|
||||
public List<DoublePinyinSchemaData> DoublePinyinSchemas { get; } =
|
||||
DropdownDataGeneric<DoublePinyinSchemas>.GetValues<DoublePinyinSchemaData>("DoublePinyinSchemas");
|
||||
|
||||
public List<Language> Languages => _translater.LoadAvailableLanguages();
|
||||
|
||||
public string AlwaysPreviewToolTip => string.Format(
|
||||
|
|
|
|||
|
|
@ -347,16 +347,44 @@
|
|||
OnContent="{DynamicResource enable}" />
|
||||
</cc:Card>
|
||||
|
||||
<cc:Card
|
||||
Title="{DynamicResource ShouldUsePinyin}"
|
||||
Icon=""
|
||||
Sub="{DynamicResource ShouldUsePinyinToolTip}">
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding Settings.ShouldUsePinyin}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
|
||||
</cc:Card>
|
||||
<cc:CardGroup Margin="0 4 0 0">
|
||||
<cc:Card
|
||||
Title="{DynamicResource ShouldUsePinyin}"
|
||||
Icon=""
|
||||
Sub="{DynamicResource ShouldUsePinyinToolTip}"
|
||||
Type="First">
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding ShouldUsePinyin}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
Visibility="{ext:VisibleWhen {Binding ShouldUsePinyin},
|
||||
IsEqualToBool=True}"
|
||||
Title="{DynamicResource ShouldUseDoublePinyin}"
|
||||
Icon=""
|
||||
Sub="{DynamicResource ShouldUseDoublePinyinToolTip}"
|
||||
Type="Middle">
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding UseDoublePinyin}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
ToolTip="{DynamicResource ShouldUseDoublePinyinToolTip}" />
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
Visibility="{ext:VisibleWhen {Binding UseDoublePinyin},
|
||||
IsEqualToBool=True}"
|
||||
Title="{DynamicResource DoublePinyinSchema}"
|
||||
Sub="{DynamicResource DoublePinyinSchemaToolTip}"
|
||||
Type="Last">
|
||||
<ComboBox
|
||||
DisplayMemberPath="Display"
|
||||
ItemsSource="{Binding DoublePinyinSchemas}"
|
||||
SelectedValue="{Binding Settings.DoublePinyinSchema}"
|
||||
SelectedValuePath="Value" />
|
||||
</cc:Card>
|
||||
</cc:CardGroup>
|
||||
|
||||
<cc:Card
|
||||
Title="{DynamicResource language}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue