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,13 +121,12 @@ 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 = str; resultInfo.name = ql.language() == QLocale::Chinese ? str : m_englishSearchList[key].at(t);
if (resultName.contains(resultInfo.name)) { if (resultName.contains(resultInfo.name)) {
continue; continue;
} }
@ -142,7 +141,7 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueue<Resu
break; break;
QString pinyin = pinyinlist.at(2 * i); // 中文转拼音 QString pinyin = pinyinlist.at(2 * i); // 中文转拼音
if (pinyin.contains(keyword, Qt::CaseInsensitive)) { if (pinyin.contains(keyword, Qt::CaseInsensitive)) {
resultInfo.name = str; resultInfo.name = ql.language() == QLocale::Chinese ? str : m_englishSearchList[key].at(t);
if (resultName.contains(resultInfo.name)) { if (resultName.contains(resultInfo.name)) {
continue; continue;
} }
@ -156,7 +155,6 @@ void Zeeker::SettingsSearchPlugin::KeywordSearch(QString keyword, DataQueue<Resu
} }
} }
} }
}
for (auto i = m_englishSearchList.constBegin(); i != m_englishSearchList.constEnd(); ++i) { for (auto i = m_englishSearchList.constBegin(); i != m_englishSearchList.constEnd(); ++i) {
QStringList regmatch = *i; QStringList regmatch = *i;
QString key = i.key(); QString key = i.key();
@ -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)) {