Merge pull request #213 from sunfengsheng/main

fix:can not search android app
This commit is contained in:
iaom 2021-04-26 00:34:12 -05:00 committed by GitHub
commit a70be3f810
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -35,6 +35,10 @@ AppMatch::AppMatch(QObject *parent) : QThread(parent)
{ {
m_watchAppDir=new QFileSystemWatcher(this); m_watchAppDir=new QFileSystemWatcher(this);
m_watchAppDir->addPath("/usr/share/applications/"); m_watchAppDir->addPath("/usr/share/applications/");
QDir androidPath(QDir::homePath()+"/.local/share/applications/");
if(androidPath.exists()){
m_watchAppDir->addPath(QDir::homePath()+"/.local/share/applications/");
}
qDBusRegisterMetaType<QMap<QString,QString>>(); qDBusRegisterMetaType<QMap<QString,QString>>();
qDBusRegisterMetaType<QList<QMap<QString,QString>>>(); qDBusRegisterMetaType<QList<QMap<QString,QString>>>();
m_interFace=new QDBusInterface ("com.kylin.softwarecenter.getsearchresults", "/com/kylin/softwarecenter/getsearchresults", m_interFace=new QDBusInterface ("com.kylin.softwarecenter.getsearchresults", "/com/kylin/softwarecenter/getsearchresults",
@ -59,9 +63,6 @@ AppMatch::~AppMatch(){
} }
void AppMatch::startMatchApp(QString input,QMap<NameString,QStringList> &installed,QMap<NameString,QStringList> &softwarereturn){ void AppMatch::startMatchApp(QString input,QMap<NameString,QStringList> &installed,QMap<NameString,QStringList> &softwarereturn){
input.replace(" ","");
if(input.isEmpty())
return;
m_sourceText=input; m_sourceText=input;
getAppName(installed); getAppName(installed);
softWareCenterSearch(softwarereturn); softWareCenterSearch(softwarereturn);
@ -363,8 +364,18 @@ void AppMatch::run(){
qDebug()<<"AppMatch is run"; qDebug()<<"AppMatch is run";
this->getDesktopFilePath(); this->getDesktopFilePath();
this->getAllDesktopFilePath("/usr/share/applications/"); this->getAllDesktopFilePath("/usr/share/applications/");
connect(m_watchAppDir,&QFileSystemWatcher::directoryChanged,[this](){ QDir androidPath(QDir::homePath()+"/.local/share/applications/");
if(androidPath.exists())
this->getAllDesktopFilePath(QDir::homePath()+"/.local/share/applications/");
connect(m_watchAppDir,&QFileSystemWatcher::directoryChanged,this,[=](const QString &path){
this->getDesktopFilePath(); this->getDesktopFilePath();
if(path=="/usr/share/applications/"){
this->getAllDesktopFilePath("/usr/share/applications/"); this->getAllDesktopFilePath("/usr/share/applications/");
}
if(androidPath.exists()){
if(path==QDir::homePath()+"/.local/share/applications/"){
this->getAllDesktopFilePath(QDir::homePath()+"/.local/share/applications/");
}
}
}); });
} }