Configuration items cannot be found by using Pinyin and initials when the system language is English.

This commit is contained in:
kirito 2021-09-29 11:38:54 +08:00
parent 1931b8327f
commit ac5a339307
1 changed files with 71 additions and 30 deletions

View File

@ -121,38 +121,36 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueue<Resu
searchResult->enqueue(resultInfo); searchResult->enqueue(resultInfo);
continue; continue;
} }
if (ql.language() == QLocale::Chinese) { pinyinlist = FileUtils::findMultiToneWords(str);
pinyinlist = FileUtils::findMultiToneWords(str); for (int i = 0; i < pinyinlist.size() / 2; i++) {
for (int i = 0; i < pinyinlist.size() / 2; i++) { str = regmatch.at(t);
str = regmatch.at(t); QString shouzimu = pinyinlist.at(2 * i + 1); // 中文转首字母
QString shouzimu = pinyinlist.at(2 * i + 1); // 中文转首字母 if (shouzimu.contains(keyword, Qt::CaseInsensitive)) {
if (shouzimu.contains(keyword, Qt::CaseInsensitive)) { resultInfo.name = ql.language() == QLocale::Chinese ? str : m_englishSearchList[key].at(t);
resultInfo.name = str; if (resultName.contains(resultInfo.name)) {
if (resultName.contains(resultInfo.name)) { continue;
continue;
}
resultName.append(resultInfo.name);
str = key + "/" + str;
resultInfo.icon = FileUtils::getSettingIcon(str, true);
resultInfo.actionKey = str;
searchResult->enqueue(resultInfo);
break;
} }
if (keyword.size() < 2) resultName.append(resultInfo.name);
break; str = key + "/" + str;
QString pinyin = pinyinlist.at(2 * i); // 中文转拼音 resultInfo.icon = FileUtils::getSettingIcon(str, true);
if (pinyin.contains(keyword, Qt::CaseInsensitive)) { resultInfo.actionKey = str;
resultInfo.name = str; searchResult->enqueue(resultInfo);
if (resultName.contains(resultInfo.name)) { break;
continue; }
} if (keyword.size() < 2)
resultName.append(resultInfo.name); break;
str = key + "/" + str; QString pinyin = pinyinlist.at(2 * i); // 中文转拼音
resultInfo.icon = FileUtils::getSettingIcon(str, true); if (pinyin.contains(keyword, Qt::CaseInsensitive)) {
resultInfo.actionKey = str; resultInfo.name = ql.language() == QLocale::Chinese ? str : m_englishSearchList[key].at(t);
searchResult->enqueue(resultInfo); if (resultName.contains(resultInfo.name)) {
break; continue;
} }
resultName.append(resultInfo.name);
str = key + "/" + str;
resultInfo.icon = FileUtils::getSettingIcon(str, true);
resultInfo.actionKey = str;
searchResult->enqueue(resultInfo);
break;
} }
} }
} }
@ -181,6 +179,49 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueue<Resu
for (auto t = regmatch.begin(); t != regmatch.end(); ++t) { for (auto t = regmatch.begin(); t != regmatch.end(); ++t) {
QString englishStr = t.value(); QString englishStr = t.value();
QString chineseStr = t.key(); QString chineseStr = t.key();
QStringList pinyinlist = FileUtils::findMultiToneWords(chineseStr);
for (int i = 0; i < pinyinlist.size() / 2; i++) {
QString shouzimu = pinyinlist.at(2 * i + 1); // 中文转首字母
if (shouzimu.contains(keyword, Qt::CaseInsensitive)) {
resultInfo.name = ql.language() == QLocale::Chinese ? chineseStr : englishStr;
if (resultName.contains(resultInfo.name)) {
continue;
}
resultName.append(resultInfo.name);
if(ql.language() == QLocale::English) {
englishStr = key + "/" + englishStr;
resultInfo.icon = FileUtils::getSettingIcon(englishStr, true);
resultInfo.actionKey = englishStr;
} else if (ql.language() == QLocale::Chinese) {
chineseStr = key + "/" + chineseStr;
resultInfo.icon = FileUtils::getSettingIcon(chineseStr, true);
resultInfo.actionKey = chineseStr;
}
searchResult->enqueue(resultInfo);
break;
}
if (keyword.size() < 2)
break;
QString pinyin = pinyinlist.at(2 * i); // 中文转拼音
if (pinyin.contains(keyword, Qt::CaseInsensitive)) {
resultInfo.name = ql.language() == QLocale::Chinese ? chineseStr : englishStr;
if (resultName.contains(resultInfo.name)) {
continue;
}
resultName.append(resultInfo.name);
if(ql.language() == QLocale::English) {
englishStr = key + "/" + englishStr;
resultInfo.icon = FileUtils::getSettingIcon(englishStr, true);
resultInfo.actionKey = englishStr;
} else if (ql.language() == QLocale::Chinese) {
chineseStr = key + "/" + chineseStr;
resultInfo.icon = FileUtils::getSettingIcon(chineseStr, true);
resultInfo.actionKey = chineseStr;
}
searchResult->enqueue(resultInfo);
break;
}
}
if (chineseStr.contains(keyword, Qt::CaseInsensitive)) { if (chineseStr.contains(keyword, Qt::CaseInsensitive)) {
resultInfo.name = ql.language() == QLocale::Chinese ? chineseStr : englishStr; resultInfo.name = ql.language() == QLocale::Chinese ? chineseStr : englishStr;
if (resultName.contains(resultInfo.name)) { if (resultName.contains(resultInfo.name)) {