From 41ece5dce317070e85495e04058f0d7c7eac6b5a Mon Sep 17 00:00:00 2001 From: sunfengsheng <327123947@qq.com> Date: Mon, 26 Apr 2021 11:39:43 +0800 Subject: [PATCH] fix:can not search android app link:172.17.66.192/biz/bug-view-49153.html --- libsearch/appsearch/app-match.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libsearch/appsearch/app-match.cpp b/libsearch/appsearch/app-match.cpp index c421dba..6db2a13 100644 --- a/libsearch/appsearch/app-match.cpp +++ b/libsearch/appsearch/app-match.cpp @@ -35,6 +35,10 @@ AppMatch::AppMatch(QObject *parent) : QThread(parent) { m_watchAppDir=new QFileSystemWatcher(this); 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>(); qDBusRegisterMetaType>>(); m_interFace=new QDBusInterface ("com.kylin.softwarecenter.getsearchresults", "/com/kylin/softwarecenter/getsearchresults", @@ -59,9 +63,6 @@ AppMatch::~AppMatch(){ } void AppMatch::startMatchApp(QString input,QMap &installed,QMap &softwarereturn){ - input.replace(" ",""); - if(input.isEmpty()) - return; m_sourceText=input; getAppName(installed); softWareCenterSearch(softwarereturn); @@ -363,8 +364,18 @@ void AppMatch::run(){ qDebug()<<"AppMatch is run"; this->getDesktopFilePath(); 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(); + if(path=="/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/"); + } + } }); }