Merge pull request #92 from sunfengsheng/main

fix:输入为/设置选项会全部出来
This commit is contained in:
iaom 2021-01-19 08:48:27 +08:00 committed by GitHub
commit 5de90a7ff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -16,6 +16,7 @@ QStringList AppMatch::startMatchApp(QString input){
this->getAppName(); this->getAppName();
m_returnResult=m_midResult; m_returnResult=m_midResult;
m_midResult.clear(); m_midResult.clear();
// qWarning()<<"m_returnResult :"<<m_returnResult;
return m_returnResult; return m_returnResult;
} }
@ -192,6 +193,7 @@ void AppMatch::getAppName()
g_key_file_load_from_file(keyfile,filepath,flags,nullptr); g_key_file_load_from_file(keyfile,filepath,flags,nullptr);
name=g_key_file_get_locale_string(keyfile,"Desktop Entry","Name", nullptr, nullptr); name=g_key_file_get_locale_string(keyfile,"Desktop Entry","Name", nullptr, nullptr);
namestr=QString::fromLocal8Bit(name); namestr=QString::fromLocal8Bit(name);
// qWarning()<<"namestr :"<<namestr;
appNameMatch(namestr,str); appNameMatch(namestr,str);
} }
@ -212,13 +214,15 @@ void AppMatch::appNameMatch(QString appname,QString desktoppath){
m_midResult.append(desktoppath); m_midResult.append(desktoppath);
return; return;
} }
QString pinyin=FileUtils::findMultiToneWords(appname).at(0);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
m_midResult.append(desktoppath);
return;
}
QString shouzimu=FileUtils::findMultiToneWords(appname).at(1);// 中文转首字母 QString shouzimu=FileUtils::findMultiToneWords(appname).at(1);// 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){ if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
m_midResult.append(desktoppath); m_midResult.append(desktoppath);
return;
}
if(m_sourceText.size()<2)
return;
QString pinyin=FileUtils::findMultiToneWords(appname).at(0);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
m_midResult.append(desktoppath);
} }
} }

View File

@ -89,6 +89,8 @@ QStringList SettingsMatch::matching(){
// qDebug()<<key; // qDebug()<<key;
for(int t=0; t<regmatch.size();t++) for(int t=0; t<regmatch.size();t++)
{ {
if(m_sourceText=="/")
continue;
QString str =regmatch.at(t); QString str =regmatch.at(t);
if(str.contains(m_sourceText)) if(str.contains(m_sourceText))
{ {
@ -96,14 +98,14 @@ QStringList SettingsMatch::matching(){
returnresult.append(str);//中文名 returnresult.append(str);//中文名
continue; continue;
} }
QString pinyin=FileUtils::findMultiToneWords(str).at(0);// 中文转拼音 QString shouzimu=FileUtils::findMultiToneWords(str).at(1);// 中文转首字母
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){ if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
str=key+"/"+str; str=key+"/"+str;
returnresult.append(str); returnresult.append(str);
continue; continue;
} }
QString shouzimu=FileUtils::findMultiToneWords(str).at(1);// 中文转首字母 QString pinyin=FileUtils::findMultiToneWords(str).at(0);// 中文转拼音
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){ if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
str=key+"/"+str; str=key+"/"+str;
returnresult.append(str); returnresult.append(str);
} }