Modify app and setting matching

This commit is contained in:
sunfengsheng 2020-12-26 04:50:52 -08:00
parent ded6461ad9
commit 579b97c208
3 changed files with 15 additions and 15 deletions

View File

@ -7,8 +7,12 @@ AppMatch::AppMatch(QObject *parent) : QObject(parent)
} }
QStringList AppMatch::startMatchApp(QString input){ QStringList AppMatch::startMatchApp(QString input){
input.replace(" ","");
m_soureText=input; m_soureText=input;
m_returnResult.clear(); m_returnResult.clear();
if(input.isEmpty()){
return m_returnResult;
}
this->getAppName(); this->getAppName();
m_returnResult=m_midResult; m_returnResult=m_midResult;
m_midResult.clear(); m_midResult.clear();
@ -42,8 +46,15 @@ void AppMatch::getAllDesktopFilePath(QString path){
getAllDesktopFilePath(fileInfo.filePath()); getAllDesktopFilePath(fileInfo.filePath());
} }
else{ else{
//过滤后缀不是.desktop的文件 //过滤LXQt、KDE
QString filePathStr=fileInfo.filePath(); QString filePathStr=fileInfo.filePath();
if(filePathStr.contains("KDE",Qt::CaseInsensitive)||
filePathStr.contains("mate",Qt::CaseInsensitive)||
filePathStr.contains("LX",Qt::CaseInsensitive) ){
i++;
continue;
}
//过滤后缀不是.desktop的文件
if(!filePathStr.endsWith(".desktop")) if(!filePathStr.endsWith(".desktop"))
{ {
i++; i++;
@ -72,17 +83,6 @@ void AppMatch::getAllDesktopFilePath(QString path){
continue; continue;
} }
} }
//过滤LXQt、KDE
char* ret=g_key_file_get_locale_string(keyfile,"Desktop Entry","OnlyShowIn", nullptr, nullptr);
if(ret!=nullptr)
{
QString str=QString::fromLocal8Bit(ret);
if(str.contains("LXQt") || str.contains("KDE"))
{
i++;
continue;
}
}
//过滤中英文名为空的情况 //过滤中英文名为空的情况
QLocale cn; QLocale cn;
QString language=cn.languageToString(cn.language()); QString language=cn.languageToString(cn.language());

View File

@ -5,7 +5,7 @@ SettingsMatch::SettingsMatch(QObject *parent) : QObject(parent)
XmlElement(); XmlElement();
} }
QStringList SettingsMatch::matchstart(const QString &source){ QStringList SettingsMatch::startMatchApp(const QString &source){
m_sourceText=source; m_sourceText=source;
// qDebug()<<m_sourceText; // qDebug()<<m_sourceText;
QStringList settingList=matching(); QStringList settingList=matching();
@ -16,7 +16,7 @@ void SettingsMatch::XmlElement(){
QString pinyinIndex; QString pinyinIndex;
QString ChineseIndex; QString ChineseIndex;
QFile file(QString::fromLocal8Bit("::/res/search.xml")); QFile file(QString::fromLocal8Bit(":/res/search.xml"));
if (!file.open(QIODevice::ReadOnly)){ if (!file.open(QIODevice::ReadOnly)){
return; return;
} }

View File

@ -16,7 +16,7 @@ class SettingsMatch : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit SettingsMatch(QObject *parent = nullptr); explicit SettingsMatch(QObject *parent = nullptr);
QStringList matchstart(const QString &source); QStringList startMatchApp(const QString &source);
private: private:
void XmlElement(); void XmlElement();