@@ -55,7 +55,7 @@ const adding = ref(false)
55
55
56
56
const selectedLanguage = ref <string | null >(null )
57
57
58
- const availableInputMethodOptions = ref <{
58
+ const languageOptions = ref <{
59
59
label: string
60
60
key: string
61
61
}[]>([])
@@ -77,7 +77,7 @@ watchEffect(() => {
77
77
displayName: im .displayName ,
78
78
})
79
79
}
80
- availableInputMethodOptions .value = []
80
+ languageOptions .value = []
81
81
const sortedLanguageCodes = Object .keys (map ).sort ((a : string , b : string ) => {
82
82
if (! a ) {
83
83
return 1
@@ -96,15 +96,15 @@ watchEffect(() => {
96
96
return la .localeCompare (lb )
97
97
})
98
98
for (const languageCode of sortedLanguageCodes ) {
99
- availableInputMethodOptions .value .push ({
100
- label: languageCode ? (languageName .of (languageCode ) ?? languageCode ) : languageCode ,
99
+ languageOptions .value .push ({
100
+ label: languageCode ? (languageName .of (languageCode ) ?? languageCode ) : ' Unknown ' ,
101
101
key: languageCode ,
102
102
})
103
103
}
104
104
})
105
105
106
106
const inputMethodsForLanguage = computed (() => {
107
- if (! selectedLanguage .value ) {
107
+ if (selectedLanguage .value === null ) {
108
108
return []
109
109
}
110
110
const enabledIMs = props .inputMethods .map (({ name }) => name )
@@ -118,6 +118,16 @@ function add() {
118
118
window .fcitx .updateStatusArea ()
119
119
imsToAdd .value = []
120
120
}
121
+
122
+ const onlyShowCurrentLanguage = ref (false )
123
+
124
+ const filteredLanguageOptions = computed (() => {
125
+ if (onlyShowCurrentLanguage .value ) {
126
+ const currentLanguage = navigator .language .split (' -' )[0 ]
127
+ return languageOptions .value .filter (({ key }) => key .split (' -' )[0 ] === currentLanguage )
128
+ }
129
+ return languageOptions .value
130
+ })
121
131
</script >
122
132
123
133
<template >
@@ -131,12 +141,22 @@ function add() {
131
141
@collapse =" collapsed = true"
132
142
@expand =" collapsed = false"
133
143
>
134
- <div v-if =" adding" >
135
- <NMenu
136
- v-model:value =" selectedLanguage"
137
- :options =" availableInputMethodOptions"
138
- />
139
- </div >
144
+ <NLayout v-if =" adding" style =" height : 100% " >
145
+ <NLayout position =" absolute" style =" bottom : 50px " >
146
+ <NMenu
147
+ v-model:value =" selectedLanguage"
148
+ :options =" filteredLanguageOptions"
149
+ />
150
+ </NLayout >
151
+ <NLayoutFooter position =" absolute" >
152
+ <NCheckbox
153
+ v-model:checked =" onlyShowCurrentLanguage"
154
+ style =" height : 50px ; display : flex ; justify-content : center ; align-items : center "
155
+ >
156
+ Only show current language
157
+ </NCheckbox >
158
+ </NLayoutFooter >
159
+ </NLayout >
140
160
<div
141
161
v-else
142
162
style =" display : flex ; flex-direction : column ; justify-content : space-between ; height : 100% "
@@ -156,7 +176,13 @@ function add() {
156
176
</NLayoutSider >
157
177
<NLayout style =" min-height : 480px ; max-height : calc (100vh - 100px )" >
158
178
<template v-if =" adding " >
159
- <NLayout position =" absolute" style =" bottom : 50px ; padding : 16px 0 16px 16px " >
179
+ <div
180
+ v-if =" selectedLanguage === null"
181
+ style =" display : flex ; justify-content : center ; align-items : center ; height : calc (100% - 50px );"
182
+ >
183
+ Select a language from the left list
184
+ </div >
185
+ <NLayout v-else position =" absolute" style =" bottom : 50px ; padding : 16px 0 16px 16px " >
160
186
<NCheckboxGroup v-model:value =" imsToAdd" >
161
187
<NFlex vertical >
162
188
<NCheckbox
0 commit comments